LEDs and WiFi
Well, it's been a while. Life got in the way. The good news is, I've actually been doing stuff other than image processing.
The distance between my TV and the Pi that would be looking at its screen is not insignificant. I think running a cable round the edge of the room to get from one to the other would just cause all sorts of issues. So, wireless would be nice.
How do you wirelessly connect a strand of wired LEDs? I figured I could use another Pi (Camera Pi could shout at LED Pi over WiFi and LED Pi could then light things up) but a whole Pi is a bit overkill for something so trivial. I then remembered that the ESP8266 is a thing that exists, and pretty much perfect for this. No real processing grunt to speak of, but has an amount of I/O, is programmable, and is dead cheap from China.
I bought two off ebay (in case I blew one up somehow) and a USB/TTL adapter so I could talk to it.
Whilst the ESP8266 was riding the slow boat from halfway round the world, I started looking into controllable LEDs. It seems there's two main types of chip used to drive these things: WS2812, and WS2801. The difference between the two is how you talk to them. The former uses a one-wire protocol, and the latter an SPI-like interface. I decided on the WS2801 because a) precise timing requirements are just crap I don't want to deal with and b) the ESP8266 has hardware SPI.
So, I bought a bunch of these (also from ebay). I got two chains of 20 (they daisy chain nicely) making 40 controllable LED elements.
There were several options that had just a single LED, but I figure with these things they'll be plenty bright. I can always turn brightness down, it's a bit more difficult to make a single LED brighter - at least whilst keeping the magic smoke inside.
Back to the ESP8266. It's still on the boat, the LEDs are in the post, so I start reading up on how to properly use the thing as I have nothing better to do. It's programmed in C, and there's an SDK floating around.
Then I came across nodemcu, a firmware that basically wraps the SDK in a lua interpreter. Using a scripting language on something as low-power as the ESP8266 seems like it could be a strange idea, but also significantly reduces the amount of effort I need to put in to get code running on it.
Time passes, the LEDs arrive, the ESP8266s arrive.
The ESP8266s i bought are completely bare - tiny little things. It needs some pull up/pull down resistors soldering on, and a button or two to reset it or put it into a mode where it can be programmed. I make a horrible mess soldering all that nonsense on, and then make even more mess because there's various descriptions on the internet of what needs to be connected to what and not all of them are entirely accurate.
Good thing I've got a spare - I'll just accept that I'm making a dogs breakfast of this one and do the next one properly on some stripboard or something.
I finally get it powering up reliably (one pin was floating, which meant it'd sometimes power up and sometimes not - most irritating!) so get the nodemcu firmware flashed on to it. The serial console now gives me a lua prompt and I can interact with the device through code entered directly into the console. Fantastic!
Driving the LEDs via the SPI however, that didn't work. The first few would light up, but not in the colours I instructed them to and at seemingly random intensities. None past the first 8 would light up at all.
At this point, stupid o'clock in the morning and feeling frustrated, I realised I hadn't yet bought the camera module for my Pi - even if these damn things were working I'd not be able to do anything useful with them. So I put in an order for a Pi camera, and went to bed.