otaku42 / v4l2py

V4L2 python library
GNU General Public License v3.0
0 stars 0 forks source link

set_to_(minimum|maximum) and (in|de)crease might fail for ControlType.MENU #12

Closed otaku42 closed 1 year ago

otaku42 commented 1 year ago
0x009a0901: <Control auto_exposure type=menu min=0 max=3 step=1 default=3 value=3> <--
 - <MenuItem index=1 name=Manual Mode>
 - <MenuItem index=3 name=Aperture Priority Mode>

Trying to set auto_exposure on this camera to 0 (which according to the driver should be acceptable, see min=0) results in an error, since no menu item with index 0 is defined. Calling decrease() would fail for the same reason: there is no menu item with index 2.

One possible solution would be to not rely on the minimum and maximum values announced by the driver when dealing with menu controls, but rather determine the lowest/highest index of all items that are defined for that menu control; similar for increasing/decreasing the control.

But.. what about other control types, such as string or boolean? While a boolean may be considered having a minimum of 0 (False) and a maximum of 1 (True), and trying to increase/decrease it may be ignored, how would that apply to a string? It appears now that introducing these helpers in https://github.com/otaku42/v4l2py/commit/c352385f343edd2fc7625d0aadf4e4b1ccb35dc9 as currently implemented was not well thought, since they each make sense only for certain control types, but not for others. Hmm.

otaku42 commented 1 year ago

Note to self; take v4l2_ctrl_type documentation into account.