Motivation

A friend of mine asked me around the time of the Palette kickstarter if I could build something similar for him since it was relatively expensive. The Palette is a USB device with several different kinds of inputs (buttons, sliders, knobs) that can be configured as various keyboard shortcuts and the like. So over last couple of months I've been thinking about possible implementations and only recently got around to prototyping them. And now that Hackaday is hosting this contest I simply had to document it, such that others might profit from the solutions to problems I had during development.

Research and preparation

For this first prototype we decided that the device should have 8 buttons and 4 rotary encoders which have 4 additional buttons arranged in a 4 wide and 3 tall array with the encoders on top.

Rough sketch of the devices layout.

Since my microcontrollers of choice are AVRs and I also wanted to get into USB capable AVRs and VUSB, the decision to use a Pro Trinket as platform for this project was a quick one. Also the fact that it can be reprogrammed (i.e. with different keyboard shortcuts) without additional hardware (dedicated ISP or USB-to-serial converter) is a great advantage.

Presently I don't have a proper Pro Trinket (mainly because I hesitated too long when the anniversary Hackaday Pro Trinket was still available) therefore I'm using a breadboarded one (whew, thanks contest rules ;) ) which would become an advantage as we will see in a later project log.

(edit Dec. 9th: The advantage was in regard to USB re-enumeration, but turned out to be irrelevant. See project log USB troubles for details)

Pro Trinket on a breadboard

In order to get into it I started looking into VUSB and USB bootloaders, most notably micronucleus. However, because of ease of use I ended up loading a ATtiny85 up with the Trinket bootloader and breadboarding the required circuitry. One reason for choosing the Trinket bootloader was that there is a great USB example. Once the Arduino IDE was set up for the Trinket, implementing the example was pretty straight forward. Unfortunately the Trinket USB libraries aren't compatible with the Pro Trinket so that was a dead end.

Speaking of great tutorials... of course Adafruit has a USB HID example for the Pro Trinket as well. Unfortunately, implementation of this project wasn't quite as straight forward (at least in my experience) as the other one so even more googling was required to get it to work. I'll describe problem and my solution to it in the next project log where I talk about the concrete implementation.

Another part of the project is managing the 12 buttons, which is most easily done as a matrix keypad for which there is a great Arduino library that is very easy to use. However, this library conflicted with the USB library and I ended up manually implementing a similar mechanism. As for the rotary encoders. There are quite a few libraries for Arduino out there, but in fear of further conflicts I copied the implementation of a previous project of mine.

This covers the most important points of this project that have to work together. As already mentioned, in the next logs I will talk about the concrete implementations of the hardware and software and about some things that are up to the builder, like the case and additional features.