fixed splits. Enabled extensions on nyquist
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import board
|
import board
|
||||||
|
|
||||||
|
from kmk.extensions.rgb import RGB
|
||||||
|
from kmk.extensions.split import Split
|
||||||
from kmk.kmk_keyboard import KMKKeyboard as _KMKKeyboard
|
from kmk.kmk_keyboard import KMKKeyboard as _KMKKeyboard
|
||||||
from kmk.matrix import DiodeOrientation
|
from kmk.matrix import DiodeOrientation
|
||||||
|
|
||||||
@@ -15,3 +17,17 @@ class KMKKeyboard(_KMKKeyboard):
|
|||||||
uart_pin = board.SCL
|
uart_pin = board.SCL
|
||||||
rgb_pixel_pin = board.TX
|
rgb_pixel_pin = board.TX
|
||||||
extra_data_pin = board.SDA
|
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
|
import busio
|
||||||
|
|
||||||
from kmk.extensions import Extension
|
from kmk.extensions import Extension
|
||||||
from kmk.kmktime import sleep_ms
|
|
||||||
from kmk.matrix import intify_coordinate
|
from kmk.matrix import intify_coordinate
|
||||||
|
|
||||||
|
|
||||||
@@ -16,20 +15,20 @@ class Split(Extension):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
extra_data_pin=None,
|
extra_data_pin=None,
|
||||||
offsets=(),
|
split_offsets=None,
|
||||||
flip=False,
|
split_flip=True,
|
||||||
side=None,
|
split_side=None,
|
||||||
stype=None,
|
split_type=SplitType.UART,
|
||||||
target_left=True,
|
target_left=True,
|
||||||
uart_flip=True,
|
uart_flip=True,
|
||||||
uart_pin=None,
|
uart_pin=None,
|
||||||
uart_timeout=20,
|
uart_timeout=20,
|
||||||
):
|
):
|
||||||
self.extra_data_pin = extra_data_pin
|
self.extra_data_pin = extra_data_pin
|
||||||
self.split_offsets = offsets
|
self.split_offsets = split_offsets
|
||||||
self.split_flip = flip
|
self.split_flip = split_flip
|
||||||
self.split_side = side
|
self.split_side = split_side
|
||||||
self.split_type = stype
|
self.split_type = split_type
|
||||||
self.split_target_left = target_left
|
self.split_target_left = target_left
|
||||||
self._uart = None
|
self._uart = None
|
||||||
self._uart_buffer = []
|
self._uart_buffer = []
|
||||||
@@ -38,15 +37,11 @@ class Split(Extension):
|
|||||||
self.uart_timeout = uart_timeout
|
self.uart_timeout = uart_timeout
|
||||||
|
|
||||||
def during_bootup(self, keyboard):
|
def during_bootup(self, keyboard):
|
||||||
if self.split_type is not None:
|
|
||||||
try:
|
try:
|
||||||
# Working around https://github.com/adafruit/circuitpython/issues/1769
|
# Working around https://github.com/adafruit/circuitpython/issues/1769
|
||||||
keyboard._hid_helper_inst.create_report([]).send()
|
# keyboard._hid_helper_inst.create_report([]).send()
|
||||||
|
# Line above is broken and needs fixed for aut detection
|
||||||
self._is_target = True
|
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:
|
except OSError:
|
||||||
self._is_target = False
|
self._is_target = False
|
||||||
|
|
||||||
@@ -56,8 +51,6 @@ class Split(Extension):
|
|||||||
self.split_target_left = self._is_target
|
self.split_target_left = self._is_target
|
||||||
elif self.split_side == 'Right':
|
elif self.split_side == 'Right':
|
||||||
self.split_target_left = not self._is_target
|
self.split_target_left = not self._is_target
|
||||||
else:
|
|
||||||
self._is_target = True
|
|
||||||
|
|
||||||
if self.uart_pin is not None:
|
if self.uart_pin is not None:
|
||||||
if self._is_target:
|
if self._is_target:
|
||||||
@@ -68,7 +61,6 @@ class Split(Extension):
|
|||||||
self._uart = busio.UART(
|
self._uart = busio.UART(
|
||||||
tx=self.uart_pin, rx=None, timeout=self.uart_timeout
|
tx=self.uart_pin, rx=None, timeout=self.uart_timeout
|
||||||
)
|
)
|
||||||
|
|
||||||
# Attempt to sanely guess a coord_mapping if one is not provided.
|
# Attempt to sanely guess a coord_mapping if one is not provided.
|
||||||
if not keyboard.coord_mapping:
|
if not keyboard.coord_mapping:
|
||||||
keyboard.coord_mapping = []
|
keyboard.coord_mapping = []
|
||||||
|
@@ -341,6 +341,7 @@ class KMKKeyboard:
|
|||||||
self._extensions = [] + getattr(self, 'extensions', [])
|
self._extensions = [] + getattr(self, 'extensions', [])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if self.debug_enabled:
|
||||||
print('EXTENSIONS', self.extensions)
|
print('EXTENSIONS', self.extensions)
|
||||||
del self.extensions
|
del self.extensions
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -360,7 +361,9 @@ class KMKKeyboard:
|
|||||||
except Exception:
|
except Exception:
|
||||||
# TODO FIXME log the exceptions or something
|
# TODO FIXME log the exceptions or something
|
||||||
print('Failed to load ', ext)
|
print('Failed to load ', ext)
|
||||||
pass
|
import time
|
||||||
|
|
||||||
|
time.sleep(30)
|
||||||
|
|
||||||
self._init_matrix()
|
self._init_matrix()
|
||||||
|
|
||||||
@@ -373,7 +376,7 @@ class KMKKeyboard:
|
|||||||
try:
|
try:
|
||||||
self._handle_matrix_report(ext.before_matrix_scan(self))
|
self._handle_matrix_report(ext.before_matrix_scan(self))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print('Failed to run pre matrix function: ', e)
|
||||||
|
|
||||||
matrix_update = self.matrix.scan_for_changes()
|
matrix_update = self.matrix.scan_for_changes()
|
||||||
self._handle_matrix_report(matrix_update)
|
self._handle_matrix_report(matrix_update)
|
||||||
@@ -382,7 +385,7 @@ class KMKKeyboard:
|
|||||||
try:
|
try:
|
||||||
ext.after_matrix_scan(self, matrix_update)
|
ext.after_matrix_scan(self, matrix_update)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print('Failed to run post matrix function: ', e)
|
||||||
|
|
||||||
for ext in self._extensions:
|
for ext in self._extensions:
|
||||||
try:
|
try:
|
||||||
|
@@ -2,7 +2,6 @@ import board
|
|||||||
|
|
||||||
from kmk.boards.converter.keebio.nyquist_r2 import KMKKeyboard
|
from kmk.boards.converter.keebio.nyquist_r2 import KMKKeyboard
|
||||||
from kmk.extensions.leader import Leader, LeaderMode
|
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.handlers.sequences import send_string, simple_key_sequence
|
||||||
from kmk.keys import KC
|
from kmk.keys import KC
|
||||||
|
|
||||||
@@ -11,7 +10,6 @@ keyboard = KMKKeyboard()
|
|||||||
# ------------------User level config variables ---------------------------------------
|
# ------------------User level config variables ---------------------------------------
|
||||||
keyboard.tap_time = 150
|
keyboard.tap_time = 150
|
||||||
keyboard.leader_timeout = 2000
|
keyboard.leader_timeout = 2000
|
||||||
keyboard.debug_enabled = False
|
|
||||||
|
|
||||||
# RGB Config (underglow)
|
# RGB Config (underglow)
|
||||||
'''
|
'''
|
||||||
@@ -26,8 +24,8 @@ keyboard.rgb_config['val_default'] = 40
|
|||||||
keyboard.rgb_config['knight_effect_length'] = 4
|
keyboard.rgb_config['knight_effect_length'] = 4
|
||||||
keyboard.rgb_config['animation_mode'] = 'static'
|
keyboard.rgb_config['animation_mode'] = 'static'
|
||||||
keyboard.rgb_config['animation_speed'] = 1
|
keyboard.rgb_config['animation_speed'] = 1
|
||||||
keyboard.debug_enabled = False
|
|
||||||
'''
|
'''
|
||||||
|
keyboard.debug_enabled = False
|
||||||
_______ = KC.TRNS
|
_______ = KC.TRNS
|
||||||
XXXXXXX = KC.NO
|
XXXXXXX = KC.NO
|
||||||
SHFT_INS = KC.LSHIFT(KC.INS)
|
SHFT_INS = KC.LSHIFT(KC.INS)
|
||||||
@@ -44,9 +42,7 @@ leader_ext = Leader(mode=LeaderMode.ENTER, sequences={
|
|||||||
'dbg': KC.DBG,
|
'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.append(leader_ext)
|
||||||
|
|
||||||
keyboard.extensions = [leader_ext, rgb_ext]
|
|
||||||
|
|
||||||
HACHEEJ = simple_key_sequence((
|
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),
|
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