Chess Clock 2.0 using an Adafruit MacroPad

by MACE

I built a better chess clock. It’s no surprise that my first attempt (see http://blog.workshop88.com/2021/07/30/making-a-chess-clock-with-a-circuit-playground-express-user-interface-decisions/), while functional, was difficult to use. The buttons are tiny, you need a lot of prior knowledge to use it, etc. My wife refused to use it.

Just in the nick of time, I received the Adabox 019. It contained a keyboard circuit, keys, keycaps, OLED display, rotary encoder, encoder knob and housing — some assembly required. Adafruit promotes this product as a way to send commands through a USB port to the foreground program running on a computer. There is also a MIDI use case.

The included demo code interprets key presses based on a menu of items that are specific to a given program. You can have multiple menus for multiple programs. You switch between menus using the rotary encoder. Each menu can set the neopixels under the keys to visually group keys by functionality. Here’s an example menu I did for Inkscape.

Inkscape-MacroPad-Menu

Key 1 (upper left) resizes the document to match the selection
Key 2 is for Trace Bitmap
Keys 4-8 are for manipulating layers

It worked, but this use case for the MacroPad wasn’t satisfying. For me, a keystroke on the pad isn’t any better than just using the shortcut keys on the full keyboard. I soon started to hunt for a bigger itch that needed a bigger scratch.

The first one I came up with was to use the example menu framework to simplify my use of various Linux terminal commands. The ls command, for example, has dozens of options. The combination of dashes, case sensitivity, non-mnemonic codes, etc. makes the command tedious to type — especially if you need to use many different options in various combinations. Not to mention that the meanings of the options are different depending of the flavor of Linux!

Here’s the menu I wrote for the terminal on MacOS. I took better care on this menu to color code the keys. The yellow keys are for formatting options, the green key is for recursion, Key4 isn’t enabled, the red keys are for sort order and the purple keys are groups of file extensions. Pushing the rotary key enters the “ls ” command itself.

With an open terminal window, the MacroPad connected and my custom menu selected, I can use the keys to easily form the command that lists “code” files with units, long dates, sorted by size, in reverse order:

<Rotary><Key1><Key2><Key5><Key7><Key12> #These are the key presses

ls -h -T -r -S *.py *.sh *.sed #This is what gets typed at the prompt
-rw-r--r-- 1 appleadmin staff 75B Jul 9 09:40:36 2021 mymoduletest.py
-rw-r--r-- 1 appleadmin staff 72B Oct 19 09:59:35 2020 timezones.py
-rw-r--r-- 1 appleadmin staff 59B Mar 30 16:17:28 2021 getSkyCharts.py
-rw-r--r-- 1 appleadmin staff 58B Apr 2 16:39:43 2021 mymod.py
-rwxr-xr-x 1 appleadmin staff 46B Mar 31 06:38:26 2020 rhi.sh*
-rw-r--r-- 1 appleadmin staff 24B Aug 2 21:47:36 2021 goPad.sh

It works well.

Finally, having just finished my 2-Player+ Chess Clock, I made version V2.0 using the MacroPad. This time, I have a display screen to properly prompt for input and display time remaining, a rotary encoder with an “ENTER” feature for numeric value input and a physical, color-coded button for each player to push.

Here’s the result in action.