In a pair programming session, this Spoon switches between each engineer's settings on the press of a button. It runs Hammerspoon code on pressing one of the physical buttons and applies the current driver's preferences to the workstation shared between the two engineers, e.g. switching the keyboard layout between German and US.
The two buttons are connected to a Teensy (or Arduino) which sends a MIDI SysEx message via USB when a button was pressed.
This pairing station consists of
-
two (mirrored) screens,
-
two keyboards (one built-in to the laptop, one via external USB), and
-
two pointing devices (trackpad of the laptop, and an external USB mouse).
In this setting, the pairing buttons should be placed between the two engineers, so that both can easily reach their designated button.
Both engineers have equal opportunity to be driver or navigator. All it takes to signal that one wants to drive is to press a button:
The act of reaching for and pressing the button, the sound it makes (it's a mechanical button, after all), and the LED of the button lighting up is a clear sign that this person has taken over the driver's responsibility. Hence, the other engineer becomes the navigator.
Swapping again is equally simple - the current navigator presses the button, has her preferences applied, and assumes the driver role.
- Download the latest ZIP
- Unzip it to
~/.hammerspoon/Spoons/PairingButtons.spoon
- Load it in
~/.hammerspoon/init.lua
withhs.loadSpoon("PairingButtons")
- On the Teensy, connect a button between pins 7 and ground and another between pin 8 and ground.
- Open the
PairingButtons.ino
file with the Teensyduino IDE and upload it to the Teensy (or Arduino). Make sure you have the USB mode set to MIDI. - While still connected by USB, the Teensy now behaves like a MIDI device and will send a SysEx message for each button pressed, which triggers the Spoon.
$ luarocks install busted
$ busted .
Run all tests whenever a Lua file has changed:
$ fswatch -r *.lua | xargs -I {} busted .
- As confirmation, switch the LEDs from Hammerspoon (instead of just within the Teensy program)