I'm just getting started trying to figure out how the whole SPI thing works.
I'm using an APA102 led as I figured turning on and off LEDs and setting colours would be a good start.
I bought the kind you have to solder yourself, not a strip, and have soldered the pins on to little breakout boards. I'm using an external 5v source to power the led and have a 5v regulator on it.
According to the datasheet (https://cpldcpu.wordpress.com/2014/08/27/apa102/), I have to send an 'led frame' of 32 bits where all the bits are 0s. Then send another frame of 32 bits, if all 1s, that should turn on the led bright white. I only have 1 led, so it should light up on the first go.
At one point, I had the led glowing red, but I'm not sure how I managed to get it to do that (apparently I'm equal to 100 monkeys typing on 100 keyboards).
Using the command line, I've tried
$ echo -ne "\x00\x00\x00\x00" > /dev/spidev0.0
$ echo -ne "\xff\xff\xff\xff" > /dev/spidev0.0
$ echo -ne "\xff\xff\xff\xff" > /dev/spidev0.0
As well as using the pi-spi
node library by writing
var SPI = require('pi-spi');
var spi0 = SPI.initialize('/dev/spidev0.0');
var clear = new Buffer(32);
var full = new Buffer(32);
clear.fill(0);
clear.fill(1);
function cb() { console.log(data)};
spi0.write(clear, cb);
spi0.write(fill, cb);
I've tried the above with both /dev/spidev0.0
and /dev/spidev0.1
Is there something obvious I'm doing wrong here? how can I tell which SPI address I should be using in the initializer? Am I even close?