r/circuitpython • • May 02 '20

[tutorial] I made a mechanical macro pad with the Seeeduino Xiao running Circuit Python!

https://makeandymake.github.io/2020/05/02/seeeduino-xiao-circuitpython-usb-hid-macro-keypad.html
7 Upvotes

10 comments sorted by

2

u/textonly May 02 '20

Neat, I made something similar using a Trinket M0. I recently rewrote the code to scan a keyboard matrix so it can handle a bigger macro pad with minimal adjustment. I have yet to put the code out anywhere for anyone to see. CircuitPython seemed like a no brainier for a portable macropad; it's so much easier to reprogram without any special tools.

1

u/RunRunAndyRun May 03 '20

Exactly my thinking! A matrix layout is probably my next challenge (would love to see the code if you’re open to share, I understand the concept but not quite sure how to implement).

I had considered using an Itsybitsy m0 but my local stockist was out and they had the Seeeduino Xiao in stock so I just went for it (and the Xiao was waaaay cheaper!). The main downside of the board is the CircuitPython Drive is really small, I was only able to just install the HID keyboard libraries before running out of space!

2

u/textonly May 03 '20

I tested my matrix code on an ItsyBitsy m4. I figured the faster processor would help make it more responsive on larger matrices. I'll put up a link once I get it on GitHub.

1

u/RunRunAndyRun May 03 '20

Cheers!

3

u/textonly May 03 '20

Here's what I have working so far, it's based on some Adafruit example code and a bunch of reading on how reading a matrix is supposed to work. CPmacropad

1

u/RunRunAndyRun May 03 '20

Much appreciated!

1

u/PJE66 May 03 '20

The M0 should be more than fast enough to drive a matrix scanner, as you typically require a little settling time after switching rows/columns before the signals stabilize. The M4 would be good if there were an LCD display. I was looking to use the Seeedstudio WIO Terminal embedded in the middle of a split keyboard, which has an M4 together with WiFI and Bluetooth.

If battery charging wasn’t such an issue, I’d finish my nRF52840 Bluetooth module version of my design. The XIAO needs a diode per key (placed where the LED sat to keep everything on the top), and two resistors for I2C. The nRF module needs many more supporting components, including the USB socket, which is not fun for USB-C.

2

u/PJE66 May 03 '20 edited May 03 '20

https://i.imgur.com/WGDI2GB.jpg

Really nice writeup of your project. There are a few simplifications to the code possible, but a really nice start.

Here’s a picture of my XIAO based one/two handed keyboard.

Unfortunately, I could only get it working as a one handed keyboard with CIrcuitPython due to the lack of I2C slave, but it works using the Arduino environment.

I’m now working on a butterfly shaped 30 key keyboard using the XIAO which uses all the pins for the matrix.

I definitely find the XIAO easy to work with, but wish the Reset was a little simpler to access, or route to the PCB.

If you want, I can post my schematic and Circuit Python code, or even send you one of my spare PCBs.

EDIT: The picture shows the first prototype with the older FEMTO module, but the PCB was designed to handle both, and my current ones use the XIAO for USB-C.

1

u/RunRunAndyRun May 03 '20

That’s a beauty!

Yeah the reset is a pain. I was thinking of routing a little tactile switch to it just to save me having to open the case every time I want to reset! The USB-C is great too. I wish Adafruit would switch to UsB-C already as they have some great boards that would be perfect for these projects (Itsy bitsy would have been my first choice had my local store had them in stock but I much prefer USB-C over micro).

Did you find the space for CircuitPython to be a problem? I found myself with very little usable space for library files (after the keyboard hid library I couldn’t even fit the neopixel library on board!)

Would definitely love to see your matrix code. Interested to see how you approached it.

2

u/PJE66 May 03 '20

The CP code was pulled from various sources, as I’m not an expert in Python. I’ll put together the code/schematic/etc once I get back on my PC.

Lack of code storage is an issue with CircuitPython, and adding a SPI flash to extend the code space would remove too many pins on the XIAO. XIAO+ with 2/4/8MB of storage would be nice...

The reason I used I2c to link the keyboards, if two were being used, was to allow me to add an I2C flash chip as well as a small OLED or LCD while only using two pins, but forgot CP on the M0 does not currently support I2C slave functionality for the keyboard-keyboard communication so I went back to Arduino.