From 0d062cfad12cb9ebe1ff95acee0a55c7a49481d5 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Sun, 30 Jul 2023 09:45:20 -0400 Subject: [PATCH] convert 'setup_physical_config' to abstract method, add 'hardware' sub-module and move 'setup_physical_config' definition to dedicated hardware implementations --- ardux/hardware/__init__.py | 0 ardux/hardware/thepaintbrush.py | 10 ++++++++++ ardux/kb.py | 15 +++++---------- main.py | 4 ++-- 4 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 ardux/hardware/__init__.py create mode 100644 ardux/hardware/thepaintbrush.py diff --git a/ardux/hardware/__init__.py b/ardux/hardware/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ardux/hardware/thepaintbrush.py b/ardux/hardware/thepaintbrush.py new file mode 100644 index 0000000..403668b --- /dev/null +++ b/ardux/hardware/thepaintbrush.py @@ -0,0 +1,10 @@ +from ardux.kb import _ArduxKeyboard +from kmk.scanners.keypad import KeysScanner +from kmk.quickpin.pro_micro.kb2040 import pinout as pins + +# ThePaintbrush Implementation +class ThePaintbrushArduxKeyboard(_ArduxKeyboard): + def setup_physical_config(self): + # Direct wire & matrix setup + self.matrix = KeysScanner([pins[16], pins[17], pins[18], pins[19], pins[12], pins[13], pins[14], pins[15]]) + diff --git a/ardux/kb.py b/ardux/kb.py index 62bf32b..30d358a 100644 --- a/ardux/kb.py +++ b/ardux/kb.py @@ -2,13 +2,9 @@ import os import board -from kmk.quickpin.pro_micro.kb2040 import pinout as pins - from kmk.kmk_keyboard import KMKKeyboard -from kmk.scanners.keypad import KeysScanner - from kmk.keys import KC -from ardux.chord import ArduxChord +from ardux.chord import ArduxChord # FIXME: Need to fix ArduxChord / sort layer filters for combos from kmk.modules.layers import Layers from kmk.modules.combos import Combos, Chord @@ -26,7 +22,7 @@ LAYER_ID_SYMBOLS = 4 LAYER_ID_CUSTOM = 5 LAYER_ID_MOUSE = 6 -class ArduxKeyboard(KMKKeyboard): +class _ArduxKeyboard(KMKKeyboard): coord_mapping = [ 0, 1, 2, 3, 4, 5, 6, 7, @@ -34,9 +30,10 @@ class ArduxKeyboard(KMKKeyboard): keymap = [] + # Switch to ABC python3 stl abstract class methods + # See https://stackoverflow.com/a/4382964 for detail (the accepted answer) def setup_physical_config(self): - # Direct wire & matrix setup - self.matrix = KeysScanner([pins[16], pins[17], pins[18], pins[19], pins[12], pins[13], pins[14], pins[15]]) + raise NotImplementedError('Please define the physical config for your keyboard') # Init / constructor / setup def __init__(self): @@ -190,5 +187,3 @@ class ArduxKeyboard(KMKKeyboard): ##### # std - mouse self.combo_module.combos.append(Chord((KC.MB_RMB, KC.MS_DN, KC.MB_LMB), KC.TO(LAYER_ID_BASE))) - - diff --git a/main.py b/main.py index d857376..6d7ae09 100644 --- a/main.py +++ b/main.py @@ -3,8 +3,8 @@ import os ##### # Main keyboard object -from ardux.kb import ArduxKeyboard -ardux_keyboard = ArduxKeyboard() +from ardux.hardware.thepaintbrush import ThePaintbrushArduxKeyboard +ardux_keyboard = ThePaintbrushArduxKeyboard() ##### # NeoPixel on kb2040 (tune accordingly / remove if different mcu)