creating led-matrix from multiple rows of led strips LPD8806
Re: creating led-matrix from multiple rows of led strips LPD8806
Re: creating led-matrix from multiple rows of led strips LPD8806
Re: creating led-matrix from multiple rows of led strips LPD8806
silverline wrote:We have loaded Arduino with a modified version of LEDstream (to be working with cjbaar's modfied library of adafruits LPD8806, which should be faster).
silverline wrote:but we can't make it happen for more than 2 strips
silverline wrote:p.s. plus, we don't want a zig zag, because we are making a tree-like- installation.... is it also possible to connect multiple strips on one teensy?
Re: creating led-matrix from multiple rows of led strips LPD8806
pburgess wrote:Also, is this something that's going to be driven strictly from an Arduino/Teensy, or will it be tethered to a PC?
[A,d,a, hi,lo, checksum, r0, g0, b0, r1,g1,b1...etc]
strip.setPixelColor(i, r, g, b)
pburgess wrote:silverline wrote:p.s. plus, we don't want a zig zag, because we are making a tree-like- installation.... is it also possible to connect multiple strips on one teensy?
Possible, yes. It'll take a long explanation, but I would basically suggest ditching the existing library code and taking an entirely different approach in this case. Are you comfortable with that as a possibility?
Re: creating led-matrix from multiple rows of led strips LPD8806
silverline wrote:because ldp8806 is lightning fast (or so ive heard), buffering isn't really required...
we wrote a bit code derived from ledstream that parses all data from serial port - that is the bytes from Serial.read, which are
- Code: Select all | TOGGLE FULL SIZE
[A,d,a, hi,lo, checksum, r0, g0, b0, r1,g1,b1...etc]
and puts these pixel values on the strip using
- Code: Select all | TOGGLE FULL SIZE
strip.setPixelColor(i, r, g, b)
when the end has arrived, we use strip.show() and start all up again...
int c;
for(;;) {
while((c = Serial.read()) < 0); // Wait for next serial byte in
SPI.transfer(c); // Copy to SPI out
}
silverline wrote:so it would be possible to connect multiple ledstrips (parallel) on more different ports on a teensy / teensy++ using the original SPI adafruit's library?? would be ideal in this situation
Re: creating led-matrix from multiple rows of led strips LPD8806
Re: creating led-matrix from multiple rows of led strips LPD8806
Re: creating led-matrix from multiple rows of led strips LPD8806
Re: creating led-matrix from multiple rows of led strips LPD8806
// LPD8806 streamer: redirects bytes from serial in to SPI out.
// No processing is performed on the data, strictly forwarding.
#include <SPI.h>
void setup() {
int c;
Serial.begin(115200); // 32u4 ignores BPS, runs full speed
// SPI is run at 2 MHz. LPD8806 can run much faster,
// but unshielded wiring is susceptible to interference.
// Feel free to experiment with other divider ratios.
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV8);
SPDR = 0; // Dummy byte out to "prime" the SPI status register
for(;;) { // loop() is avoided for max throughput
while((c = Serial.read()) < 0); // Wait for next serial byte in
while(!(SPSR & (1<<SPIF))); // Wait for prior SPI byte out
SPDR = c; // Issue new SPI byte out
}
}
void loop() { } // Do nothing
import processing.serial.*;
static final int
nLEDs = 160,
latchLen = (nLEDs + 63) / 64;
color[] led = new color[nLEDs];
byte[] serialBuf = new byte[3 * (nLEDs + latchLen)],
gamma = new byte[256];
Serial port;
void setup() {
// The "gamma" table actually does three things: applies gamma
// correction to input colors to produce a more perceptually linear
// output range, reduces 8-bit inputs to 7-bit outputs, and sets the
// high bit as required by the LPD8806 LED data protocol.
for(int i=0; i<256; i++) {
gamma[i] = (byte)(0x80 | (int)(pow(((float)i / 255.0), 2.5) * 127.0 + 0.5));
}
// Assumes Arduino is first/only serial device. Change to suit:
port = new Serial(this, Serial.list()[0], 115200);
colorMode(HSB, 100); // Easy rainbows
}
void draw() {
int i,j;
// Fill the led color array with something interesting:
for(i=0; i<led.length; i++) {
led[i] = color((frameCount + i) % 100, 100, 100);
}
// Convert data from led color array to LPD8806-ready format:
for(i=j=0; i<led.length; i++) {
serialBuf[j++] = gamma[(led[i] >> 8) & 0xff];
serialBuf[j++] = gamma[(led[i] >> 16) & 0xff];
serialBuf[j++] = gamma[ led[i] & 0xff];
}
// Arrays are zero-initialized in Processing/Java,
// so no need to set up the latch data; it's already there.
port.write(serialBuf); // Issue LPD8806 data to Arduino
// You *might* need to comment out the above line and use
// the following code instead. Long writes fail for some
// unknown reason. RXTX lib? Processing? Java? OS? Hardware?
// for(i=0; i<serialBuf.length; i=j) {
// j = i + 255;
// if(j > serialBuf.length) j = serialBuf.length;
// port.write(Arrays.copyOfRange(serialBuf,i,j));
// }
}
Re: creating led-matrix from multiple rows of led strips LPD8806
pburgess wrote:[ready-made sketches]
Re: creating led-matrix from multiple rows of led strips LPD8806
Re: creating led-matrix from multiple rows of led strips LPD8806
silverline wrote:
we wrote a bit code derived from ledstream that parses all data from serial port - that is the bytes from Serial.read, which are
- Code: Select all | TOGGLE FULL SIZE
[A,d,a, hi,lo, checksum, r0, g0, b0, r1,g1,b1...etc]
and puts these pixel values on the strip using
- Code: Select all | TOGGLE FULL SIZE
strip.setPixelColor(i, r, g, b)
when the end has arrived, we use strip.show() and start all up again...
Re: creating led-matrix from multiple rows of led strips LPD8806
SPI.setClockDivider(SPI_CLOCK_DIV2);
GrAnD wrote:Any chance you can post your code to take a loook at? I'm trying to run lpd8806 strip connected to arduino from boblightd which runs under Linux and that's exactly what I'm looking for. Thanks in advance
#include "LPD8806.h"
#include "SPI.h"
// LED pin for Teensy:
#define LED_DDR DDRD
#define LED_PORT PORTD
#define LED_PIN _BV(PORTD6)
// set number of total pixels here
#define NUMPIXELS 180
// mode names
#define WAITING 0
#define PROCESSING 1
// magic word
static const uint8_t magic[] = {
'A','d','a'};
LPD8806 strip = LPD8806(NUMPIXELS);
void setup()
{
uint8_t mode = WAITING;
int16_t pixelIndex = 0;
byte sArray[3];
// LED_DDR |= LED_PIN; // Enable output for LED
// LED_PORT &= ~LED_PIN; // LED off
strip.begin();
// loop() is avoided as even that small bit of function overhead
// has a measurable impact on this code's overall throughput.
for(;;) {
if(Serial.available() > 0) {
sArray[0] = Serial.read();
sArray[1] = Serial.read();
sArray[2] = Serial.read();
if(mode == WAITING) {
if(sArray[0] == 'A' && sArray[1] == 'd' && sArray[2] == 'a') {
sArray[0] = Serial.read();
sArray[1] = Serial.read();
sArray[2] = Serial.read();
if(sArray[2] == (sArray[0] ^ sArray[1] ^ 0x55)) {
mode = PROCESSING;
pixelIndex = 0;
}
else {
Serial.print("Ada\n");
mode = WAITING;
}
}
else {
Serial.print("Ada\n");
mode = WAITING;
}
}
else {
strip.setPixelColor(pixelIndex++,sArray[0],sArray[1],sArray[2]);
if(pixelIndex >= NUMPIXELS) {
strip.show();
mode = WAITING;
}
}
}
else {
Serial.print("Ada\n");
}
} // end for(;;)
}
void loop()
{
// Not used.
}