SqueezePi: The Joy of lite Jive, and custom controls

Community Power

There’s a great community that has grown up around Slim Device’s Squeezebox products. I think that stems from the company’s very open approach, with a wiki and forums that are still very active today – despite the company’s assimilation into Logitech, and the discontinuation of its devices.

It was through these resources that I discovered JiveLite, Squeezebox controller software created by members of this community. This is a very fully featured app, written in a mixture of C and Lua with full source available, that runs on Linux. With a little digging and interpretation of the available instructions, I built and ran it on my Pi connected to a conventional LCD monitor via HDMI.

The next challenge was to get it working with the little 2.8″ LCD. Fortunately others had been there before me, so that didn’t take long – and with a little extension to the settings, I also got JiveLite to respond to the touch screen. This was proving a bit too easy…

Other People’s Software

Yes, it was a little too easy. It turned out that JiveLite had a few issues – some minor ones arising from using a very small display, some in the build configuration files and a crash when navigating music collections (e.g. when selecting by artist). I’m jumping ahead a bit here… I’ve now fixed these issues in a clone of the original codebase, and made it public. Hopefully I can persuade the originators to consider taking some of these back into the main repository.

I also added some extras – the necessary user interface data files for the small size LCD, the ability to turn off the mouse pointer for touch screen use, and the ability to control GPIO pins from the Lua script. The latter I used to modify one of the screen-savers, so it would turn off the LCD backlight when active to save some power.

Prototyping Custom Controls

Inspired by these strong steps forward, I decided to try driving JiveLite via controls attached to the Pi via GPIO pins. You can see what my efforts look like in the picture below. I used an Adafruit Pi Cobbler kit to connect my Pi to the breadboard, to make it easier to wire up the GPIOs to the control components.

IMG_20140614_162041 (1)

Yet more research turned up another really useful bit of Pi software made for this purpose – pikeyd. This package runs in the background, polling GPIO pins connected to switches and generating keystrokes when the switches are closed. So it was a relatively easy task to find out the keys that control JiveLite and configure pikeyd to generate those from GPIO inputs. Et voila, those little switches under the LCD were usable for navigating the menus, playing tracks and changing the volume.

Next I wanted to get a rotary encoder control to work. My Squeezebox Radio has one of these, which is used primarily to scroll up and down through menus and make choices by pressing on it. Rotary control components are relatively cheap and easy to obtain – both RS and Farnell carry a bewildering range. I got a couple of cheap ones from here. They’re okay quality for this project; however you could wind up spending a lot if you want really top quality rotary controls!

These SparkFun encoders act as a pair of switches that make and break contact with ground out of phase with each other as you turn the control shaft. By wiring the two “output” pins of the encoder via pull-up resistors to GPIO pins on the Pi, those pins will alternate between low and hi in the a pattern known as a Gray code, and the direction of rotation can be determined by tracking how the pin values change over time. So you can turn rotation of the controller into steps in the two different directions, and map those steps into changing something in your software (e.g. the current selection in a menu). This tutorial for Arduino provides more detail.

Unfortunately, piked doesn’t support rotary encoders, just simple switches on GPIO. But it wasn’t hard to add this support… you can find my modified fork of the software here for public consumption. So now pikeyd had gained the ability to map rotary encoder steps into key presses (two on each encoder, one per rotation direction), then I added a configuration option to set up the internal pull-up resistors on the Pi GPIO pins, saving extra components and wiring.

With my modified pikeyd configured to generate the corresponding keys from a rotary control, I could now navigate the JiveLite interface through it. There was also a built-in push switch on the controller, which I wired up to another GPIO pin to act as a “select” key stroke when pushed.

You can see all of it working together on this video.

The Control Board

With all of this prototyping under my belt, I went on to build a first working version of the controls for the SqueezePi – two rotary encoders (one for navigation, one for volume) and four switches for “home”, “back”, “on/off” and “play”. I constructed this on a thin strip of Veroboard with tracks like a breadboard, and attached a couple of single track strips top and bottom running at ninety degrees as ground tracks. I also used another (cheap) Pi cobbler from Maplin soldered onto the breadboard as a quick way of attaching the Pi GPIOs via ribbon cable.

IMG_20140629_133259IMG_20140629_133317

Extending my custom pikeyd configuration to read these controls was a walk in the park.

Next, I’ll go onto describe what I did for audio output and the process of creating the case.

Advertisements