From c8288a6b697e73fa0c6c9daa4789d22dc03cca8f Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Sun, 24 Mar 2024 09:40:01 -0400 Subject: [PATCH] settings: fix bug in LEDZoneSetting when effect is not implemented --- lib/logitech_receiver/hidpp20.py | 25 ++++++++++++--------- lib/logitech_receiver/settings_templates.py | 4 +++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/logitech_receiver/hidpp20.py b/lib/logitech_receiver/hidpp20.py index 92ba6681..566f8fdd 100644 --- a/lib/logitech_receiver/hidpp20.py +++ b/lib/logitech_receiver/hidpp20.py @@ -909,6 +909,7 @@ class LEDParam: intensity = "intensity" ramp = "ramp" form = "form" + saturation = "saturation" LEDRampChoices = _NamedInts(default=0, yes=1, no=2) @@ -920,19 +921,23 @@ LEDParamSize = { LEDParam.intensity: 1, LEDParam.ramp: 1, LEDParam.form: 1, + LEDParam.saturation: 1, } # not implemented from x8070 Wave=4, Stars=5, Press=6, Audio=7 -# not implemented from x8071 Custom=12, Kitt=13, Decomposition=14, FrameActive=15, FramePassive=16, -# HSVPulsing=20, CycleC=21, WaveC=22, RippleC=23, SignatureActive=24, SignaturePassive=25 +# not implemented from x8071 Custom=12, Kitt=13, HSVPulsing=20, WaveC=22, RippleC=23, SignatureActive=24, SignaturePassive=25 LEDEffects = { - 0x0: [_NamedInt(0x0, _("Disabled")), {}], - 0x1: [_NamedInt(0x1, _("Static")), {LEDParam.color: 0, LEDParam.ramp: 3}], - 0x2: [_NamedInt(0x2, _("Pulse")), {LEDParam.color: 0, LEDParam.speed: 3}], - 0x3: [_NamedInt(0x3, _("Cycle")), {LEDParam.period: 5, LEDParam.intensity: 7}], - 0x8: [_NamedInt(0x8, _("Boot")), {}], - 0x9: [_NamedInt(0x9, _("Demo")), {}], - 0xA: [_NamedInt(0xA, _("Breathe")), {LEDParam.color: 0, LEDParam.period: 3, LEDParam.form: 5, LEDParam.intensity: 6}], - 0xB: [_NamedInt(0xB, _("Ripple")), {LEDParam.color: 0, LEDParam.period: 4}], + 0x00: [_NamedInt(0x00, _("Disabled")), {}], + 0x01: [_NamedInt(0x01, _("Static")), {LEDParam.color: 0, LEDParam.ramp: 3}], + 0x02: [_NamedInt(0x02, _("Pulse")), {LEDParam.color: 0, LEDParam.speed: 3}], + 0x03: [_NamedInt(0x03, _("Cycle")), {LEDParam.period: 5, LEDParam.intensity: 7}], + 0x08: [_NamedInt(0x08, _("Boot")), {}], + 0x09: [_NamedInt(0x09, _("Demo")), {}], + 0x0A: [_NamedInt(0x0A, _("Breathe")), {LEDParam.color: 0, LEDParam.period: 3, LEDParam.form: 5, LEDParam.intensity: 6}], + 0x0B: [_NamedInt(0x0B, _("Ripple")), {LEDParam.color: 0, LEDParam.period: 4}], + 0x0E: [_NamedInt(0x0E, _("Decomposition")), {LEDParam.period: 6, LEDParam.intensity: 8}], + 0x0F: [_NamedInt(0x0F, _("Signature1")), {LEDParam.period: 5, LEDParam.intensity: 7}], + 0x10: [_NamedInt(0x10, _("Signature2")), {LEDParam.period: 5, LEDParam.intensity: 7}], + 0x15: [_NamedInt(0x15, _("CycleS")), {LEDParam.saturation: 1, LEDParam.period: 6, LEDParam.intensity: 8}], } diff --git a/lib/logitech_receiver/settings_templates.py b/lib/logitech_receiver/settings_templates.py index 47021924..c1dbb9cc 100644 --- a/lib/logitech_receiver/settings_templates.py +++ b/lib/logitech_receiver/settings_templates.py @@ -1539,7 +1539,7 @@ class LEDZoneSetting(_Setting): setting = cls(device, rw, validator) setting.name = cls.name + str(int(zone.location)) setting.label = _("LEDs") + " " + str(hidpp20.LEDZoneLocations[zone.location]) - choices = [hidpp20.LEDEffects[e.ID][0] for e in zone.effects] + choices = [hidpp20.LEDEffects[e.ID][0] for e in zone.effects if e.ID in hidpp20.LEDEffects] ID_field = {"name": "ID", "kind": _KIND.choice, "label": None, "choices": choices} setting.possible_fields = [ID_field] + cls.possible_fields setting.fields_map = hidpp20.LEDEffects @@ -1578,6 +1578,8 @@ SETTINGS = [ Backlight3, LEDControl, LEDZoneSetting, + RGBControl, + RGBEffectSetting, BrightnessControl, FnSwap, # simple NewFnSwap, # simple