From c34fd3c2b0655b9236a0f4816864a22a87336e4e Mon Sep 17 00:00:00 2001 From: MattHag <16444067+MattHag@users.noreply.github.com> Date: Tue, 5 Nov 2024 03:14:46 +0100 Subject: [PATCH] Remove NamedInts: Convert LedRampChoice to flag Related #2273 --- lib/logitech_receiver/hidpp20.py | 7 ++++++- lib/logitech_receiver/settings_templates.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/logitech_receiver/hidpp20.py b/lib/logitech_receiver/hidpp20.py index 73218523..3713d9a1 100644 --- a/lib/logitech_receiver/hidpp20.py +++ b/lib/logitech_receiver/hidpp20.py @@ -990,7 +990,12 @@ class LEDParam: saturation = "saturation" -LEDRampChoices = common.NamedInts(default=0, yes=1, no=2) +class LedRampChoice(IntEnum): + DEFAULT = 0 + YES = 1 + NO = 2 + + LEDFormChoices = common.NamedInts(default=0, sine=1, square=2, triangle=3, sawtooth=4, sharkfin=5, exponential=6) LEDParamSize = { LEDParam.color: 3, diff --git a/lib/logitech_receiver/settings_templates.py b/lib/logitech_receiver/settings_templates.py index d69b2a4a..c67c9473 100644 --- a/lib/logitech_receiver/settings_templates.py +++ b/lib/logitech_receiver/settings_templates.py @@ -1608,7 +1608,7 @@ class LEDZoneSetting(settings.Setting): speed_field = {"name": _LEDP.speed, "kind": settings.Kind.RANGE, "label": _("Speed"), "min": 0, "max": 255} period_field = {"name": _LEDP.period, "kind": settings.Kind.RANGE, "label": _("Period"), "min": 100, "max": 5000} intensity_field = {"name": _LEDP.intensity, "kind": settings.Kind.RANGE, "label": _("Intensity"), "min": 0, "max": 100} - ramp_field = {"name": _LEDP.ramp, "kind": settings.Kind.CHOICE, "label": _("Ramp"), "choices": hidpp20.LEDRampChoices} + ramp_field = {"name": _LEDP.ramp, "kind": settings.Kind.CHOICE, "label": _("Ramp"), "choices": hidpp20.LedRampChoice} possible_fields = [color_field, speed_field, period_field, intensity_field, ramp_field] @classmethod