From f7a1d5475208e483deb2b6beab8bbc29e2d3aee2 Mon Sep 17 00:00:00 2001 From: Kyle Brown Date: Tue, 26 Feb 2019 17:30:53 -0800 Subject: [PATCH] Added LED support, cleaned up RGB docs --- docs/led.md | 54 ++++++++++ docs/rgb.md | 57 ++++++----- kmk/firmware.py | 68 ++++++++---- kmk/handlers/stock.py | 49 +++++++-- kmk/keys.py | 11 ++ kmk/led.py | 125 +++++++++++++++++++++++ kmk/rgb.py | 53 ++++++---- user_keymaps/kdb424/nyquist_converter.py | 69 +++---------- 8 files changed, 356 insertions(+), 130 deletions(-) create mode 100644 docs/led.md create mode 100644 kmk/led.py diff --git a/docs/led.md b/docs/led.md new file mode 100644 index 0000000..1145c05 --- /dev/null +++ b/docs/led.md @@ -0,0 +1,54 @@ +# LED (Mono color backlight) +Want your keyboard to shine? Add some lights! + +## Usage +At minimum you will need to make sure that this set in either your keymap is importing an MCU directly, or it should be included in the predefined boards if they support them. + +|Define |Description | +|---------------------|---------------------------------------------| +|`keyboard.led_pin` |The pin connected to the data pin of the LEDs| + +Then you should be able to use the keycodes below to change the LED lighting to your liking. + +## [Keycodes] + +|Key |Aliases |Description | +|-----------------------------|-------------------|----------------------------| +|`KC.LED_TOG` | |Toggles LED's | +|`KC.LED_INC` | |Increase Brightness | +|`KC.LED_DEC` | |Decrease Brightness | +|`KC.LED_ANI` | |Increase animation speed | +|`KC.LED_AND` | |Decrease animation speed | +|`KC.LED_MODE_PLAIN` |`LED_M_P` |Static LED's | +|`KC.LED_MODE_BREATHE` |`LED_M_B` |Breathing animation | + +## Configuration +|Define |Default |Description | +|-------------------------------|-------------|------------------------------------------------| +|`keyboard.led_brightness_step` |`5` |The number of steps to change the brightness by | +|`keyboard.led_brightness_limit`|`100` |The maximum brightness level in percent | + +## Built-in Animation Configuration +|Define |Default |Description | +|-------------------------------|-------------|-------------------------------------------------------------------------------------| +|`keyboard.led_breath_center` |`1.5` |Used to calculate the curve for the breathing animation. Anywhere from 1.0 - 2.7 is valid| + +## Functions + +If you want to create your own animations, or for example, change the lighting in a macro, or a layer switch, here are some functions that are available. + +|Function |Description | +|--------------------------------------------|--------------------------------------------------------------------------------------------| +|`keyboard.pixels.increase_brightness(step)` |Increases hue by a given step | +|`keyboard.pixels.decrease_brightness(step)` |Decreases hue by a given step | +|`keyboard.pixels.set_brightness(percent)` |Increases saturation by a given step | + +## Direct variable access +|Define |Default |Description | +|-----------------------------------|-----------|--------------------------------------------------------------------------------------------------------| +|`keyboard.led.brightness` |`0` |Sets the brightness by percent 0-100 | +|`keyboard.led.brightness_limit` |`100` |Sets the limit of brightness | +|`keyboard.led.brightness_step` |`5` |Sets the step value to change brightness by | +|`keyboard.led.animation_mode` |`static` |This can be changed to any modes included, or to something custom for user animations. Any string is valid | +|`keyboard.led.animation_speed` |`1` |Increases animation speed of most animations. Recommended 1-5, Maximum 10. | + diff --git a/docs/rgb.md b/docs/rgb.md index 164e93c..ec4c7e6 100644 --- a/docs/rgb.md +++ b/docs/rgb.md @@ -12,7 +12,7 @@ Currently we support the following addressable LEDs: * All neopixels ## Usage -At minimum you will need to make sure that these are set in either your keymap ip importing an MCU directly, or it should be included in the predefined boards if they support them. +At minimum you will need to make sure that these are set in either your keymap is importing an MCU directly, or it should be included in the predefined boards if they support them. |Define |Description | |---------------------|---------------------------------------------| @@ -49,13 +49,19 @@ Changing the **Value** sets the overall brightness. |`KC.RGB_MODE_KNIGHT` |`RGB_M_K` |Knightrider animation | ## Configuration -|Define |Default |Description | -|---------------------|-------------|-----------------------------------------------------------------------------| -|`keyboard.rgb_order` |`(1, 0, 2)` |The order of the pixels R G B, and optionally white. Example(1, 0, 2, 3) | -|`keyboard.hue_step` |`10` |The number of steps to cycle through the hue by | -|`keyboard.sat_step` |`17` |The number of steps to increment the saturation by | -|`keyboard.val_step` |`17` |The number of steps to increment the brightness by | -|`keyboard.val_limit` |`255` |The maximum brightness level | +|Define |Default |Description | +|-------------------------|-------------|-----------------------------------------------------------------------------| +|`keyboard.rgb_order` |`(1, 0, 2)` |The order of the pixels R G B, and optionally white. Example(1, 0, 2, 3) | +|`keyboard.rgb_hue_step` |`10` |The number of steps to cycle through the hue by | +|`keyboard.rgb_sat_step` |`17` |The number of steps to change the saturation by | +|`keyboard.rgb_val_step` |`17` |The number of steps to change the brightness by | +|`keyboard.rgb_val_limit` |`255` |The maximum brightness level | + +## Built-in Animation Configuration +|Define |Default |Description | +|-----------------------------------|-------------|-------------------------------------------------------------------------------------| +|`keyboard.rgb_breath_center` |`1.5` |Used to calculate the curve for the breathing animation. Anywhere from 1.0 - 2.7 is valid| +|`keyboard.rgb_knight_effect_length`|`4` |The number of LEDs to light up for the "Knight" animation | ## Functions @@ -67,6 +73,7 @@ If you want to create your own animations, or for example, change the lighting i |`keyboard.pixels.set_hsv(hue, sat, val, index)` |Sets a single LED with HSV value | |`keyboard.pixels.set_rgb_fill((r, g, b))` |Fills all LED's with RGB(W) values | |`keyboard.pixels.set_rgb((r, g, b), index)` |Set's a single LED with RGB(W) values | +|`keyboard.pixels.disable_auto_write(bool)` |When True, disables showing changes. Good for setting multiple LED's before a visible update| |`keyboard.pixels.increase_hue(step)` |Increases hue by a given step | |`keyboard.pixels.decrease_hue(step)` |Decreases hue by a given step | |`keyboard.pixels.increase_sat(step)` |Increases saturation by a given step | @@ -79,32 +86,28 @@ If you want to create your own animations, or for example, change the lighting i |`keyboard.pixels.show()` |Displays all stored configuration for LED's. Useful with disable_auto_write explained below | |`keyboard.pixels.time_ms()` |Returns a time in ms since the board has booted. Useful for start/stop timers | -Other settings that are useful that can be changed. -## Configuration -|Define |Default |Description | -|------------------------------|-------------|---------------------------------------------------------------------------------------------------------| -|`keyboard.hue` |`0` |Sets the hue from 0-360 | -|`keyboard.sat` |`100` |Sets the saturation from 0-100 | -|`keyboard.val` |`80` |Sets the brightness from 1-255 | -|`keyboard.disable_auto_write` |`False` |When True, disables showing changes. Good for setting multiple LED's before a visible update | -|`keyboard.reverse_animation` |`False` |If true, some animations will run in reverse. Can be safely used in user animations | -|`keyboard.animation_mode` |`static` |This can be changed to any modes included, or to something custom for user animations. Any string is valid | -|`keyboard.animation_speed` |`1` |Increases animation speed of most animations. Recommended 1-5, Maximum 10. | +## Direct variable access +|Define |Default |Description | +|-----------------------------------|-----------|-----------------------------------------------------------------------------------------------------------| +|`keyboard.pixels.hue` |`0` |Sets the hue from 0-360 | +|`keyboard.pixels.sat` |`100` |Sets the saturation from 0-100 | +|`keyboard.pixels.val` |`80` |Sets the brightness from 1-255 | +|`keyboard.pixels.reverse_animation`|`False` |If true, some animations will run in reverse. Can be safely used in user animations | +|`keyboard.pixels.animation_mode` |`static` |This can be changed to any modes included, or to something custom for user animations. Any string is valid | +|`keyboard.pixels.animation_speed` |`1` |Increases animation speed of most animations. Recommended 1-5, Maximum 10. | -## Built-in Animation Configuration -|Define |Default |Description | -|-------------------------------|-------------|-------------------------------------------------------------------------------------| -|`keyboard.breath_center` |`1.5` |Used to calculate the curve for the breathing animation. Anywhere from 1.0 - 2.7 is valid| -|`keyboard.knight_effect_length`|`4` |The number of LEDs to light up for the "Knight" animation | ## Hardware Modification -To add LED's to boards that don't support them, you will have to add a 3 wires. The power wire will run on 3.3v or 5v (depending on the LED), ground, and data pins will need added to an unused pin on your microcontroller unless your keyboard has specific solder points for them. With those 3 wires connected, set the pixel_pin as described above, and you are ready to use your LED's/Neopixels. +To add RGB LED's to boards that don't support them directly, you will have to add a 3 wires. The power wire will run on 3.3v or 5v (depending on the LED), +ground, and data pins will need added to an unused pin on your microcontroller unless your keyboard has specific solder points for them. With those 3 wires +connected, set the pixel_pin as described above, and you are ready to use your RGB LED's/Neopixels. ## ADVANCED USAGE -If you wish to interact with these as you would normal LED's and do not want help from KMK, you can disable all helper functions from working and access the neopixel object directly like this. +If you wish to interact with these as you would normal LED's and do not want help from KMK, you can disable all helper functions from working and access the +neopixel object directly like this. ```python -keyboard.pixels.disabse_auto_write = True +keyboard.pixels.disable_auto_write = True keyboard.pixels.neopixel() # <-- This is the neopixel object ``` diff --git a/kmk/firmware.py b/kmk/firmware.py index 389bde5..98e4fa3 100644 --- a/kmk/firmware.py +++ b/kmk/firmware.py @@ -92,21 +92,30 @@ class Firmware: uart_pin = None # RGB config - pixel_pin = None - num_pixels = None + rgb_pixel_pin = None + rgb_pixels = None + rgb_num_pixels = None rgb_order = (1, 0, 2) # GRB WS2812 - val_limit = 255 - hue_default = 0 - sat_default = 100 - val_default = val_limit - hue_step = 1 - sat_step = 1 - val_step = 1 - animation_speed = 1 - breathe_center = 1.5 # 1.0-2.7 - knight_effect_length = 3 - animation_mode = 'static' - pixels = None + rgb_val_limit = 255 + rgb_hue_default = 0 + rgb_sat_default = 100 + rgb_val_default = rgb_val_limit + rgb_hue_step = 1 + rgb_sat_step = 1 + rgb_val_step = 1 + rgb_animation_speed = 1 + rgb_breathe_center = 1.5 # 1.0-2.7 + rgb_knight_effect_length = 3 + rgb_animation_mode = 'static' + + # led config (mono color) + led = None + led_pin = None + led_brightness_step = 5 + led_brightness_limit = 100 + led_breathe_center = 1.5 + led_animation_mode = 'static' + led_animation_speed = 1 def __init__(self): # Attempt to sanely guess a coord_mapping if one is not provided @@ -220,14 +229,21 @@ class Firmware: if self.uart_pin is not None: self.uart = self.init_uart(self.uart_pin) - if self.pixel_pin is not None: - self.pixels = rgb.RGB(self.pixel_pin, self.rgb_order, self.num_pixels, - self.hue_step, self.sat_step, self.val_step, - self.hue_default, self.sat_default, self.val_default, - self.breathe_center, self.knight_effect_length, - self.val_limit, self.animation_mode, self.animation_speed, + if self.rgb_pixel_pin is not None: + self.pixels = rgb.RGB(self.rgb_pixel_pin, self.rgb_order, self.rgb_num_pixels, + self.rgb_hue_step, self.rgb_sat_step, self.rgb_val_step, + self.rgb_hue_default, self.rgb_sat_default, self.rgb_val_default, + self.rgb_breathe_center, self.rgb_knight_effect_length, + self.rgb_val_limit, self.rgb_animation_mode, + self.rgb_animation_speed, ) + if self.led_pin: + self.led = led.led(self.led_pin, self.led_brightness_step, self.led_brightness_limit, + self.led_animation_mode, self.led_animation_speed, + self.led_breathe_center, + ) + self.matrix = MatrixScanner( cols=self.col_pins, rows=self.row_pins, @@ -286,7 +302,15 @@ class Firmware: if self.debug_enabled and state_changed and self.pixels.enabled: print('New State: {}'.format(self.pixels)) - if self.pixels.animation_mode is not None: - self.pixels = self.pixels.animate() + if self.pixels: + # Only check animations if pixels is initialized + if self.pixels.animation_mode: + if self.pixels.animation_mode is not 'static_standby': + self.pixels = self.pixels.animate() + + if self.led: + # Only check animations if led is initialized + if self.led.animation_mode: + self.led = self.led.animate() gc.collect() diff --git a/kmk/handlers/stock.py b/kmk/handlers/stock.py index 3dc7d85..736cc61 100644 --- a/kmk/handlers/stock.py +++ b/kmk/handlers/stock.py @@ -126,32 +126,32 @@ def rgb_tog(key, state, *args, **kwargs): def rgb_hui(key, state, *args, **kwargs): - state.config.pixels.increase_hue(state.config.pixels.hue_step) + state.config.pixels.increase_hue() return state def rgb_hud(key, state, *args, **kwargs): - state.config.pixels.decrease_hue(state.config.pixels.hue_step) + state.config.pixels.decrease_hue() return state def rgb_sai(key, state, *args, **kwargs): - state.config.pixels.increase_sat(state.config.pixels.sat_step) + state.config.pixels.increase_sat() return state def rgb_sad(key, state, *args, **kwargs): - state.config.pixels.decrease_sat(state.config.pixels.sat_step) + state.config.pixels.decrease_sat() return state def rgb_vai(key, state, *args, **kwargs): - state.config.pixels.increase_val(state.config.pixels.val_step) + state.config.pixels.increase_val() return state def rgb_vad(key, state, *args, **kwargs): - state.config.pixels.decrease_val(state.config.pixels.val_step) + state.config.pixels.decrease_val() return state @@ -193,3 +193,40 @@ def rgb_mode_knight(key, state, *args, **kwargs): state.config.pixels.effect_init = True state.config.pixels.animation_mode = 'knight' return state + + +def led_tog(key, state, *args, **kwargs): + state.config.led.enabled = not state.config.led.enabled + return state + + +def led_inc(key, state, *args, **kwargs): + state.config.led.increase_brightness() + return state + + +def led_dec(key, state, *args, **kwargs): + state.config.led.decrease_brightness() + return state + + +def led_ani(key, state, *args, **kwargs): + state.config.led.increase_ani() + return state + + +def led_and(key, state, *args, **kwargs): + state.config.led.decrease_ani() + return state + + +def led_mode_static(key, state, *args, **kwargs): + state.config.led.effect_init = True + state.config.led.animation_mode = 'static' + return state + + +def led_mode_breathe(key, state, *args, **kwargs): + state.config.led.effect_init = True + state.config.led.animation_mode = 'breathing' + return state diff --git a/kmk/keys.py b/kmk/keys.py index 2e2b6ff..40ee7d5 100644 --- a/kmk/keys.py +++ b/kmk/keys.py @@ -641,6 +641,17 @@ make_key(names=('RGB_MODE_RAINBOW', 'RGB_M_R'), on_press=handlers.rgb_mode_rainb make_key(names=('RGB_MODE_BREATHE_RAINBOW', 'RGB_M_BR'), on_press=handlers.rgb_mode_breathe_rainbow) make_key(names=('RGB_MODE_KNIGHT', 'RGB_M_K'), on_press=handlers.rgb_mode_knight) + + +make_key(names=('LED_TOG',), on_press=handlers.led_tog) +make_key(names=('LED_INC',), on_press=handlers.led_inc) +make_key(names=('LED_DEC',), on_press=handlers.led_dec) +make_key(names=('LED_ANI',), on_press=handlers.led_ani) +make_key(names=('LED_AND',), on_press=handlers.led_and) +make_key(names=('LED_MODE_PLAIN', 'LED_M_P'), on_press=handlers.led_mode_static) +make_key(names=('LED_MODE_BREATHE', 'LED_M_B'), on_press=handlers.led_mode_breathe) + + make_key( names=('LEADER', 'LEAD'), on_press=handlers.leader_pressed, diff --git a/kmk/led.py b/kmk/led.py new file mode 100644 index 0000000..eaaad7e --- /dev/null +++ b/kmk/led.py @@ -0,0 +1,125 @@ +import time +from math import e, exp, pi, sin + +import pulseio + + +class led: + brightness = 0 + time = int(time.monotonic() * 1000) + pos = 0 + effect_init = False + + led = None + brightness_step = 5 + brightness_limit = 100 + breath_center = 1.5 + animation_mode = 'static' + animation_speed = 1 + enabled = True + + def __init__(self, led_pin, brightness_step, brightness_limit, + animation_mode, animation_speed, breath_center): + self.led = pulseio.PWMOut(led_pin) + self.brightness_step = brightness_step + self.brightness_limit = brightness_limit + self.animation_mode = animation_mode + self.animation_speed = animation_speed + self.breath_center = breath_center + + def __repr__(self): + return 'LED({})'.format(self._to_dict()) + + def _to_dict(self): + return { + 'led': self.led, + 'brightness_step': self.brightness_step, + 'brightness_limit': self.brightness_limit, + 'animation_mode': self.animation_mode, + 'animation_speed': self.animation_speed, + 'breath_center': self.breath_center, + } + + def time_ms(self): + return int(time.monotonic() * 1000) + + def set_brightness(self, percent): + self.led.duty_cycle = int(percent / 100 * 65535) + + def increase_brightness(self, step=None): + if not step: + self.brightness += self.brightness_step + else: + self.brightness += step + + if self.brightness > 100: + self.brightness = 100 + + self.set_brightness(self.brightness) + + def decrease_brightness(self, step=None): + if not step: + self.brightness -= self.brightness_step + else: + self.brightness -= step + + if self.brightness < 0: + self.brightness = 0 + + self.set_brightness(self.brightness) + + def off(self): + self.set_brightness(0) + + def increase_ani(self): + """ + Increases animation speed by 1 amount stopping at 10 + :param step: + """ + if (self.animation_speed + 1) >= 10: + self.animation_speed = 10 + else: + self.val += 1 + + def decrease_ani(self): + """ + Decreases animation speed by 1 amount stopping at 0 + :param step: + """ + if (self.val - 1) <= 0: + self.val = 0 + else: + self.val -= 1 + + def effect_breathing(self): + # http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ + # https://github.com/qmk/qmk_firmware/blob/9f1d781fcb7129a07e671a46461e501e3f1ae59d/quantum/rgblight.c#L806 + self.brightness = int((exp(sin((self.pos / 255.0) * pi)) - self.breath_center / e) * + (self.brightness_limit / (e - 1 / e))) + self.pos = (self.pos + self.animation_speed) % 256 + self.set_brightness(self.brightness) + + return self + + def effect_static(self): + self.set_brightness(self.brightness) + # Set animation mode to none to prevent cycles from being wasted + self.animation_mode = None + return self + + def animate(self): + """ + Activates a "step" in the animation based on the active mode + :return: Returns the new state in animation + """ + if self.effect_init: + self.init_effect() + if self.enabled: + if self.animation_mode == 'breathing': + return self.effect_breathing() + elif self.animation_mode == 'static': + return self.effect_static() + else: + self.off() + + return self diff --git a/kmk/rgb.py b/kmk/rgb.py index b9a5eb1..037cb65 100644 --- a/kmk/rgb.py +++ b/kmk/rgb.py @@ -1,6 +1,5 @@ import time -from math import e as M_E -from math import exp, floor, pi, sin +from math import e, exp, pi, sin class RGB: @@ -8,7 +7,7 @@ class RGB: sat = 100 val = 80 pos = 0 - time = floor(time.monotonic() * 10) + time = int(time.monotonic() * 10) intervals = (30, 20, 10, 5) animation_speed = 1 enabled = True @@ -61,7 +60,7 @@ class RGB: return 'RGB({})'.format(self._to_dict()) def _to_dict(self): - ret = { + return { 'hue': self.hue, 'sat': self.sat, 'val': self.val, @@ -74,10 +73,8 @@ class RGB: 'disable_auto_write': self.disable_auto_write, } - return ret - def time_ms(self): - return floor(time.monotonic() * 1000) + return int(time.monotonic() * 1000) def hsv_to_rgb(self, hue, sat, val): """ @@ -101,9 +98,9 @@ class RGB: else: base = ((100 - sat) * val) / 100 - color = floor((val - base) * ((hue % 60) / 60)) + color = int((val - base) * ((hue % 60) / 60)) - x = floor(hue / 60) + x = int(hue / 60) if x == 0: r = val g = base + color @@ -129,7 +126,7 @@ class RGB: g = base b = val - color - return floor(r), floor(g), floor(b) + return int(r), int(g), int(b) def hsv_to_rgbw(self, hue, sat, val): """ @@ -190,58 +187,76 @@ class RGB: if not self.disable_auto_write: self.neopixel.show() - def increase_hue(self, step): + def increase_hue(self, step=None): """ Increases hue by step amount rolling at 360 and returning to 0 :param step: """ + if not step: + step = self.hue_step + self.hue = (self.hue + step) % 360 - def decrease_hue(self, step): + def decrease_hue(self, step=None): """ Decreases hue by step amount rolling at 0 and returning to 360 :param step: """ + if not step: + step = self.hue_step + if (self.hue - step) <= 0: self.hue = (self.hue + 360 - step) % 360 else: self.hue = (self.hue - step) % 360 - def increase_sat(self, step): + def increase_sat(self, step=None): """ Increases saturation by step amount stopping at 100 :param step: """ + if not step: + step = self.sat_step + if self.sat + step >= 100: self.sat = 100 else: self.sat += step - def decrease_sat(self, step): + def decrease_sat(self, step=None): """ Decreases saturation by step amount stopping at 0 :param step: """ + if not step: + step = self.sat_step + if (self.sat - step) <= 0: self.sat = 0 else: self.sat -= step - def increase_val(self, step): + def increase_val(self, step=None): """ Increases value by step amount stopping at 100 :param step: """ + if not step: + step = self.val_step + if (self.val + step) >= 100: self.val = 100 else: self.val += step - def decrease_val(self, step): + def decrease_val(self, step=None): """ Decreases value by step amount stopping at 0 :param step: """ + if not step: + step = self.val_step + if (self.val - step) <= 0: self.val = 0 else: @@ -326,8 +341,8 @@ class RGB: def effect_breathing(self): # http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ # https://github.com/qmk/qmk_firmware/blob/9f1d781fcb7129a07e671a46461e501e3f1ae59d/quantum/rgblight.c#L806 - self.val = floor((exp(sin((self.pos / 255.0) * pi)) - self.breath_center / M_E) * - (self.val_limit / (M_E - 1 / M_E))) + self.val = int((exp(sin((self.pos / 255.0) * pi)) - self.breath_center / e) * + (self.val_limit / (e - 1 / e))) self.pos = (self.pos + self.animation_speed) % 256 self.set_hsv_fill(self.hue, self.sat, self.val) @@ -351,7 +366,7 @@ class RGB: # Determine which LEDs should be lit up self.disable_auto_write = True # Turn off instantly showing self.off() # Fill all off - pos = floor(self.pos) + pos = int(self.pos) # Set all pixels on in range of animation length offset by position for i in range(pos, (pos + self.knight_effect_length)): diff --git a/user_keymaps/kdb424/nyquist_converter.py b/user_keymaps/kdb424/nyquist_converter.py index 6c7024d..4b92c68 100644 --- a/user_keymaps/kdb424/nyquist_converter.py +++ b/user_keymaps/kdb424/nyquist_converter.py @@ -28,23 +28,20 @@ keyboard.tap_time = 150 keyboard.leader_timeout = 2000 keyboard.debug_enabled = True -keyboard.pixel_pin = board.TX -keyboard.num_pixels = 12 -keyboard.val_limit = 150 -keyboard.hue_step = 5 -keyboard.sat_step = 5 -keyboard.val_step = 5 -keyboard.hue_default = 260 -keyboard.knight_effect_length = 4 -keyboard.animation_mode = 'knight' -keyboard.animation_speed = 2 +# RGB Config (underglow) +keyboard.rgb_pixel_pin = board.TX +keyboard.rgb_num_pixels = 12 -OFF = (0, 0, 0) -BLUE = (0, 0, 100) -CYAN = (0, 100, 100) -PURPLE = (71, 0, 100) -RED = (100, 0, 0) -WHITE = (100, 100, 100) +keyboard.rgb_val_limit = 150 +keyboard.rgb_hue_step = 5 +keyboard.rgb_sat_step = 5 +keyboard.rgb_val_step = 5 +keyboard.rgb_hue_default = 260 +keyboard.rgb_sat_default = 100 +keyboard.rgb_val_default = 20 +keyboard.rgb_knight_effect_length = 4 +keyboard.rgb_animation_mode = 'static' +keyboard.rgb_animation_speed = 2 emoticons = compile_unicode_string_sequences({ # Emoticons, but fancier @@ -79,74 +76,34 @@ r3 = 4 def base(*args, **kwargs): - ''' - keyboard.pixels.animation_mode = 'breathing' - keyboard.pixels.neopixel(OFF) - keyboard.pixels.neopixelshow() - ''' return df_pressed(*args, **kwargs) def layer1p(*args, **kwargs): - ''' - keyboard.pixels.animation_mode = 'User' - keyboard.pixels.neopixel.fill(WHITE) - keyboard.pixels.neopixel.show() - ''' return mo_pressed(*args, **kwargs) def layer1r(*args, **kwargs): - ''' - keyboard.pixels.animation_mode = 'breathing' - keyboard.pixels.neopixel.fill(OFF) - keyboard.pixels.neopixel.show() - ''' return mo_released(*args, **kwargs) def layer2p(*args, **kwargs): - ''' - keyboard.pixels.animation_mode = 'User' - keyboard.pixels.neopixel.fill(BLUE) - keyboard.pixels.neopixel.show() - ''' return lt_pressed(*args, **kwargs) def layer2r(*args, **kwargs): - ''' - keyboard.pixels.animation_mode = 'breathing' - keyboard.pixels.neopixel.fill(OFF) - keyboard.pixels.neopixel.show() - ''' return lt_released(*args, **kwargs) def layer3p(*args, **kwargs): - ''' - keyboard.pixels.animation_mode = 'User' - keyboard.pixels.neopixel.fill(PURPLE) - keyboard.pixels.neopixel.show() - ''' return mo_pressed(*args, **kwargs) def layer3r(*args, **kwargs): - ''' - keyboard.pixels.animation_mode = 'breathing' - keyboard.pixels.neopixel.fill(OFF) - keyboard.pixels.neopixel.show() - ''' return mo_released(*args, **kwargs) def gaming(*args, **kwargs): - ''' - keyboard.pixels.animation_mode = 'User' - keyboard.pixels.neopixel.fill(CYAN) - keyboard.pixels.neopixel.show() - ''' return df_pressed(*args, **kwargs)