From 88807837d563c774ba9a666a0c833f1e7a1ddfc2 Mon Sep 17 00:00:00 2001 From: Josh Klar Date: Sun, 16 Sep 2018 20:50:05 -0700 Subject: [PATCH] Misc. cleanup around the tree --- Makefile | 6 ++---- boards/klardotsh/threethree_matrix_pyboard.py | 8 ++++++-- kmk/micropython/matrix.py | 6 +++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index eba91c9..d2aac9c 100644 --- a/Makefile +++ b/Makefile @@ -50,14 +50,14 @@ vendor/circuitpython/ports/nrf/freeze/.kmk_frozen: upy-freeze.txt vendor/micropython/ports/teensy/freeze/.kmk_frozen: upy-freeze.txt @echo "===> Preparing vendored dependencies for bundling" - @mkdir vendor/micropython/ports/teensy/freeze/ + @mkdir -p vendor/micropython/ports/teensy/freeze/ @rm -rf vendor/micropython/ports/teensy/freeze/* @cat $< | xargs -I '{}' cp -a {} vendor/micropython/ports/teensy/freeze/ @touch $@ vendor/micropython/ports/stm32/freeze/.kmk_frozen: upy-freeze.txt @echo "===> Preparing vendored dependencies for bundling" - @mkdir vendor/micropython/ports/stm32/freeze/ + @mkdir -p vendor/micropython/ports/stm32/freeze/ @rm -rf vendor/micropython/ports/stm32/freeze/* @cat $< | xargs -I '{}' cp -a {} vendor/micropython/ports/stm32/freeze/ @touch $@ @@ -86,7 +86,6 @@ micropython-flash-teensy3.1: @make -C vendor/micropython/ports/teensy/ BOARD=TEENSY_3.1 deploy micropython-flash-pyboard: - @make -j4 -C vendor/micropython/ports/stm32/ BOARD=PYBV11 clean @make -j4 -C vendor/micropython/ports/stm32/ BOARD=PYBV11 FROZEN_MPY_DIR=freeze deploy micropython-flash-pyboard-entrypoint: @@ -96,7 +95,6 @@ micropython-flash-pyboard-entrypoint: @-timeout -k 5s 10s pipenv run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} rm /flash/boot.py 2>/dev/null @-timeout -k 5s 10s pipenv run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} put entrypoints/pyboard.py /flash/main.py @-timeout -k 5s 10s pipenv run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} put entrypoints/pyboard_boot.py /flash/boot.py - @-timeout -k 5s 10s pipenv run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} reset @echo "===> Flashed keyboard successfully!" circuitpy-flash-nrf-entrypoint: diff --git a/boards/klardotsh/threethree_matrix_pyboard.py b/boards/klardotsh/threethree_matrix_pyboard.py index d0b767b..8eea9aa 100644 --- a/boards/klardotsh/threethree_matrix_pyboard.py +++ b/boards/klardotsh/threethree_matrix_pyboard.py @@ -1,12 +1,16 @@ from logging import DEBUG +import machine + from kmk.common.consts import DiodeOrientation from kmk.firmware import Firmware def main(): - cols = ('X10', 'X11', 'X12') - rows = ('X1', 'X2', 'X3') + p = machine.Pin.board + + cols = (p.X10, p.X11, p.X12) + rows = (p.X1, p.X2, p.X3) diode_orientation = DiodeOrientation.COLUMNS diff --git a/kmk/micropython/matrix.py b/kmk/micropython/matrix.py index e7c329b..f775719 100644 --- a/kmk/micropython/matrix.py +++ b/kmk/micropython/matrix.py @@ -8,7 +8,11 @@ class MatrixScanner(AbstractMatrixScanner): def __init__(self, cols, rows, diode_orientation=DiodeOrientation.COLUMNS): # A pin cannot be both a row and column, detect this by combining the # two tuples into a set and validating that the length did not drop - unique_pins = set(cols) | set(rows) + # + # repr() hackery is because MicroPython Pin objects are not hashable. + # Technically we support passing either a string (hashable) or the + # Pin object directly here, so the hackaround is necessary. + unique_pins = {repr(c) for c in cols} | {repr(r) for r in rows} if len(unique_pins) != len(cols) + len(rows): raise ValueError('Cannot use a pin as both a column and row')