Lpd8806 code

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
wirenut1980
 
Posts: 10
Joined: Sat Jun 18, 2011 12:51 am

Lpd8806 code

Post by wirenut1980 »

I have been doing my best to learn how the LPD8806 code works. So far I have been able to make changes to brightness, speed, delay and color. But havent't been able to figure this out: I want to be able to send a single pixel of what ever color from the start of the strip to the end and stack till the strip is full and then clear out and start with a new color. Also how can I write a pixel to go to a specific location say 1/2 way or 3/4 and stay till cleared. Any help would be greatly appreciated.

User avatar
adafruit_support_bill
 
Posts: 88097
Joined: Sat Feb 07, 2009 10:11 am

Re: Lpd8806 code

Post by adafruit_support_bill »

I want to be able to send a single pixel of what ever color from the start of the strip to the end and stack till the strip is full and then clear out and start with a new color.
This is not tested, but should be close to what you want ( derived from the colorChase function in StrandTest)

Code: Select all


void colorChaseAndFill(uint32_t c, uint8_t wait) 
{
  int i;
  
  for (i=0; i < strip.numPixels(); i++) 
  {
    strip.setPixelColor(i, 0);  // turn all pixels off
  } 
  
  for (j=0; j < strip.numPixels(); j++
  {
    for (i=0; i < strip.numPixels()-j; i++) 
    {
        strip.setPixelColor(i, c);
        if (i > 0) 
        { 
          strip.setPixelColor(i-1, 0);
        }
        strip.show();
        delay(wait);
    }
}
Also how can I write a pixel to go to a specific location say 1/2 way or 3/4 and stay till cleared
You should be able to derive that from the code above.

User avatar
wirenut1980
 
Posts: 10
Joined: Sat Jun 18, 2011 12:51 am

Re: Lpd8806 code

Post by wirenut1980 »

I was able to make a few additions to get the code suggested to compile ( see below ). I tested it in the strand test and it seems to either skip over the cycle or it"s running the same as one of the other cycles. Is there a way to write this so as to be able to choose color and speed? ex; colorChaseAndFill(strip.Color(127,0,0), 10); and add lines for each color.



void colorChaseAndFill(uint32_t c, uint8_t wait)
{
int i;
int j;

for (i=0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i, 0); // turn all pixels off
}

for (j=0; j < strip.numPixels(); j++)
{
for (i=0; i < strip.numPixels()-j; i++)
{
strip.setPixelColor(i, c);
if (i > 0)
{
strip.setPixelColor(i-1, 0);
}
strip.show();
delay(wait);
}
}
}

User avatar
wirenut1980
 
Posts: 10
Joined: Sat Jun 18, 2011 12:51 am

Re: Lpd8806 code

Post by wirenut1980 »

This example may help;

Something like this;

colorChaseAndFill(strip.Color(127,0,0), 10); // full brightness red
colorChaseAndFill(strip.Color(127,127,0), 10); // orange
colorChaseAndFill(strip.Color(0,127,0), 10); // green
colorChaseAndFill(strip.Color(0,127,127), 10); // teal
colorChaseAndFill(strip.Color(0,0,127), 10); // blue
colorChaseAndFill(strip.Color(127,0,127), 10); // violet


It should display a single pixel with chosen color to light one pixel and make it's way down the strip to the end and stay lit followed by another pixel of that same color to make it's way down and stack till the entire strip is full then clear out and start with next chosen color.

User avatar
adafruit_support_bill
 
Posts: 88097
Joined: Sat Feb 07, 2009 10:11 am

Re: Lpd8806 code

Post by adafruit_support_bill »

I tested it in the strand test and it seems to either skip over the cycle or it"s running the same as one of the other cycles.
You have to call it from the loop.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”