So, I'm trying to make a custom library to drive a 8x8 Bi-Color LED Matrix from 2 MAX7219's that incorporates two "Matrix" objects from the "Matrix" library and I cannot, for the life of me, figure out how to initialize them in my class. Can someone help me? By the way, I have been programming for 8 years, and consequently have a decent knowledge of the topic! Here is my current code:
header file
#include "Arduino.h"
#include "Matrix.h"
#include "Sprite.h"
class ZackBiColorMatrix{
public:
ZackBiColorMatrix(byte dataR, byte loadR, byte clockR, byte dataG, byte loadG, byte clockG);
Matrix r;
Matrix g;
void setLED(byte col, byte row, byte val, char color);
void writeSprite(byte x, byte y, Sprite sp, char color);
private:
byte redData;
byte redLoad;
byte redClock;
byte greenData;
byte greenLoad;
byte greenClock;
};
and the .cpp file:
#include "Arduino.h"
#include "Sprite.h"
#include "Matrix.h"
#include "ZackBiColorMatrix.h"
ZackBiColorMatrix::ZackBiColorMatrix (byte dataR, byte loadR, byte clockR, byte dataG, byte loadG, byte clockG) {
redData = dataR;
redLoad = loadR;
redClock = clockR;
greenData = dataG;
greenLoad = loadG;
greenClock = clockG;
r = Matrix (redData, redClock, redLoad);
g = Matrix (greenData, greenClock, greenLoad);
}
void ZackBiColorMatrix::setLED (byte col, byte row, byte val, char color) {
if (color == 'g') {
g.write (col, row, val);
}
else if (color == 'r') {
r.write (col, row, val);
}
}
void ZackBiColorMatrix::writeSprite (byte x, byte y, Sprite sp, char color) {
if (color == 'g') {
g.write (x, y, sp);
}
else if (color == 'r') {
r.write (x, y, sp);
}
}
Also, I use the Eclipse Arduino IDE if that matters.