New animation

This commit is contained in:
Kyle Brown 2019-03-15 17:37:25 -07:00
parent bb198709f2
commit 86b8c4ffb0
5 changed files with 82 additions and 21 deletions

View File

@ -52,8 +52,6 @@ def gesc_pressed(key, state, KC, *args, **kwargs):
if GESC_TRIGGERS.intersection(state.keys_pressed):
# First, release GUI if already pressed
state.keys_pressed.discard(KC.LGUI)
state.keys_pressed.discard(KC.RGUI)
state.config._send_hid()
# if Shift is held, KC_GRAVE will become KC_TILDE on OS level
state.keys_pressed.add(KC.GRAVE)
@ -191,6 +189,12 @@ def rgb_mode_rainbow(key, state, *args, **kwargs):
return state
def rgb_mode_swirl(key, state, *args, **kwargs):
state.config.pixels.effect_init = True
state.config.pixels.animation_mode = 'swirl'
return state
def rgb_mode_knight(key, state, *args, **kwargs):
state.config.pixels.effect_init = True
state.config.pixels.animation_mode = 'knight'

View File

@ -640,6 +640,7 @@ make_key(names=('RGB_MODE_BREATHE', 'RGB_M_B'), on_press=handlers.rgb_mode_breat
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_SWIRL', 'RGB_M_S'), on_press=handlers.rgb_mode_swirl)
make_key(names=('RGB_MODE_KNIGHT', 'RGB_M_K'), on_press=handlers.rgb_mode_knight)

View File

@ -51,7 +51,7 @@ class RGB:
self.knight_effect_length = knight_effect_length
self.val_limit = val_limit
self.rgb_animation_mode = animation_mode
self.rgb_animation_speed = animation_speed
self.animation_speed = animation_speed
except ImportError as e:
print(e)
@ -358,6 +358,8 @@ class RGB:
return self.effect_static()
elif self.animation_mode == 'knight':
return self.effect_knight()
elif self.animation_mode == 'swirl':
return self.effect_swirl()
elif self.animation_mode == 'static_standby':
pass
else:
@ -418,6 +420,22 @@ class RGB:
return self
def effect_swirl(self):
if self._animation_step():
self.increase_hue(self.animation_speed)
self.disable_auto_write = True # Turn off instantly showing
for i in range(0, self.num_pixels):
self.set_hsv(
(self.hue - (i * self.num_pixels)) % 360,
self.sat,
self.val,
i)
# Show final results
self.disable_auto_write = False # Resume showing changes
self.show()
return self
def effect_knight(self):
# Determine which LEDs should be lit up
self.disable_auto_write = True # Turn off instantly showing

View File

@ -1,16 +1,58 @@
from kmk.boards.converter.fourtypercentclub.luddite import Firmware
from kmk.consts import LeaderMode, UnicodeMode
from kmk.handlers.sequences import compile_unicode_string_sequences
from kmk.keys import KC
from kmk.keys import KC, make_key
keyboard = Firmware()
# ---------------------------------- Config --------------------------------------------
keyboard.leader_mode = LeaderMode.TIMEOUT
keyboard.leader_mode = LeaderMode.ENTER
keyboard.unicode_mode = UnicodeMode.LINUX
keyboard.tap_time = 150
keyboard.leader_timeout = 2000
keyboard.leader_timeout = 999999999999
keyboard.rgb_num_pixels = 16
keyboard.rgb_hue_default = 260
keyboard.rgb_sat_default = 100
keyboard.rgb_val_default = 20
keyboard.rgb_knight_effect_length = 6
keyboard.rgb_animation_mode = 'static'
keyboard.rgb_animation_speed = 3
keyboard.debug_enabled = True
# ---------------------- Custom Functions --------------------------------------------
def portal_lights(*args, **kwargs):
keyboard.pixels.disable_auto_write = True
keyboard.pixels.rgb_animation_mode = 'User'
for i in range(0, 9):
keyboard.pixels.set_hsv(21, 100, 100, i)
for i in range(10, 16):
keyboard.pixels.set_hsv(220, 100, 100, i)
keyboard.pixels.show()
def portal_off(*args, **kwargs):
keyboard.pixels.disable_auto_write = False
keyboard.pixels.off()
keyboard.pixels.rgb_animation_mode = 'static'
# ---------------------- Custom Keys --------------------------------------------
LON = make_key(on_press=portal_lights)
LOFF = make_key(on_press=portal_off)
_______ = KC.TRNS
XXXXXXX = KC.NO
HOME = KC.MT(KC.HOME, KC.LSFT)
END = KC.MT(KC.END, KC.RSFT)
BASE = 0
FN1 = 1
# ---------------------- Leader Key Macros --------------------------------------------
@ -35,17 +77,13 @@ keyboard.leader_dictionary = {
'f': emoticons.F,
'meh': emoticons.MEH,
'yay': emoticons.YAY,
}
'p': LON,
'po': LOFF,
}
# ---------------------- Keymap ---------------------------------------------------------
_______ = KC.TRNS
XXXXXXX = KC.NO
BASE = 0
FN1 = 1
keyboard.keymap = [
[
[KC.GESC, KC.N1, KC.N2, KC.N3, KC.N4, KC.N5, KC.N6, KC.N7],
@ -55,7 +93,7 @@ keyboard.keymap = [
[KC.U, KC.I, KC.D, KC.H, KC.T, KC.N, KC.S, KC.MINS],
[KC.ENT, KC.LSFT, KC.SCLN, KC.Q, KC.J, KC.K, KC.X, KC.B],
[KC.M, KC.W, KC.V, KC.Z, KC.RSFT, KC.LCTL, KC.LGUI, KC.MO(FN1)],
[KC.SPC, KC.LEFT, KC.DOWN, KC.UP, KC.RIGHT],
[KC.SPC, KC.LEFT, KC.DOWN, KC.UP, KC.RIGHT],
],
[
@ -65,8 +103,8 @@ keyboard.keymap = [
[_______, _______, KC.VOLU, _______, _______, _______, _______, _______],
[_______, _______, _______, _______, _______, _______, _______, KC.VOLD],
[_______, _______, _______, _______, _______, _______, _______, _______],
[_______, _______, _______, _______, _______, KC.GRV, _______, _______],
[_______, KC.LALT, _______, _______, _______],
[_______, _______, _______, _______, _______, KC.RGB_M_K, _______, _______],
[_______, KC.LALT, KC.RGB_M_S, LON, LOFF],
],
]

View File

@ -95,11 +95,11 @@ keyboard.keymap = [
],
[
# r3
[KC.GESC, KC.RGB_M_P, KC.RGB_M_K, KC.RGB_M_B, KC.RGB_M_BR, _______, _______, _______, KC.F10, KC.F11, KC.F12, KC.DEL],
[KC.RGB_ANI, KC.RGB_HUD, KC.RGB_HUI, _______, _______, _______, _______, _______, KC.F7, KC.F8, KC.F9, SHFT_INS],
[KC.RGB_AND, KC.RGB_SAD, KC.RGB_SAI, _______, _______, _______, _______, _______, KC.F4, KC.F5, KC.F6, KC.VOLU],
[_______, KC.RGB_VAD, KC.RGB_VAI, _______, _______, _______, _______, _______, KC.F1, KC.F2, KC.F4, KC.VOLD],
[BASE, GAMING, _______, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX],
[KC.GESC, KC.RGB_M_P, KC.RGB_M_K, KC.RGB_M_B, KC.RGB_M_BR, KC.RGB_M_S, _______, _______, KC.F10, KC.F11, KC.F12, KC.DEL],
[KC.RGB_ANI, KC.RGB_HUD, KC.RGB_HUI, _______, _______, _______, _______, _______, KC.F7, KC.F8, KC.F9, SHFT_INS],
[KC.RGB_AND, KC.RGB_SAD, KC.RGB_SAI, _______, _______, _______, _______, _______, KC.F4, KC.F5, KC.F6, KC.VOLU],
[_______, KC.RGB_VAD, KC.RGB_VAI, _______, _______, _______, _______, _______, KC.F1, KC.F2, KC.F4, KC.VOLD],
[BASE, GAMING, _______, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX],
],
]