I am turning my LED clock code into a library so that I can easily drop it into a project and keep the main sketch uncluttered, just exposing the methods that create the clock functionality.
I am not new to programming or OOP programming, but I am new to C-based programming with it's pointers and strong typing. I am having trouble figuring out how to instantiate an Adafruit_NeoPixel object inside of my class and then use it in other methods. One example:
MyClock.h
MyClock.ccp
When I try to call _Seconds->begin() for example, this error presents:
Any suggestions would be appreciated!
Also, may be a separate issue, may be related, but you can see that I would like to declare two objects for one strip for semantics (Seconds and Minutes). Is this good practice? Would a cloned object/pointer be better? Suggestions?
I am not new to programming or OOP programming, but I am new to C-based programming with it's pointers and strong typing. I am having trouble figuring out how to instantiate an Adafruit_NeoPixel object inside of my class and then use it in other methods. One example:
MyClock.h
Code:
class MyClock
{
public:
MyClock(byte Outer_Ring_LEDs, byte Outer_Ring_Pin, byte Inner_Ring_LEDs, byte Inner_Ring_Pin);
private:
Adafruit_NeoPixel* _Seconds;
Adafruit_NeoPixel* _Minutes;
Adafruit_NeoPixel* _Hours;
};
MyClock.ccp
Code:
GClock::GClock(byte Outer_Ring_LEDs, byte Outer_Ring_Pin, byte Inner_Ring_LEDs, byte Inner_Ring_Pin) {
_Seconds = new Adafruit_NeoPixel(Outer_Ring_LEDs, Outer_Ring_Pin, NEO_GRB + NEO_KHZ800);
_Minutes = new Adafruit_NeoPixel(Outer_Ring_LEDs, Outer_Ring_Pin, NEO_GRB + NEO_KHZ800);
_Hours = new Adafruit_NeoPixel(Inner_Ring_LEDs, Inner_Ring_Pin, NEO_GRB + NEO_KHZ800);
// initialize the LED rings
_Seconds->begin();
_Seconds->show();
// _Minutes->begin();
// _Minutes->show();
_Hours->begin();
_Hours->show();
}
When I try to call _Seconds->begin() for example, this error presents:
Code:
GClock.cpp:26: undefined reference to `Adafruit_NeoPixel::begin()
Any suggestions would be appreciated!
Also, may be a separate issue, may be related, but you can see that I would like to declare two objects for one strip for semantics (Seconds and Minutes). Is this good practice? Would a cloned object/pointer be better? Suggestions?