device: handle BRIGHTNESS CONTROL notifications

This commit is contained in:
Peter F. Patel-Schneider 2024-03-23 13:27:24 -04:00
parent 3876f07d57
commit 490493d7a3
1 changed files with 14 additions and 0 deletions

View File

@ -437,5 +437,19 @@ def _process_feature_notification(device, n, feature):
device.setting_callback(device, _st.AdjustableDpi, [profile.resolutions[resolution_index]])
break
elif feature == _F.BRIGHTNESS_CONTROL:
if n.address > 0x10:
if logger.isEnabledFor(logging.INFO):
logger.info("%s: unknown BRIGHTNESS CONTROL %s", device, n)
else:
if n.address == 0x00:
brightness = _unpack("!H", n.data[:2])[0]
device.setting_callback(device, _st.BrightnessControl, [brightness])
elif n.address == 0x10:
brightness = n.data[0] & 0x01
if brightness:
brightness = _unpack("!H", device.feature_request(_F.BRIGHTNESS_CONTROL, 0x10)[:2])[0]
device.setting_callback(device, _st.BrightnessControl, [brightness])
_diversion.process_notification(device, n, feature)
return True