OK, I'm stumped... I've got a sketch that uses OneWire devices. I'm making a library that will support a real-time clock chip (DS2417) on the OneWire net. So the library class needs to know and remember the user's OneWire instance so it can talk to the clock chip. I've stripped the code to its essentials below:
// DS2417RTC.h - library for DS2417 RTC -------------------------
#include <Time.h>
#include <OneWire.h>
class DS2417RTC {
static OneWire* dsx; // Private variable
public:
DS2417RTC(OneWire*); // Constructor
static time_t get(); // Member function
};
// Here's the DS2417RTC.ccp file-----------------------------------
#include <Time.h>
#include <OneWire.h>
#include "DS2417RTC.h"
DS2417RTC::DS2417RTC(OneWire* dsp) {
dsx = dsp; // Save pointer to main's OneWire instance
}
time_t DS2417RTC::get() {
uint8_t rom[8] = {0x27, 0xAB, 0x5B, 0x22, 0, 0, 0, 0x6A}; // Clock chip addr
dsx->select(rom); // Represents several OneWire function calls
return 123;
}
// Here's the Arduino sketch file (xxx.pde)------------------------
#include <Time.h>
#include "DS2417RTC.h"
#include <OneWire.h>
OneWire ds(10); // One-Wire net on pin 10
DS2417RTC RTC(&ds); // Use DS2417 Real-Time Clock
void setup() {
}
void loop() {
time_t t = RTC.get();
}
// Here's the error output:
//
DS2417RTC.cpp.o: In function `DS2417RTC':
(file path removed) /DS2417RTC.cpp:7: undefined reference to `DS2417RTC::dsx'
(file path removed) /DS2417RTC.cpp:7: undefined reference to `DS2417RTC::dsx'
DS2417RTC.cpp.o: In function `DS2417RTC::get()':
(file path removed) /DS2417RTC.cpp:13: undefined reference to `DS2417RTC::dsx'
(file path removed) /DS2417RTC.cpp:13: undefined reference to `DS2417RTC::dsx'
What's he complaining about?
Thanks in advance for your attention!
73,
Gary