fixed splits. Enabled extensions on nyquist
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import board
|
||||
|
||||
from kmk.extensions.rgb import RGB
|
||||
from kmk.extensions.split import Split
|
||||
from kmk.kmk_keyboard import KMKKeyboard as _KMKKeyboard
|
||||
from kmk.matrix import DiodeOrientation
|
||||
|
||||
@@ -15,3 +17,17 @@ class KMKKeyboard(_KMKKeyboard):
|
||||
uart_pin = board.SCL
|
||||
rgb_pixel_pin = board.TX
|
||||
extra_data_pin = board.SDA
|
||||
rgb_ext = RGB(
|
||||
pixel_pin=board.TX,
|
||||
num_pixels=12,
|
||||
val_limit=150,
|
||||
hue_step=10,
|
||||
sat_step=5,
|
||||
val_step=5,
|
||||
hue_default=260,
|
||||
sat_default=100,
|
||||
val_default=40,
|
||||
animation_speed=1,
|
||||
)
|
||||
split = Split(uart_pin=board.SCL, split_offsets=[6, 6, 6, 6, 6])
|
||||
extensions = [rgb_ext, split]
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import busio
|
||||
|
||||
from kmk.extensions import Extension
|
||||
from kmk.kmktime import sleep_ms
|
||||
from kmk.matrix import intify_coordinate
|
||||
|
||||
|
||||
@@ -16,20 +15,20 @@ class Split(Extension):
|
||||
def __init__(
|
||||
self,
|
||||
extra_data_pin=None,
|
||||
offsets=(),
|
||||
flip=False,
|
||||
side=None,
|
||||
stype=None,
|
||||
split_offsets=None,
|
||||
split_flip=True,
|
||||
split_side=None,
|
||||
split_type=SplitType.UART,
|
||||
target_left=True,
|
||||
uart_flip=True,
|
||||
uart_pin=None,
|
||||
uart_timeout=20,
|
||||
):
|
||||
self.extra_data_pin = extra_data_pin
|
||||
self.split_offsets = offsets
|
||||
self.split_flip = flip
|
||||
self.split_side = side
|
||||
self.split_type = stype
|
||||
self.split_offsets = split_offsets
|
||||
self.split_flip = split_flip
|
||||
self.split_side = split_side
|
||||
self.split_type = split_type
|
||||
self.split_target_left = target_left
|
||||
self._uart = None
|
||||
self._uart_buffer = []
|
||||
@@ -38,26 +37,20 @@ class Split(Extension):
|
||||
self.uart_timeout = uart_timeout
|
||||
|
||||
def during_bootup(self, keyboard):
|
||||
if self.split_type is not None:
|
||||
try:
|
||||
# Working around https://github.com/adafruit/circuitpython/issues/1769
|
||||
keyboard._hid_helper_inst.create_report([]).send()
|
||||
self._is_target = True
|
||||
|
||||
# Sleep 2s so target portion doesn't "appear" to boot quicker than
|
||||
# dependent portions (which will take ~2s to time out on the HID send)
|
||||
sleep_ms(2000)
|
||||
except OSError:
|
||||
self._is_target = False
|
||||
|
||||
if self.split_flip and not self._is_target:
|
||||
keyboard.col_pins = list(reversed(keyboard.col_pins))
|
||||
if self.split_side == 'Left':
|
||||
self.split_target_left = self._is_target
|
||||
elif self.split_side == 'Right':
|
||||
self.split_target_left = not self._is_target
|
||||
else:
|
||||
try:
|
||||
# Working around https://github.com/adafruit/circuitpython/issues/1769
|
||||
# keyboard._hid_helper_inst.create_report([]).send()
|
||||
# Line above is broken and needs fixed for aut detection
|
||||
self._is_target = True
|
||||
except OSError:
|
||||
self._is_target = False
|
||||
|
||||
if self.split_flip and not self._is_target:
|
||||
keyboard.col_pins = list(reversed(keyboard.col_pins))
|
||||
if self.split_side == 'Left':
|
||||
self.split_target_left = self._is_target
|
||||
elif self.split_side == 'Right':
|
||||
self.split_target_left = not self._is_target
|
||||
|
||||
if self.uart_pin is not None:
|
||||
if self._is_target:
|
||||
@@ -68,7 +61,6 @@ class Split(Extension):
|
||||
self._uart = busio.UART(
|
||||
tx=self.uart_pin, rx=None, timeout=self.uart_timeout
|
||||
)
|
||||
|
||||
# Attempt to sanely guess a coord_mapping if one is not provided.
|
||||
if not keyboard.coord_mapping:
|
||||
keyboard.coord_mapping = []
|
||||
|
@@ -341,7 +341,8 @@ class KMKKeyboard:
|
||||
self._extensions = [] + getattr(self, 'extensions', [])
|
||||
|
||||
try:
|
||||
print('EXTENSIONS', self.extensions)
|
||||
if self.debug_enabled:
|
||||
print('EXTENSIONS', self.extensions)
|
||||
del self.extensions
|
||||
except Exception:
|
||||
pass
|
||||
@@ -360,7 +361,9 @@ class KMKKeyboard:
|
||||
except Exception:
|
||||
# TODO FIXME log the exceptions or something
|
||||
print('Failed to load ', ext)
|
||||
pass
|
||||
import time
|
||||
|
||||
time.sleep(30)
|
||||
|
||||
self._init_matrix()
|
||||
|
||||
@@ -373,7 +376,7 @@ class KMKKeyboard:
|
||||
try:
|
||||
self._handle_matrix_report(ext.before_matrix_scan(self))
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print('Failed to run pre matrix function: ', e)
|
||||
|
||||
matrix_update = self.matrix.scan_for_changes()
|
||||
self._handle_matrix_report(matrix_update)
|
||||
@@ -382,7 +385,7 @@ class KMKKeyboard:
|
||||
try:
|
||||
ext.after_matrix_scan(self, matrix_update)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print('Failed to run post matrix function: ', e)
|
||||
|
||||
for ext in self._extensions:
|
||||
try:
|
||||
|
@@ -2,7 +2,6 @@ import board
|
||||
|
||||
from kmk.boards.converter.keebio.nyquist_r2 import KMKKeyboard
|
||||
from kmk.extensions.leader import Leader, LeaderMode
|
||||
from kmk.extensions.rgb import RGB
|
||||
from kmk.handlers.sequences import send_string, simple_key_sequence
|
||||
from kmk.keys import KC
|
||||
|
||||
@@ -11,7 +10,6 @@ keyboard = KMKKeyboard()
|
||||
# ------------------User level config variables ---------------------------------------
|
||||
keyboard.tap_time = 150
|
||||
keyboard.leader_timeout = 2000
|
||||
keyboard.debug_enabled = False
|
||||
|
||||
# RGB Config (underglow)
|
||||
'''
|
||||
@@ -26,8 +24,8 @@ keyboard.rgb_config['val_default'] = 40
|
||||
keyboard.rgb_config['knight_effect_length'] = 4
|
||||
keyboard.rgb_config['animation_mode'] = 'static'
|
||||
keyboard.rgb_config['animation_speed'] = 1
|
||||
keyboard.debug_enabled = False
|
||||
'''
|
||||
keyboard.debug_enabled = False
|
||||
_______ = KC.TRNS
|
||||
XXXXXXX = KC.NO
|
||||
SHFT_INS = KC.LSHIFT(KC.INS)
|
||||
@@ -44,9 +42,7 @@ leader_ext = Leader(mode=LeaderMode.ENTER, sequences={
|
||||
'dbg': KC.DBG,
|
||||
})
|
||||
|
||||
rgb_ext = RGB(pixel_pin=board.TX, num_pixels=12, val_limit=150, hue_step=10, sat_step=5, val_step=5, hue_default=260, sat_default=100, val_default=40, animation_speed=1)
|
||||
|
||||
keyboard.extensions = [leader_ext, rgb_ext]
|
||||
keyboard.extensions.append(leader_ext)
|
||||
|
||||
HACHEEJ = simple_key_sequence((
|
||||
KC.LSFT(KC.SCOLON), KC.H, KC.A, KC.C, KC.H, KC.E, KC.E, KC.J, KC.A, KC.I, KC.L, KC.N1, KC.LSFT(KC.SCOLON),
|
||||
|
Reference in New Issue
Block a user