move old matrix to kmk.scanners.digitalio_matrix

This commit is contained in:
xs5871 2022-04-09 00:07:38 +00:00 committed by Kyle Brown
parent 142a15e175
commit 7431192e95
7 changed files with 36 additions and 30 deletions

View File

@ -4,7 +4,8 @@ from kmk.consts import KMK_RELEASE, UnicodeMode
from kmk.hid import BLEHID, USBHID, AbstractHID, HIDModes
from kmk.keys import KC
from kmk.kmktime import ticks_add, ticks_diff
from kmk.matrix import MatrixScanner, intify_coordinate
from kmk.scanners import intify_coordinate
from kmk.scanners.digitalio_matrix import MatrixScanner
class Sandbox:

View File

@ -3,12 +3,13 @@ import busio
from micropython import const
from supervisor import runtime, ticks_ms
from keypad import Event as KeyEvent
from storage import getmount
from kmk.hid import HIDModes
from kmk.kmktime import check_deadline
from kmk.matrix import KeyEvent, intify_coordinate
from kmk.modules import Module
from kmk.scanners import intify_coordinate
class SplitSide:

View File

@ -1,3 +1,22 @@
def intify_coordinate(row, col, len_cols):
return len_cols * row + col
class DiodeOrientation:
'''
Orientation of diodes on handwired boards. You can think of:
COLUMNS = vertical
ROWS = horizontal
COL2ROW and ROW2COL are equivalent to their meanings in QMK.
'''
COLUMNS = 0
ROWS = 1
COL2ROW = COLUMNS
ROW2COL = ROWS
class Scanner:
'''
Base class for scanners.

View File

@ -1,31 +1,8 @@
import digitalio
from kmk.scanners import Scanner
from keypad import Event as KeyEvent
def intify_coordinate(row, col, len_cols):
return len_cols * row + col
class DiodeOrientation:
'''
Orientation of diodes on handwired boards. You can think of:
COLUMNS = vertical
ROWS = horizontal
COL2ROW and ROW2COL are equivalent to their meanings in QMK.
'''
COLUMNS = 0
ROWS = 1
COL2ROW = COLUMNS
ROW2COL = ROWS
class KeyEvent:
def __init__(self, key_number, pressed):
self.key_number = key_number
self.pressed = pressed
from kmk.scanners import DiodeOrientation, Scanner
class MatrixScanner(Scanner):

View File

@ -1,7 +1,6 @@
import keypad
from kmk.matrix import DiodeOrientation
from kmk.scanners import Scanner
from kmk.scanners import DiodeOrientation, Scanner
class NativeKeypadScanner(Scanner):

View File

@ -6,7 +6,7 @@ from unittest.mock import Mock, patch
from kmk.hid import HIDModes
from kmk.keys import ModifierKey
from kmk.kmk_keyboard import KMKKeyboard
from kmk.matrix import DiodeOrientation
from kmk.scanners import DiodeOrientation
class DigitalInOut(Mock):

View File

@ -3,6 +3,12 @@ import time
from unittest.mock import Mock
class KeyEvent:
def __init__(self, key_number, pressed):
self.key_number = key_number
self.pressed = pressed
def init_circuit_python_modules_mocks():
sys.modules['usb_hid'] = Mock()
sys.modules['digitalio'] = Mock()
@ -13,6 +19,9 @@ def init_circuit_python_modules_mocks():
sys.modules['board'] = Mock()
sys.modules['storage'] = Mock()
sys.modules['keypad'] = Mock()
sys.modules['keypad'].Event = KeyEvent
sys.modules['micropython'] = Mock()
sys.modules['micropython'].const = lambda x: x