From d379acfc97de6211c0b281ccff80e2d6f6a89fb2 Mon Sep 17 00:00:00 2001 From: Josh Klar Date: Sun, 7 Oct 2018 00:22:54 -0700 Subject: [PATCH] Support ItsyBitsy M4 Express as an effective clone of the Feather M4 Express with less pins. Because that's what it is. --- Makefile | 28 ++++++++ README.md | 2 +- .../handwire/itsybitsy_m4_express.py | 33 ++++++++++ .../itsybitsy_m4_express/threethree.py | 65 +++++++++++++++++++ 4 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 kmk/entrypoints/handwire/itsybitsy_m4_express.py create mode 100644 user_keymaps/klardotsh/itsybitsy_m4_express/threethree.py diff --git a/Makefile b/Makefile index 1408727..5b2134c 100644 --- a/Makefile +++ b/Makefile @@ -137,6 +137,10 @@ circuitpy-build-feather-m4-express: @echo "===> Building CircuitPython" @make -C build/circuitpython/ports/atmel-samd BOARD=feather_m4_express FROZEN_MPY_DIRS="modules" clean all +circuitpy-build-itsybitsy-m4-express: + @echo "===> Building CircuitPython" + @make -C build/circuitpython/ports/atmel-samd BOARD=itsybitsy_m4_express FROZEN_MPY_DIRS="modules" clean all + circuitpy-build-nrf: @echo "===> Building CircuitPython" @make -C build/circuitpython/ports/nrf BOARD=feather_nrf52832 SERIAL=${AMPY_PORT} SD=s132 FROZEN_MPY_DIR=freeze clean all @@ -148,6 +152,13 @@ circuitpy-flash-feather-m4-express: @echo "Copy build/circuitpython/ports/atmel-samd/build-feather_m4_express/firmware.uf2 to this device" @echo "The device will auto-reboot. You may need to forcibly unmount the drive on Linuxes, with umount -f path/to/mountpoint" +circuitpy-flash-itsybitsy-m4-express: + @echo "Flashing not available for ItsyBitsy M4 Express over bossa right now" + @echo "First, double tap the reset button on the ItsyBitsy. You should see a red light near the USB port" + @echo "Then, find and (if necessary) mount the USB drive that will show up (should be about 4MB)" + @echo "Copy build/circuitpython/ports/atmel-samd/build-itsybitsy_m4_express/firmware.uf2 to this device" + @echo "The device will auto-reboot. You may need to forcibly unmount the drive on Linuxes, with umount -f path/to/mountpoint" + circuitpy-flash-nrf: circuitpy-build-nrf @echo "===> Flashing CircuitPython with KMK and your keymap" @make -C build/circuitpython/ports/nrf BOARD=feather_nrf52832 SERIAL=${AMPY_PORT} SD=s132 FROZEN_MPY_DIR=freeze dfu-gen dfu-flash @@ -206,6 +217,23 @@ flash-feather-nrf52832: lint devdeps circuitpy-deps circuitpy-freeze-kmk-nrf @$(MAKE) circuitpy-flash-nrf circuitpy-flash-nrf-entrypoint endif +ifndef USER_KEYMAP +build-itsybitsy-m4-express: + @echo "===> Must provide a USER_KEYMAP (usually from user_keymaps/...) to build!" && exit 1 + +flash-itsybitsy-m4-express: + @echo "===> Must provide a USER_KEYMAP (usually from user_keymaps/...) to build!" && exit 1 +else +build-itsybitsy-m4-express: lint devdeps circuitpy-deps circuitpy-freeze-kmk-atmel-samd + @echo "===> Preparing keyboard script for bundling into CircuitPython" + @cp -av ${USER_KEYMAP} build/circuitpython/ports/atmel-samd/modules/kmk_keyboard_user.py + @$(MAKE) circuitpy-build-itsybitsy-m4-express + +flash-itsybitsy-m4-express: lint devdeps circuitpy-deps circuitpy-freeze-kmk-atmel-samd + @echo "===> Preparing keyboard script for bundling into CircuitPython" + @$(MAKE) build-itsybitsy-m4-express circuitpy-flash-itsybitsy-m4-express +endif + ifndef USER_KEYMAP build-teensy-3.1: @echo "===> Must provide a USER_KEYMAP (usually from user_keymaps/...) to build!" && exit 1 diff --git a/README.md b/README.md index 9701aec..383fd42 100644 --- a/README.md +++ b/README.md @@ -43,11 +43,11 @@ ecosystem: | ----- | ------- | --------------- | ----- | | [pyboard v1.1](https://www.adafruit.com/product/2390) | STM32F405RG (Cortex M4F) | MicroPython | Our reference board for basic USB keyboards | | [Adafruit Feather M4 Express](https://www.adafruit.com/product/3857) | Atmel SAMD52 (Cortex M4F) | CircuitPython | A more economical solution for basic USB keyboards | +| [Adafruit ItsyBitsy M4 Express](https://www.adafruit.com/product/3800) | Atmel SAMD52 (Cortex M4F) | CircuitPython | An EVEN MORE economical solution for basic USB keyboards | ### Support Planned/WIP | Board | Chipset | Python Platform | Notes | | ----- | ------- | --------------- | ----- | -| [Adafruit ItsyBitsy M4 Express](https://www.adafruit.com/product/3800) | Atmel SAMD52 (Cortex M4F) | CircuitPython | An EVEN MORE economical solution for basic USB keyboards | | [Seeed nRF52840 Micro Dev Kit](https://www.seeedstudio.com/nRF52840-Micro-Development-Kit-p-3079.html) | nRF52840 | [CircuitPython](https://github.com/KMKfw/circuitpython/tree/topic-nrf52840-mdk) | This is basically as bleeding edge as it gets. Will support BLE HID to PC as well as BLE split boards | | [Planck rev6 Keyboard](https://olkb.com/planck) | STM32 of some sort | MicroPython | Requires porting MicroPython to STM32F3, this work has begun but I'm pretty terrible at it. | | [Proton C Controller?](https://www.reddit.com/r/MechanicalKeyboards/comments/87cw36/render_of_the_qmk_proton_c_qmkpowered_pro_micro/) | ??? | ??? | Does not exist yet, the controller from a Planck rev6 in a Pro Micro pin-compat controller chip | diff --git a/kmk/entrypoints/handwire/itsybitsy_m4_express.py b/kmk/entrypoints/handwire/itsybitsy_m4_express.py new file mode 100644 index 0000000..b695541 --- /dev/null +++ b/kmk/entrypoints/handwire/itsybitsy_m4_express.py @@ -0,0 +1,33 @@ +import sys +from logging import WARNING + +from kmk.circuitpython.hid import HIDHelper +from kmk.circuitpython.matrix import MatrixScanner +from kmk.common.consts import UnicodeModes +from kmk.firmware import Firmware + + +def main(): + from kmk_keyboard_user import cols, diode_orientation, keymap, rows + + try: + from kmk_keyboard_user import unicode_mode + except Exception: + unicode_mode = UnicodeModes.NOOP + + try: + firmware = Firmware( + keymap=keymap, + row_pins=rows, + col_pins=cols, + diode_orientation=diode_orientation, + unicode_mode=unicode_mode, + log_level=WARNING, + matrix_scanner=MatrixScanner, + hid=HIDHelper, + ) + + firmware.go() + except Exception as e: + sys.print_exception(e) + sys.exit(1) diff --git a/user_keymaps/klardotsh/itsybitsy_m4_express/threethree.py b/user_keymaps/klardotsh/itsybitsy_m4_express/threethree.py new file mode 100644 index 0000000..711c5b1 --- /dev/null +++ b/user_keymaps/klardotsh/itsybitsy_m4_express/threethree.py @@ -0,0 +1,65 @@ +import board + +from kmk.common.consts import DiodeOrientation, UnicodeModes +from kmk.common.keycodes import KC +from kmk.common.macros.simple import send_string, simple_key_sequence +from kmk.common.macros.unicode import unicode_sequence +from kmk.entrypoints.handwire.itsybitsy_m4_express import main +from kmk.firmware import Firmware + +cols = (board.A4, board.A5, board.D13) +rows = (board.D12, board.D11, board.D10) + +diode_orientation = DiodeOrientation.COLUMNS +unicode_mode = UnicodeModes.LINUX + +MACRO_TEST_SIMPLE = simple_key_sequence([ + KC.LSHIFT(KC.H), + KC.E, + KC.L, + KC.L, + KC.O, + + KC.SPACE, + + KC.MACRO_SLEEP_MS(500), + + KC.LSHIFT(KC.K), + KC.LSHIFT(KC.M), + KC.LSHIFT(KC.K), + KC.EXCLAIM, +]) + +MACRO_TEST_STRING = send_string("Hello! from, uhhhh, send_string | and some other WEIRD STUFF` \\ like this' \"\t[]") + +ANGRY_TABLE_FLIP = unicode_sequence([ + "28", + "30ce", + "ca0", + "75ca", + "ca0", + "29", + "30ce", + "5f61", + "253b", + "2501", + "253b", +]) + +keymap = [ + [ + [KC.GESC, KC.A, KC.RESET], + [KC.MO(1), KC.B, KC.MUTE], + [KC.LT(2, KC.EXCLAIM), KC.HASH, KC.ENTER], + ], + [ + [KC.MUTE, KC.B, KC.C], + [KC.TRNS, KC.D, KC.E], + [KC.F, KC.G, KC.H], + ], + [ + [KC.VOLU, KC.MUTE, ANGRY_TABLE_FLIP], + [KC.NO, KC.PIPE, MACRO_TEST_SIMPLE], + [KC.TRNS, KC.P, MACRO_TEST_STRING], + ], +]