code cleanup to pass lint and some for flake8
This commit is contained in:
parent
1751cce299
commit
9fbad17ed4
@ -171,8 +171,7 @@ class InternalState:
|
||||
return self
|
||||
|
||||
if (
|
||||
changed_key not in self.tap_dance_counts or
|
||||
not self.tap_dance_counts[changed_key]
|
||||
changed_key not in self.tap_dance_counts or not self.tap_dance_counts[changed_key]
|
||||
):
|
||||
self.tap_dance_counts[changed_key] = 1
|
||||
self.set_timeout(self.config.tap_time, lambda: self._end_tap_dance(changed_key))
|
||||
@ -257,8 +256,7 @@ class InternalState:
|
||||
|
||||
for key in keys_pressed:
|
||||
if (
|
||||
self.config.leader_mode == LeaderMode.ENTER_ACTIVE and
|
||||
key == KC.ENT
|
||||
self.config.leader_mode == LeaderMode.ENTER_ACTIVE and key == KC.ENT
|
||||
):
|
||||
self._handle_leader_sequence()
|
||||
break
|
||||
|
@ -638,7 +638,8 @@ make_key(names=('RGB_VAD',), on_press=handlers.rgb_vad)
|
||||
make_key(names=('RGB_MODE_PLAIN', 'RGB_M_P'), on_press=handlers.rgb_mode_static)
|
||||
make_key(names=('RGB_MODE_BREATHE', 'RGB_M_B'), on_press=handlers.rgb_mode_breathe)
|
||||
make_key(names=('RGB_MODE_RAINBOW', 'RGB_M_R'), on_press=handlers.rgb_mode_rainbow)
|
||||
make_key(names=('RGB_MODE_BREATHE_RAINBOW', 'RGB_M_BR'), on_press=handlers.rgb_mode_breathe_rainbow)
|
||||
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=('LEADER', 'LEAD'),
|
||||
|
69
kmk/rgb.py
69
kmk/rgb.py
@ -1,6 +1,6 @@
|
||||
from math import sin, exp, pi, floor
|
||||
from math import e as M_E
|
||||
import time
|
||||
from math import e as M_E
|
||||
from math import exp, floor, pi, sin
|
||||
|
||||
|
||||
class RGB:
|
||||
@ -65,7 +65,6 @@ class RGB:
|
||||
'hue': self.hue,
|
||||
'sat': self.sat,
|
||||
'val': self.val,
|
||||
'animation_mode': self.animation_mode,
|
||||
'time': self.time,
|
||||
'intervals': self.intervals,
|
||||
'animation_mode': self.animation_mode,
|
||||
@ -81,13 +80,13 @@ class RGB:
|
||||
return floor(time.monotonic() * 10)
|
||||
|
||||
def hsv_to_rgb(self, hue, sat, val):
|
||||
'''
|
||||
"""
|
||||
Converts HSV values, and returns a tuple of RGB values
|
||||
:param hue:
|
||||
:param sat:
|
||||
:param val:
|
||||
:return: (r, g, b)
|
||||
'''
|
||||
"""
|
||||
r = 0
|
||||
g = 0
|
||||
b = 0
|
||||
@ -133,24 +132,24 @@ class RGB:
|
||||
return floor(r), floor(g), floor(b)
|
||||
|
||||
def hsv_to_rgbw(self, hue, sat, val):
|
||||
'''
|
||||
"""
|
||||
Converts HSV values, and returns a tuple of RGBW values
|
||||
:param hue:
|
||||
:param sat:
|
||||
:param val:
|
||||
:return: (r, g, b, w)
|
||||
'''
|
||||
"""
|
||||
rgb = self.hsv_to_rgb(hue, sat, val)
|
||||
return rgb[0], rgb[1], rgb[2], min(rgb)
|
||||
|
||||
def set_hsv(self, hue, sat, val, index):
|
||||
'''
|
||||
"""
|
||||
Takes HSV values and displays it on a single LED/Neopixel
|
||||
:param hue:
|
||||
:param sat:
|
||||
:param val:
|
||||
:param index: Index of LED/Pixel
|
||||
'''
|
||||
"""
|
||||
if self.neopixel:
|
||||
if self.rgbw:
|
||||
self.set_rgb(self.hsv_to_rgbw(hue, sat, val), index)
|
||||
@ -158,13 +157,12 @@ class RGB:
|
||||
self.set_rgb(self.hsv_to_rgb(hue, sat, val), index)
|
||||
|
||||
def set_hsv_fill(self, hue, sat, val):
|
||||
'''
|
||||
"""
|
||||
Takes HSV values and displays it on all LEDs/Neopixels
|
||||
:param hue:
|
||||
:param sat:
|
||||
:param val:
|
||||
:param index: Index of LED/Pixel
|
||||
'''
|
||||
"""
|
||||
if self.neopixel:
|
||||
if self.rgbw:
|
||||
self.set_rgb_fill(self.hsv_to_rgbw(hue, sat, val))
|
||||
@ -172,103 +170,102 @@ class RGB:
|
||||
self.set_rgb_fill(self.hsv_to_rgb(hue, sat, val))
|
||||
|
||||
def set_rgb(self, rgb, index):
|
||||
'''
|
||||
"""
|
||||
Takes an RGB or RGBW and displays it on a single LED/Neopixel
|
||||
:param rgb: RGB or RGBW
|
||||
:param index: Index of LED/Pixel
|
||||
'''
|
||||
if self.neopixel:
|
||||
if index >=0 and index <= self.num_pixels - 1:
|
||||
"""
|
||||
if self.neopixel and 0 <= index <= self.num_pixels - 1:
|
||||
self.neopixel[index] = rgb
|
||||
if not self.disable_auto_write:
|
||||
self.neopixel.show()
|
||||
|
||||
def set_rgb_fill(self, rgb):
|
||||
'''
|
||||
"""
|
||||
Takes an RGB or RGBW and displays it on all LEDs/Neopixels
|
||||
:param rgb: RGB or RGBW
|
||||
'''
|
||||
"""
|
||||
if self.neopixel:
|
||||
self.neopixel.fill(rgb)
|
||||
if not self.disable_auto_write:
|
||||
self.neopixel.show()
|
||||
|
||||
def increase_hue(self, step):
|
||||
'''
|
||||
"""
|
||||
Increases hue by step amount rolling at 360 and returning to 0
|
||||
:param step:
|
||||
'''
|
||||
"""
|
||||
self.hue = (self.hue + step) % 360
|
||||
|
||||
def decrease_hue(self, step):
|
||||
'''
|
||||
"""
|
||||
Decreases hue by step amount rolling at 0 and returning to 360
|
||||
:param 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):
|
||||
'''
|
||||
"""
|
||||
Increases saturation by step amount stopping at 100
|
||||
:param step:
|
||||
'''
|
||||
"""
|
||||
if self.sat + step >= 100:
|
||||
self.sat = 100
|
||||
else:
|
||||
self.sat += step
|
||||
|
||||
def decrease_sat(self, step):
|
||||
'''
|
||||
"""
|
||||
Decreases saturation by step amount stopping at 0
|
||||
:param step:
|
||||
'''
|
||||
"""
|
||||
if (self.sat - step) <= 0:
|
||||
self.sat = 0
|
||||
else:
|
||||
self.sat -= step
|
||||
|
||||
def increase_val(self, step):
|
||||
'''
|
||||
"""
|
||||
Increases value by step amount stopping at 100
|
||||
:param step:
|
||||
'''
|
||||
"""
|
||||
if (self.val + step) >= 100:
|
||||
self.val = 100
|
||||
else:
|
||||
self.val += step
|
||||
|
||||
def decrease_val(self, step):
|
||||
'''
|
||||
"""
|
||||
Decreases value by step amount stopping at 0
|
||||
:param step:
|
||||
'''
|
||||
"""
|
||||
if (self.val - step) <= 0:
|
||||
self.val = 0
|
||||
else:
|
||||
self.val -= step
|
||||
|
||||
def off(self):
|
||||
'''
|
||||
"""
|
||||
Turns off all LEDs/Neopixels without changing stored values
|
||||
'''
|
||||
"""
|
||||
if self.neopixel:
|
||||
self.set_hsv_fill(0, 0, 0)
|
||||
|
||||
def show(self):
|
||||
'''
|
||||
"""
|
||||
Turns on all LEDs/Neopixels without changing stored values
|
||||
'''
|
||||
"""
|
||||
if self.neopixel:
|
||||
self.neopixel.show()
|
||||
|
||||
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:
|
||||
|
@ -2,8 +2,9 @@ import board
|
||||
import busio
|
||||
|
||||
from kmk.consts import DiodeOrientation, LeaderMode, UnicodeMode
|
||||
from kmk.handlers.layers import df_pressed, mo_pressed, mo_released, lt_pressed, lt_released
|
||||
from kmk.handlers.sequences import (compile_unicode_string_sequences)
|
||||
from kmk.handlers.layers import (df_pressed, lt_pressed, lt_released,
|
||||
mo_pressed, mo_released)
|
||||
from kmk.handlers.sequences import compile_unicode_string_sequences
|
||||
from kmk.keys import KC, layer_key_validator, make_argumented_key
|
||||
from kmk.mcus.circuitpython_samd51 import Firmware
|
||||
from kmk.pins import Pin as P
|
||||
|
Loading…
x
Reference in New Issue
Block a user