Adding Text to LED Strip Matrix

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
bentpins
 
Posts: 5
Joined: Wed Sep 14, 2011 1:19 am

Adding Text to LED Strip Matrix

Post by bentpins »

Hello,

I've been working on creating a LED matrix out of strips that are cut into pieces and soldered together in a zig-zag to form an 80 pixel grid. So far so good. I'm new to this so I created my own shapes and text by addressing individual pixels. While this is fine for shapes, it would be great to be able to use the adafruit GFX library. I was looking at the LEDbackpack code as an example. I'm getting an error here:

Adafruit_strip strip = Adafruit_strip(nLEDs, dataPin, clockPin);

*Not a member of this class.
..Hoping you could point me in the right direction. I thought I understood but I'm missing something?

Thanks for your help.

Ben

Header file of LDP8806:

Code: Select all

#if (ARDUINO >= 100)
 #include <Arduino.h>
#else
 #include <WProgram.h>
#endif

#include "Adafruit_GFX.h"

#define LED_ON 1
#define LED_OFF 0

class LPD8806  {

 public:

  LPD8806(uint16_t n, uint8_t dpin, uint8_t cpin);
  LPD8806(uint16_t n);
  void
    begin(void),
    show(void),
    setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b),
    setPixelColor(uint16_t n, uint32_t c);
  uint16_t
    numPixels(void);
  uint32_t
    Color(byte, byte, byte);

  boolean
    slowmo; // If true, use digitalWrite instead of direct PORT writes
  uint8_t
    pause;  // Delay (in milliseconds) after latch

 private:

  uint8_t
    *pixels;     // Holds LED color values
  uint16_t
    numLEDs;     // Number of RGB LEDs in strand
  boolean
    hardwareSPI; // If true, using hardware SPI, the following are ignored:
  uint8_t
    datapin, datapinmask, clockpin, clockpinmask;
  volatile uint8_t
    *clockport, *dataport;

  void
    writezeros(uint16_t n);
};

class Adafruit_strip : public LPD8806, public Adafruit_GFX {
 public:
  Adafruit_strip(void);

  void drawPixel(int16_t x, int16_t y, uint16_t color);

 private:
};
Then here's the sketch:

Code: Select all


#include "LPD8806.h"
#include "SPI.h"
#include "Adafruit_GFX.h"


// Example to control LPD8806-based RGB LED Modules in a strip


int we[] = {12,13,14,16,18,21,23,25,32,33,34,36,38,41,42,43,45,52,53,54,56,58,-1}; 

             
int heart[] = {12,13,16,15,22,23,24,25,26,27,28,31,32,33,34,35,36,37,43,44,45,46,47,53,54,55,65,-1}; 


int A[] = {16,17,18,21,23,36,37,38,41,43,56,58,-1}; 

int D[] = {17,18,21,23,36,38,41,43,57,58,-1};

int F[] = {16,17,18,21,37,38,41,58,-1}; 

int R[] = {16,17,18,21,23,37,38,41,42,56,58,-1}; 

int U[] = {16,18,21,23,36,38,41,43,56,57,58,-1}; 

int I[] = {16,17,18,22,37,42,56,57,58,-1}; 

int T[] = {16,17,18,22,37,42,57,-1};

/*****************************************************************************/

// Number of RGB LEDs in strand:
int nLEDs = 80;

// Chose 2 pins for output; can be any valid output pins:
int dataPin = 2;
int clockPin = 3;

// First parameter is the number of LEDs in the strand. The LED strips
// are 32 LEDs per meter but you can extend or cut the strip. Next two
// parameters are SPI data and clock pins:
Adafruit_strip strip = Adafruit_strip(nLEDs, dataPin, clockPin);

// You can optionally use hardware SPI for faster writes, just leave out
// the data and clock pin parameters. But this does limit use to very
// specific pins on the Arduino. For "classic" Arduinos (Uno, Duemilanove,
// etc.), data = pin 11, clock = pin 13. For Arduino Mega, data = pin 51,
// clock = pin 52. For 32u4 Breakout Board+ and Teensy, data = pin B2,
// clock = pin B1. For Leonardo, this can ONLY be done on the ICSP pins.
//LPD8806 strip = LPD8806(nLEDs);

void setup() {
  // Start up the LED strip
  strip.begin();
  Serial.begin(9600);

 
   for (int i = 0 ; we[i]>0 ; i++){
      strip.setPixelColor(we[i], strip.Color(255, 255, 255));
    }
    strip.show();
    delay(3000);
  
    for (int i = 0 ; we[i]>0 ; i++){
      strip.setPixelColor(we[i], strip.Color(0, 0, 0));
    }
    strip.show();


    for (int i = 0 ; heart[i]>0 ; i++){
     strip.setPixelColor(heart[i], strip.Color(255, 0, 0));
    }
    strip.show();
    delay(3000);
    
    for (int i = 0 ; heart[i]>0 ; i++){
     strip.setPixelColor(heart[i], strip.Color(0, 0, 0));
    }
    strip.show();
    
   
    for (int i = 0 ; A[i]>0 ; i++){
     strip.setPixelColor(A[i], strip.Color(0, 255, 255));
    }
    strip.show();
    delay(1000);
    
    for (int i = 0 ; A[i]>0 ; i++){
     strip.setPixelColor(A[i], strip.Color(0, 0, 0));
    }
    strip.show();
    
    
    for (int i = 0 ; D[i]>0 ; i++){
     strip.setPixelColor(D[i], strip.Color(0, 255, 255));
    }
    strip.show();
    delay(1000);
    
    for (int i = 0 ; D[i]>0 ; i++){
     strip.setPixelColor(D[i], strip.Color(0, 0, 0));
    }
    strip.show();
    
    for (int i = 0 ; A[i]>0 ; i++){
     strip.setPixelColor(A[i], strip.Color(0, 255, 255));
    }
    strip.show();
    delay(1000);
    
    for (int i = 0 ; A[i]>0 ; i++){
     strip.setPixelColor(A[i], strip.Color(0, 0, 0));
    }
    strip.show();
    
    
    for (int i = 0 ; F[i]>0 ; i++){
     strip.setPixelColor(F[i], strip.Color(0, 255, 255));
    }
    strip.show();
    delay(1000);
    
    for (int i = 0 ; F[i]>0 ; i++){
     strip.setPixelColor(F[i], strip.Color(0, 0, 0));
    }
    strip.show();
    
    
    for (int i = 0 ; R[i]>0 ; i++){
     strip.setPixelColor(R[i], strip.Color(0, 255, 255));
    }
    strip.show();
    delay(1000);
    
    for (int i = 0 ; R[i]>0 ; i++){
     strip.setPixelColor(R[i], strip.Color(0, 0, 0));
    }
    strip.show();
    
 
    for (int i = 0 ; U[i]>0 ; i++){
     strip.setPixelColor(U[i], strip.Color(0, 255, 255));
    }
    strip.show();
    delay(1000);
    
    for (int i = 0 ; U[i]>0 ; i++){
     strip.setPixelColor(U[i], strip.Color(0, 0, 0));
    }
    strip.show();
    
        
    for (int i = 0 ; I[i]>0 ; i++){
     strip.setPixelColor(I[i], strip.Color(0, 255, 255));
    }
    strip.show();
    delay(1000);
    
    for (int i = 0 ; I[i]>0 ; i++){
     strip.setPixelColor(I[i], strip.Color(0, 0, 0));
    }
    strip.show(); 
    
 
    for (int i = 0 ; T[i]>0 ; i++){
     strip.setPixelColor(T[i], strip.Color(0, 255, 255));
    }
    strip.show();
    delay(1000);
    
    for (int i = 0 ; T[i]>0 ; i++){
     strip.setPixelColor(T[i], strip.Color(0, 0, 0));
    }
    strip.show(); 
  
  // Update the strip, to start they are all 'off'
  strip.show();
}



void loop() {
//   strip.setTextSize(1);
//  strip.setTextWrap(false);  // we dont want text to wrap so it scrolls nicely
//   strip.setTextColor(LED_ON);
//   for (int8_t x=0; x>=-36; x--) {
//    strip.clear();
//    strip.setCursor(x,0);
//    strip.print("Hello");
//    strip.writeDisplay();
//    delay(100);
//  }

    
}



User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adding Text to LED Strip Matrix

Post by adafruit_support_rick »

You need to define a constructor for Adafruit_strip that takes three arguments. The only constructor you have declared takes 0 arguments.

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: Adding Text to LED Strip Matrix

Post by pburgess »

Have a look at the source code for the Adafruit_NeoMatrix library. Though it's written for NeoPixels, you can get a feel for how it's built and apply the same idea for LPD8806 strips.

User avatar
bentpins
 
Posts: 5
Joined: Wed Sep 14, 2011 1:19 am

Re: Adding Text to LED Strip Matrix

Post by bentpins »

Hello Rick and Phil,

Thank you both for the quick reply.

So I changed the constructor in the header file to:

Code: Select all

class Adafruit_strip : public LPD8806, public Adafruit_GFX {
 public:

  Adafruit_strip(uint16_t n, uint8_t dpin, uint8_t cpin);
  

  void drawPixel(int16_t x, int16_t y, uint16_t color);

 private:
};
and get the error below:

Code: Select all

LED_matrix_80.cpp.o: In function `__static_initialization_and_destruction_0':
C:\arduino-1.0.3/LED_matrix_80.ino:42: undefined reference to `Adafruit_strip::Adafruit_strip(unsigned int, unsigned char, unsigned char)'
Do I need to modify the .cpp file also?

Thanks for you help,

Ben

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adding Text to LED Strip Matrix

Post by adafruit_support_rick »

Yes - you need to go into the .cpp file and define the constructor function. Also, you're going to need to add the arguments to the Adafruit_GFX constructor, which are width and height. Since you have to pass width and height in, I got rid of the n parameter, because you can calculate if from w * h

Code: Select all

class Adafruit_strip : public LPD8806, public Adafruit_GFX {
 public:
  Adafruit_strip(uint8_t dpin, uint8_t cpin, uint8_t w, uint8_t h);
  void drawPixel(int16_t x, int16_t y, uint16_t color);

 private:
};
Since you're just passing the arguments through to the LPD8806 and Adafruit_GFX constructors, you can get away with simply doing this in your .cpp file:

Code: Select all

  Adafruit_strip::Adafruit_strip(uint8_t dpin, uint8_t cpin, uint8_t w, uint8_t h ) : LPD8806(w*h, dpin, cpin), Adafruit_GFX(w, h)
{
}

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

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