Haskell projects on Raspberry Pi

Posted on February 27, 2017
Tags: haskell, making

Here’s what I’ve been up to lately…

Haskell binding for wiringPi

I’ve taken my Haskell binding to the wiringPi C library, which I originally wrote to hook up a button to my Raspberry Pi, and fleshed it out into a full-fledged package on Hackage.

I also wrote a Haskell program using Rasterific to draw a diagram of the various pin numbering schemes available in wiringPi.

Raspberry Pi pinout

I tested the wiringPi binding using some breadboarded circuits, and also using a Pi-LITEr, which is a nice compact way to have 8 LEDs connected to wiringPi pins 0-7. (Sadly not in order, though.)

Pi-LITEr attached to Raspberry Pi

I also have a Fish Dish on order, which is another simple board that seems good for testing out wiringPi’s functionality.

Haskell library for Adafruit LCD+Keypad Kit for Raspberry Pi

I bought an Adafruit LCD+Keypad Kit for my Pi. Adafruit only supplies a Python library for it, but of course I wanted to program it in Haskell, so I wrote a library to do that. It even seamlessly supports Unicode by using the “custom character” feature of the LCD controller.

Haskell logo displayed on an LCD

Color organ

During Christmas, I had programmable Christmas lights on the banister, which I synced to music using manually programmed light sequences.

After Christmas, we kept the lights on the banister, and kept the Raspberry Pi connected to the stereo, but I took a different approach to syncing the lights to music. Instead of manually programmed sequences, I built a color organ. (Or, Wikipedia claims the term light organ is now in vogue, but I’ll call it a color organ.)

I used the fft package, which is a binding to the FFTW library, to perform a Fourier transform on the music, and then I send data to the LEDs (using the FadeCandy, as before) based on the frequencies contained in the music.

I used the above-mentioned LCD to add a rudimentary user interface for choosing music to play.

Here is what it looks like. (The videos are silent because the music is copyrighted, so you’ll have to use your imagination a bit.)

I haven’t released the code for the color organ (or the Christmas lights) yet, because the code is pretty ugly (at least as Haskell code goes) and is still under active development.

Taking over as maintainer for the powermate package

Another adventure I went on was connecting a Griffin Powermate USB to my Raspberry Pi. There was a powermate package on Hackage, but it hadn’t been updated in a decade or so and didn’t build. With the author’s blessing, I took over as maintainer of the powermate package, and got it working again. (Although it works great on a Raspberry Pi, this package isn’t Pi-specific, and should work on any Linux computer.)

Open Pixel Control server for ESP8266

And one more project, which is not in Haskell and not on the Raspberry Pi. I wrote an Open Pixel Control server for the ESP8266, using the Arduino tools. Now I can control NeoPixels (such as the Alitove string) remotely. The goal is to have the color organ on the Pi be able to talk to lights on the other side of the room.

ESP8266 Feather hooked up to Neopixel stick