From 2f8a7765e5097b2d0acbf321200cae3a543c7b70 Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Sun, 4 Feb 2024 21:06:12 -0500 Subject: [PATCH] ui: handle backlight notification --- lib/logitech_receiver/notifications.py | 8 ++++++++ lib/solaar/ui/config_panel.py | 3 +++ 2 files changed, 11 insertions(+) diff --git a/lib/logitech_receiver/notifications.py b/lib/logitech_receiver/notifications.py index 3e3de9df4..77c7f95e1 100644 --- a/lib/logitech_receiver/notifications.py +++ b/lib/logitech_receiver/notifications.py @@ -410,6 +410,14 @@ def _process_feature_notification(device, status, n, feature): else: _log.warn('%s: unknown REPROG_CONTROLS %s', device, n) + elif feature == _F.BACKLIGHT2: + if (n.address == 0x00): + level = _unpack('!B', n.data[1:2])[0] + from solaar.ui.config_panel import record_setting # prevent circular import + setting = next((s for s in device.settings if s.name == _st.Backlight2Level.name), None) + if setting: + record_setting(device, setting, [level]) + elif feature == _F.REPROG_CONTROLS_V4: if n.address == 0x00: if _log.isEnabledFor(_DEBUG): diff --git a/lib/solaar/ui/config_panel.py b/lib/solaar/ui/config_panel.py index 7e5801d18..daa2a1aa4 100644 --- a/lib/solaar/ui/config_panel.py +++ b/lib/solaar/ui/config_panel.py @@ -18,6 +18,7 @@ import traceback +from logging import DEBUG as _DEBUG from logging import WARNING as _WARNING from logging import getLogger from threading import Timer as _Timer @@ -724,6 +725,8 @@ def record_setting(device, setting, values): def _record_setting(device, setting, values): + if _log.isEnabledFor(_DEBUG): + _log.debug('on %s changing setting %s to %s', device, setting, values) if len(values) > 1: setting.update_key_value(values[0], values[-1]) value = {values[0]: values[-1]}