i want write library rgbdigit shield (http://rgbdigit.com/), adafruit neopixel strip, packed 7 segment display. shield has ds3231 clock , ir receiver.
so plan make class rgbdigit, inherits adafruit_neopixel class , add private members ds3231 , irrecv.
this rgbdigit.h:
this rgbdigit.cpp:
and arduino sketch:
i al lot of "undefined reference" errors:
but don' t understand why. doing wrong?
so plan make class rgbdigit, inherits adafruit_neopixel class , add private members ds3231 , irrecv.
this rgbdigit.h:
code: [select]
#ifndef rgbdigit_h
#define rgbdigit_h
#include <arduino.h>
#include "wire.h"
#include "../adafruit_neopixel/adafruit_neopixel.h"
#include "../irremote/irremote.h"
#include "../ds3231/ds3231.h"
class rgbdigit : public adafruit_neopixel {
public:
rgbdigit(int ndigits);
~rgbdigit();
private:
int _ndigits;
ds3231 _clock;
irrecv* _ir;
};
#endif
this rgbdigit.cpp:
code: [select]
#include "rgbdigit.h"
rgbdigit::rgbdigit(int ndigits)
: adafruit_neopixel(8 * ndigits, 12, neo_grb + neo_khz800),
_ndigits(ndigits)
{
_ir = new irrecv(10);
_ir->enableirin(); // start receiver
adafruit_neopixel::begin();
}
rgbdigit::~rgbdigit()
{
delete _ir;
}
and arduino sketch:
code: [select]
#include <wire.h>
#include <rgbdigit.h>
rgbdigit display = rgbdigit(4);
void setup() {
// put setup code here, run once:
}
void loop() {
// put main code here, run repeatedly:
}
i al lot of "undefined reference" errors:
code: [select]
rgbdigit/rgbdigit.cpp.o: in function `rgbdigit::rgbdigit(int)':
/home/ralph/arduino/libraries/rgbdigit/rgbdigit.cpp:23: undefined reference `adafruit_neopixel::adafruit_neopixel(unsigned int, unsigned char, unsigned char)'
/home/ralph/arduino/libraries/rgbdigit/rgbdigit.cpp:23: undefined reference `ds3231::ds3231()'
/home/ralph/arduino/libraries/rgbdigit/rgbdigit.cpp:25: undefined reference `irrecv::irrecv(int)'
/home/ralph/arduino/libraries/rgbdigit/rgbdigit.cpp:26: undefined reference `irrecv::enableirin()'
/home/ralph/arduino/libraries/rgbdigit/rgbdigit.cpp:27: undefined reference `adafruit_neopixel::begin()'
rgbdigit/rgbdigit.cpp.o: in function `rgbdigit::~rgbdigit()':
/home/ralph/arduino/libraries/rgbdigit/rgbdigit.cpp:30: undefined reference `adafruit_neopixel::~adafruit_neopixel()'
collect2: error: ld returned 1 exit status
but don' t understand why. doing wrong?
Arduino Forum > Using Arduino > Programming Questions > Inheritance: error in calling the constructor of the base class?
arduino
Comments
Post a Comment