add a keycode for setting LED to a defined brightness
This commit is contained in:
parent
967046587b
commit
cd4ba26e95
@ -9,6 +9,7 @@ from kmk.utils import clamp
|
|||||||
class LEDKeyMeta:
|
class LEDKeyMeta:
|
||||||
def __init__(self, *leds):
|
def __init__(self, *leds):
|
||||||
self.leds = leds
|
self.leds = leds
|
||||||
|
self.brightness = None
|
||||||
|
|
||||||
|
|
||||||
class AnimationModes:
|
class AnimationModes:
|
||||||
@ -74,6 +75,11 @@ class LED(Extension):
|
|||||||
validator=self._led_key_validator,
|
validator=self._led_key_validator,
|
||||||
on_press=self._key_led_dec,
|
on_press=self._key_led_dec,
|
||||||
)
|
)
|
||||||
|
make_argumented_key(
|
||||||
|
names=('LED_SET',),
|
||||||
|
validator=self._led_set_key_validator,
|
||||||
|
on_press=self._key_led_set,
|
||||||
|
)
|
||||||
make_key(names=('LED_ANI',), on_press=self._key_led_ani)
|
make_key(names=('LED_ANI',), on_press=self._key_led_ani)
|
||||||
make_key(names=('LED_AND',), on_press=self._key_led_and)
|
make_key(names=('LED_AND',), on_press=self._key_led_and)
|
||||||
make_key(
|
make_key(
|
||||||
@ -220,6 +226,11 @@ class LED(Extension):
|
|||||||
>>>>>>> c7bdb7c (apply suggested changes)
|
>>>>>>> c7bdb7c (apply suggested changes)
|
||||||
return LEDKeyMeta(*leds)
|
return LEDKeyMeta(*leds)
|
||||||
|
|
||||||
|
def _led_set_key_validator(self, brightness, *leds):
|
||||||
|
meta = self._led_key_validator(*leds)
|
||||||
|
meta.brightness = brightness
|
||||||
|
return meta
|
||||||
|
|
||||||
def _key_led_tog(self, *args, **kwargs):
|
def _key_led_tog(self, *args, **kwargs):
|
||||||
if self.animation_mode == AnimationModes.STATIC_STANDBY:
|
if self.animation_mode == AnimationModes.STATIC_STANDBY:
|
||||||
self.animation_mode = AnimationModes.STATIC
|
self.animation_mode = AnimationModes.STATIC
|
||||||
@ -232,6 +243,9 @@ class LED(Extension):
|
|||||||
def _key_led_dec(self, key, *args, **kwargs):
|
def _key_led_dec(self, key, *args, **kwargs):
|
||||||
self.decrease_brightness(leds=key.meta.leds)
|
self.decrease_brightness(leds=key.meta.leds)
|
||||||
|
|
||||||
|
def _key_led_set(self, key, *args, **kwargs):
|
||||||
|
self.set_brightness(percent=key.meta.brightness, leds=key.meta.leds)
|
||||||
|
|
||||||
def _key_led_ani(self, *args, **kwargs):
|
def _key_led_ani(self, *args, **kwargs):
|
||||||
self.increase_ani()
|
self.increase_ani()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user