I'm trying to take the Renard protocol output of Vixen Lights 3.0 into my Arduino Due and spit it out over SPI to the LPD8806 RGB strip (sold at adafruit). The renard protocol is very simple, it will output 2 control bytes (which are ignored for now in the code) and then 3 bytes for each RGB pixel on the strip. So for 20 pixels that is 60 bytes + 2 bytes for a total of 62 bytes. All I do is take the 60 bytes of color information and send it out via spi with 3 latch bytes. The code below works fine for 20 pixels. Not a problem. Once I try anything above that (24 pixels) the spi output stops cold and I see nothing on the strip. This is where I've wasted hours and need a little advice.
I'm using 2 pins on the Arduino Due:
MOSI - 109
SCK - 110
//****************************************************************
// Name : LPD8806 RGB Awesomeness //
// Author : Matthew Strange //
// Version : 1.0 //
// Notes : Arduino Due Sketch //
// : Renard Protocol //
// : LPD8806 RGB Strip //
// : Vixen 3.0.3 //
//****************************************************************
#include "SPI.h"
byte incomingByte[481]; //Channels + 1 - zero indexed
//number of pixels/LEDs in strip you will use
int pix = 24;
int pixCount = pix * 3;
int one = 0;
int fun = pixCount + 1;
//int ss=109;
// Clock Pin
//int clockPin = 110;
// Data Pin
//int dataPin = 109;
void setup()
{
//pinMode(ss, OUTPUT); // we use this for 109 pin
SPI.begin(109);
SPI.setBitOrder(109, MSBFIRST);
SPI.setDataMode(109, SPI_MODE0);
SPI.setClockDivider(109, 21);
Serial.begin(115200);
}
void loop(){
//Run once to clear the strip
if (one == 0){
SPI.transfer(109, 0x00, SPI_CONTINUE);
SPI.transfer(109, 0x00, SPI_CONTINUE);
SPI.transfer(109, 0x00);
one = 5;
}
//Place incoming bytes into the array
if (Serial.available() >= (pixCount + 2)) { // Channels + 2
for (int i=0; i < (pixCount + 3); i++) { // Channels + 3
incomingByte[i] = ((Serial.read()/2) + 128);
}
}
// Skip the first 2 bytes on Renard protocol and output to RGB strip
for (int i=2; i < (pixCount + 3); i++) { //Channels + 3
//shiftOut(dataPin, clockPin, MSBFIRST, incomingByte[i]);
SPI.transfer(109, incomingByte[i], SPI_CONTINUE);
}
// Latch the output
SPI.transfer(109, 0x00, SPI_CONTINUE);
SPI.transfer(109, 0x00, SPI_CONTINUE);
SPI.transfer(109, 0x00);
//delayMicroseconds(150);
//delay(25);
}
Yes I'm aware Adafruit has a library but I'm a DIY geek/junkie and I want to learn this myself, not cheat. Thank you in advance