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:
};
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);
// }
}