From 175f0c6a97ae98d0dffd409d0ebc5c8f419b6ff3 Mon Sep 17 00:00:00 2001 From: xs5871 Date: Sun, 10 Apr 2022 12:46:40 +0000 Subject: [PATCH] introduce consistent naming scheme --- boards/pimoroni/keybow/keybow.py | 4 ++-- boards/pimoroni/keybow_2040/keybow_2040.py | 4 ++-- kmk/kmk_keyboard.py | 4 ++-- kmk/scanners/{digitalio_matrix.py => digitalio.py} | 0 kmk/scanners/{native_keypad_scanner.py => keypad.py} | 10 +++++----- tests/keyboard_test.py | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) rename kmk/scanners/{digitalio_matrix.py => digitalio.py} (100%) rename kmk/scanners/{native_keypad_scanner.py => keypad.py} (90%) diff --git a/boards/pimoroni/keybow/keybow.py b/boards/pimoroni/keybow/keybow.py index 202e85b..8fb4360 100644 --- a/boards/pimoroni/keybow/keybow.py +++ b/boards/pimoroni/keybow/keybow.py @@ -39,7 +39,7 @@ import sys from kmk.extensions.rgb import RGB, AnimationModes from kmk.kmk_keyboard import KMKKeyboard -from kmk.scanners.native_keypad_scanner import keys_scanner +from kmk.scanners.keypad import KeysScanner # fmt: off @@ -91,4 +91,4 @@ class Keybow(KMKKeyboard): extensions = [rgb_ext] def __init__(self): - self.matrix = keys_scanner(_KEY_CFG) + self.matrix = KeysScanner(_KEY_CFG) diff --git a/boards/pimoroni/keybow_2040/keybow_2040.py b/boards/pimoroni/keybow_2040/keybow_2040.py index 64aed00..1c31b58 100644 --- a/boards/pimoroni/keybow_2040/keybow_2040.py +++ b/boards/pimoroni/keybow_2040/keybow_2040.py @@ -24,7 +24,7 @@ key switches, then adds [BOOT] in (4,0). [RESET] can't be mapped as a key. import board from kmk.kmk_keyboard import KMKKeyboard -from kmk.scanners.native_keypad_scanner import keys_scanner +from kmk.scanners.keypad import KeysScanner # fmt: off _KEY_CFG = [ @@ -43,4 +43,4 @@ class Keybow2040(KMKKeyboard): ''' def __init__(self): - self.matrix = keys_scanner(_KEY_CFG) + self.matrix = KeysScanner(_KEY_CFG) diff --git a/kmk/kmk_keyboard.py b/kmk/kmk_keyboard.py index 1b7c2ab..386f462 100644 --- a/kmk/kmk_keyboard.py +++ b/kmk/kmk_keyboard.py @@ -4,7 +4,7 @@ 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.scanners.native_keypad_scanner import keypad_matrix +from kmk.scanners.keypad import MatrixScanner class Sandbox: @@ -304,7 +304,7 @@ class KMKKeyboard: if self.matrix is None: if self.debug_enabled: print('Initialising default matrix scanner.') - self.matrix = keypad_matrix( + self.matrix = MatrixScanner( col_pins=self.col_pins, row_pins=self.row_pins, direction=self.diode_orientation, diff --git a/kmk/scanners/digitalio_matrix.py b/kmk/scanners/digitalio.py similarity index 100% rename from kmk/scanners/digitalio_matrix.py rename to kmk/scanners/digitalio.py diff --git a/kmk/scanners/native_keypad_scanner.py b/kmk/scanners/keypad.py similarity index 90% rename from kmk/scanners/native_keypad_scanner.py rename to kmk/scanners/keypad.py index 620baac..e3d6cdb 100644 --- a/kmk/scanners/native_keypad_scanner.py +++ b/kmk/scanners/keypad.py @@ -3,7 +3,7 @@ import keypad from kmk.scanners import DiodeOrientation, Scanner -class NativeKeypadScanner(Scanner): +class KeypadScanner(Scanner): ''' Translation layer around a CircuitPython 7 keypad scanner. @@ -39,7 +39,7 @@ class NativeKeypadScanner(Scanner): return ev -def keypad_matrix(row_pins, col_pins, direction=DiodeOrientation.COLUMNS): +def MatrixScanner(row_pins, col_pins, direction=DiodeOrientation.COLUMNS): ''' Row/Column matrix using the CircuitPython 7 keypad scanner. @@ -53,10 +53,10 @@ def keypad_matrix(row_pins, col_pins, direction=DiodeOrientation.COLUMNS): kp = keypad.KeyMatrix( row_pins, col_pins, columns_to_anodes=(direction == DiodeOrientation.COLUMNS) ) - return NativeKeypadScanner(pin_map, kp) + return KeypadScanner(pin_map, kp) -def keys_scanner(pins): +def KeysScanner(pins): ''' GPIO-per-key 'matrix' using the native CircuitPython 7 keypad scanner. @@ -66,4 +66,4 @@ def keys_scanner(pins): kp = keypad.Keys( [pins[r][c] for (r, c) in pin_map], value_when_pressed=False, pull=True ) - return NativeKeypadScanner(pin_map, kp) + return KeypadScanner(pin_map, kp) diff --git a/tests/keyboard_test.py b/tests/keyboard_test.py index 183940f..aa19395 100644 --- a/tests/keyboard_test.py +++ b/tests/keyboard_test.py @@ -7,7 +7,7 @@ from kmk.hid import HIDModes from kmk.keys import ModifierKey from kmk.kmk_keyboard import KMKKeyboard from kmk.scanners import DiodeOrientation -from kmk.scanners.digitalio_matrix import MatrixScanner +from kmk.scanners.digitalio import MatrixScanner class DigitalInOut(Mock):