2018-12-01 09:15:00 +01:00
|
|
|
import board
|
|
|
|
import busio
|
|
|
|
|
2018-12-13 04:35:08 +01:00
|
|
|
from kmk.consts import DiodeOrientation, LeaderMode, UnicodeMode
|
2019-02-24 00:12:50 +01:00
|
|
|
from kmk.handlers.layers import (df_pressed, lt_pressed, lt_released,
|
|
|
|
mo_pressed, mo_released)
|
|
|
|
from kmk.handlers.sequences import compile_unicode_string_sequences
|
2019-02-09 22:12:04 +01:00
|
|
|
from kmk.keys import KC, layer_key_validator, make_argumented_key
|
2018-12-01 09:15:00 +01:00
|
|
|
from kmk.mcus.circuitpython_samd51 import Firmware
|
|
|
|
from kmk.pins import Pin as P
|
|
|
|
|
|
|
|
keyboard = Firmware()
|
|
|
|
|
|
|
|
keyboard.col_pins = (P.RX, P.A1, P.A2, P.A3, P.A4, P.A5)
|
2018-12-11 09:27:24 +01:00
|
|
|
keyboard.row_pins = (P.D13, P.D11, P.D10, P.D9, P.D7)
|
2018-12-01 09:15:00 +01:00
|
|
|
keyboard.diode_orientation = DiodeOrientation.COLUMNS
|
|
|
|
|
|
|
|
keyboard.split_type = "UART"
|
|
|
|
keyboard.split_flip = True
|
|
|
|
keyboard.split_offsets = [6, 6, 6, 6, 6]
|
2018-12-11 09:27:24 +01:00
|
|
|
keyboard.uart_pin = board.SCL
|
|
|
|
keyboard.extra_data_pin = board.SDA
|
2018-12-01 09:15:00 +01:00
|
|
|
|
|
|
|
# ------------------User level config variables ---------------------------------------
|
|
|
|
keyboard.leader_mode = LeaderMode.TIMEOUT
|
2018-12-13 04:35:08 +01:00
|
|
|
keyboard.unicode_mode = UnicodeMode.LINUX
|
2018-12-01 09:15:00 +01:00
|
|
|
keyboard.tap_time = 150
|
|
|
|
keyboard.leader_timeout = 2000
|
2018-12-13 04:35:08 +01:00
|
|
|
keyboard.debug_enabled = True
|
2018-12-01 09:15:00 +01:00
|
|
|
|
2019-02-09 22:12:04 +01:00
|
|
|
keyboard.pixel_pin = board.TX
|
|
|
|
keyboard.num_pixels = 12
|
2019-02-23 04:50:56 +01:00
|
|
|
keyboard.val_limit = 150
|
|
|
|
keyboard.hue_step = 5
|
|
|
|
keyboard.sat_step = 5
|
|
|
|
keyboard.val_step = 5
|
|
|
|
keyboard.hue_default = 260
|
2019-02-23 23:03:13 +01:00
|
|
|
keyboard.knight_effect_length = 4
|
|
|
|
keyboard.animation_mode = 'knight'
|
|
|
|
keyboard.animation_speed = 2
|
2019-02-23 04:50:56 +01:00
|
|
|
|
2019-02-09 22:12:04 +01:00
|
|
|
OFF = (0, 0, 0)
|
2019-02-20 00:01:51 +01:00
|
|
|
BLUE = (0, 0, 100)
|
|
|
|
CYAN = (0, 100, 100)
|
|
|
|
PURPLE = (71, 0, 100)
|
|
|
|
RED = (100, 0, 0)
|
|
|
|
WHITE = (100, 100, 100)
|
2019-02-09 22:12:04 +01:00
|
|
|
|
2018-12-01 09:15:00 +01:00
|
|
|
emoticons = compile_unicode_string_sequences({
|
|
|
|
# Emoticons, but fancier
|
|
|
|
'ANGRY_TABLE_FLIP': r'(ノಠ痊ಠ)ノ彡┻━┻',
|
|
|
|
'CHEER': r'+。:.゚ヽ(´∀。)ノ゚.:。+゚゚+。:.゚ヽ(*´∀)ノ゚.:。+゚',
|
|
|
|
'TABLE_FLIP': r'(╯°□°)╯︵ ┻━┻',
|
|
|
|
'WAT': r'⊙.☉',
|
|
|
|
'FF': r'凸(゚Д゚#)',
|
|
|
|
'F': r'( ̄^ ̄)凸',
|
|
|
|
'MEH': r'╮( ̄_ ̄)╭',
|
|
|
|
'YAY': r'o(^▽^)o',
|
|
|
|
})
|
|
|
|
|
|
|
|
# ---------------------- Leader Key Macros --------------------------------------------
|
|
|
|
|
|
|
|
keyboard.leader_dictionary = {
|
2018-12-30 00:36:46 +01:00
|
|
|
'flip': emoticons.ANGRY_TABLE_FLIP,
|
|
|
|
'cheer': emoticons.CHEER,
|
|
|
|
'wat': emoticons.WAT,
|
|
|
|
'ff': emoticons.FF,
|
|
|
|
'f': emoticons.F,
|
|
|
|
'meh': emoticons.MEH,
|
|
|
|
'yay': emoticons.YAY,
|
2018-12-01 09:15:00 +01:00
|
|
|
}
|
2018-12-11 09:27:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
df = 0
|
|
|
|
gw = 1
|
|
|
|
r1 = 2
|
|
|
|
r2 = 3
|
|
|
|
r3 = 4
|
2019-02-09 22:12:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
def base(*args, **kwargs):
|
2019-02-23 04:50:56 +01:00
|
|
|
'''
|
|
|
|
keyboard.pixels.animation_mode = 'breathing'
|
|
|
|
keyboard.pixels.neopixel(OFF)
|
|
|
|
keyboard.pixels.neopixelshow()
|
|
|
|
'''
|
2019-02-09 22:12:04 +01:00
|
|
|
return df_pressed(*args, **kwargs)
|
|
|
|
|
|
|
|
|
2019-02-20 00:01:51 +01:00
|
|
|
def layer1p(*args, **kwargs):
|
2019-02-23 04:50:56 +01:00
|
|
|
'''
|
|
|
|
keyboard.pixels.animation_mode = 'User'
|
|
|
|
keyboard.pixels.neopixel.fill(WHITE)
|
|
|
|
keyboard.pixels.neopixel.show()
|
|
|
|
'''
|
2019-02-20 00:01:51 +01:00
|
|
|
return mo_pressed(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
def layer1r(*args, **kwargs):
|
2019-02-23 04:50:56 +01:00
|
|
|
'''
|
|
|
|
keyboard.pixels.animation_mode = 'breathing'
|
|
|
|
keyboard.pixels.neopixel.fill(OFF)
|
|
|
|
keyboard.pixels.neopixel.show()
|
|
|
|
'''
|
2019-02-20 00:01:51 +01:00
|
|
|
return mo_released(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
def layer2p(*args, **kwargs):
|
2019-02-23 04:50:56 +01:00
|
|
|
'''
|
|
|
|
keyboard.pixels.animation_mode = 'User'
|
|
|
|
keyboard.pixels.neopixel.fill(BLUE)
|
|
|
|
keyboard.pixels.neopixel.show()
|
|
|
|
'''
|
2019-02-20 00:01:51 +01:00
|
|
|
return lt_pressed(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
def layer2r(*args, **kwargs):
|
2019-02-23 04:50:56 +01:00
|
|
|
'''
|
|
|
|
keyboard.pixels.animation_mode = 'breathing'
|
|
|
|
keyboard.pixels.neopixel.fill(OFF)
|
|
|
|
keyboard.pixels.neopixel.show()
|
|
|
|
'''
|
2019-02-20 00:01:51 +01:00
|
|
|
return lt_released(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
def layer3p(*args, **kwargs):
|
2019-02-23 04:50:56 +01:00
|
|
|
'''
|
|
|
|
keyboard.pixels.animation_mode = 'User'
|
|
|
|
keyboard.pixels.neopixel.fill(PURPLE)
|
|
|
|
keyboard.pixels.neopixel.show()
|
|
|
|
'''
|
2019-02-20 00:01:51 +01:00
|
|
|
return mo_pressed(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
def layer3r(*args, **kwargs):
|
2019-02-23 04:50:56 +01:00
|
|
|
'''
|
|
|
|
keyboard.pixels.animation_mode = 'breathing'
|
|
|
|
keyboard.pixels.neopixel.fill(OFF)
|
|
|
|
keyboard.pixels.neopixel.show()
|
|
|
|
'''
|
2019-02-20 00:01:51 +01:00
|
|
|
return mo_released(*args, **kwargs)
|
|
|
|
|
|
|
|
|
2019-02-09 22:12:04 +01:00
|
|
|
def gaming(*args, **kwargs):
|
2019-02-23 04:50:56 +01:00
|
|
|
'''
|
|
|
|
keyboard.pixels.animation_mode = 'User'
|
|
|
|
keyboard.pixels.neopixel.fill(CYAN)
|
|
|
|
keyboard.pixels.neopixel.show()
|
|
|
|
'''
|
2019-02-09 22:12:04 +01:00
|
|
|
return df_pressed(*args, **kwargs)
|
|
|
|
|
2019-02-20 00:01:51 +01:00
|
|
|
|
2019-02-09 22:12:04 +01:00
|
|
|
make_argumented_key(
|
|
|
|
validator=layer_key_validator,
|
2019-02-20 00:01:51 +01:00
|
|
|
names=('LAYER_BASE',),
|
|
|
|
on_press=base,
|
2019-02-09 22:12:04 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
make_argumented_key(
|
|
|
|
validator=layer_key_validator,
|
2019-02-20 00:01:51 +01:00
|
|
|
names=('LAYER_1',),
|
|
|
|
on_press=layer1p,
|
|
|
|
on_release=layer1r,
|
2019-02-09 22:12:04 +01:00
|
|
|
)
|
2019-02-20 00:01:51 +01:00
|
|
|
|
|
|
|
make_argumented_key(
|
|
|
|
validator=layer_key_validator,
|
|
|
|
names=('LAYER_2',),
|
|
|
|
on_press=layer2p,
|
|
|
|
on_release=layer2r,
|
|
|
|
)
|
|
|
|
|
|
|
|
make_argumented_key(
|
|
|
|
validator=layer_key_validator,
|
|
|
|
names=('LAYER_3',),
|
|
|
|
on_press=layer3p,
|
|
|
|
on_release=layer3r,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
make_argumented_key(
|
|
|
|
validator=layer_key_validator,
|
|
|
|
names=('LAYER_GAMING',),
|
|
|
|
on_press=gaming,
|
|
|
|
)
|
|
|
|
|
|
|
|
_______ = KC.TRNS
|
|
|
|
XXXXXXX = KC.NO
|
|
|
|
SHFT_INS = KC.LSHIFT(KC.INS)
|
|
|
|
|
2019-02-09 22:12:04 +01:00
|
|
|
BASE = KC.LAYER_BASE(df)
|
2019-02-20 00:01:51 +01:00
|
|
|
LAYER_1 = KC.LAYER_1(r1)
|
|
|
|
LT2_SP = KC.LAYER_2(r2, KC.SPC)
|
|
|
|
LAYER_3 = KC.LAYER_3(r3)
|
2019-02-09 22:12:04 +01:00
|
|
|
GAMING = KC.LAYER_GAMING(gw)
|
|
|
|
|
2018-12-01 09:15:00 +01:00
|
|
|
# ---------------------- Keymap ---------------------------------------------------------
|
|
|
|
|
|
|
|
keyboard.keymap = [
|
|
|
|
[
|
2018-12-11 09:27:24 +01:00
|
|
|
# df
|
2019-02-20 00:01:51 +01:00
|
|
|
[KC.GESC, KC.N1, KC.N2, KC.N3, KC.N4, KC.N5, KC.N6, KC.N7, KC.N8, KC.N9, KC.N0, KC.DEL],
|
|
|
|
[KC.GRV, KC.QUOTE, KC.COMMA, KC.DOT, KC.P, KC.Y, KC.F, KC.G, KC.C, KC.R, KC.L, KC.BKSP],
|
|
|
|
[KC.TAB, KC.A, KC.O, KC.E, KC.U, KC.I, KC.D, KC.H, KC.T, KC.N, KC.S, 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.SLSH],
|
2019-02-21 05:40:46 +01:00
|
|
|
[KC.LCTRL, KC.LGUI, KC.LALT, KC.RGB_TOG, LAYER_1, KC.LT(r2, KC.SPC), KC.LT(r2, KC.SPC), LAYER_3, KC.LEFT, KC.DOWN, KC.UP, KC.RIGHT],
|
2018-12-01 09:15:00 +01:00
|
|
|
],
|
|
|
|
[
|
2018-12-11 09:27:24 +01:00
|
|
|
# gw
|
|
|
|
[KC.GESC, KC.N1, KC.N2, KC.N3, KC.N4, KC.N5, KC.N6, KC.N7, KC.N8, KC.N9, KC.N0, KC.DEL],
|
|
|
|
[KC.TAB, KC.QUOT, KC.COMM, KC.DOT, KC.P, KC.Y, KC.F, KC.G, KC.C, KC.R, KC.L, KC.BKSP],
|
|
|
|
[KC.ESC, KC.A, KC.O, KC.E, KC.U, KC.I, KC.D, KC.H, KC.T, KC.N, KC.S, 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.SLSH],
|
2019-02-20 00:01:51 +01:00
|
|
|
[KC.LCTRL, KC.LGUI, KC.LALT, KC.F1, KC.F2, KC.SPC, KC.LT(r2, KC.SPC), KC.MO(r3), KC.LEFT, KC.DOWN, KC.UP, KC.RIGHT],
|
2018-12-01 09:15:00 +01:00
|
|
|
],
|
|
|
|
[
|
2018-12-11 09:27:24 +01:00
|
|
|
# r1
|
2018-12-01 09:15:00 +01:00
|
|
|
[KC.GESC, KC.N1, KC.N2, KC.N3, KC.N4, KC.N5, KC.N6, KC.N7, KC.N8, KC.N9, KC.N0, KC.DEL],
|
|
|
|
[KC.TILD, KC.EXLM, KC.AT, KC.HASH, KC.DLR, KC.PERC, KC.CIRC, KC.AMPR, KC.ASTR, KC.LPRN, KC.RPRN, KC.DEL],
|
2018-12-11 09:27:24 +01:00
|
|
|
[_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC.LBRC, KC.RBRC, KC.BSLS],
|
|
|
|
[_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC.INS, _______, _______, KC.MINS],
|
|
|
|
[KC.RESET, _______, _______, _______, _______, XXXXXXX, XXXXXXX, KC.EQL, KC.HOME, KC.PGDN, KC.PGUP, KC.END],
|
2018-12-01 09:15:00 +01:00
|
|
|
],
|
|
|
|
[
|
2018-12-11 09:27:24 +01:00
|
|
|
# r2
|
2018-12-01 09:15:00 +01:00
|
|
|
[KC.GESC, KC.N1, KC.N2, KC.N3, KC.N4, KC.N5, KC.N6, KC.N7, KC.N8, KC.N9, KC.N0, KC.DEL],
|
2018-12-11 09:27:24 +01:00
|
|
|
[_______, _______, _______, _______, _______, _______, _______, _______, KC.N7, KC.N8, KC.N9, KC.BKSP],
|
|
|
|
[_______, _______, _______, _______, _______, _______, _______, _______, KC.N4, KC.N5, KC.N6, XXXXXXX],
|
|
|
|
[_______, _______, _______, _______, _______, _______, _______, _______, KC.N1, KC.N2, KC.N3, XXXXXXX],
|
|
|
|
[_______, _______, _______, _______, _______, _______, _______, _______, KC.N0, KC.N0, KC.PDOT, KC.ENT],
|
2018-12-01 09:15:00 +01:00
|
|
|
],
|
|
|
|
[
|
2018-12-11 09:27:24 +01:00
|
|
|
# r3
|
2019-02-25 07:32:13 +01:00
|
|
|
[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],
|
2018-12-01 09:15:00 +01:00
|
|
|
],
|
|
|
|
]
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
keyboard.go()
|