Forum - I'm having a persistant failure in verifying a small clock sketch with an included library file set "RTCMHHlib". The sketch will verify correctly if another "standard" library file is substituted for the offender.
The error message is shown below:
Arduino: 1.8.1 (Windows 7), Board: "Arduino/Genuino Uno"
C:\Users\Astro\Documents\Arduino\libraries\RTCMHHlib\RTCMHHlib.cpp:460:44: error: no 'void RTC_DS3231::setHour(const DateTime&)' member function declared in class 'RTC_DS3231'
void RTC_DS3231::setHour(const DateTime& dt) {
^
exit status 1
Error compiling for board Arduino/Genuino Uno.
The code snippet below shows the #include section of the sketch. The third line calls the library file RTCMHHlib.h (which was modified from Adafruit's RTClib.h; the sketch works with RTClib.h).
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <RTCMHHlib.h>
#include "Adafruit_LEDBackpack.h"
The problem is in the file RTCMHHlib.cpp in the library RTCMHHlib. The code snippet below shows the line from RTCMHHlib.cpp that causes the compiler to balk:
void RTC_DS3231::setHour(const DateTime& dt) { [color=red]//This line causes the problem[/color]
Wire.beginTransmission(DS3231_ADDRESS);
Wire._I2C_WRITE((byte)2); // start at location 2
Wire._I2C_WRITE(bin2bcd(dt.hour()));
Wire.endTransmission();
uint8_t statreg = read_i2c_register(DS3231_ADDRESS, DS3231_STATUSREG);
statreg &= ~0x80; // flip OSF bit
write_i2c_register(DS3231_ADDRESS, DS3231_STATUSREG, statreg);
}
The next code snippet comes just before the above in RTCMHHlib.cpp and works fine:
void RTC_DS3231::adjust(const DateTime& dt) {
Wire.beginTransmission(DS3231_ADDRESS);
Wire._I2C_WRITE((byte)0); // start at location 0
Wire._I2C_WRITE(bin2bcd(dt.second()));
Wire._I2C_WRITE(bin2bcd(dt.minute()));
Wire._I2C_WRITE(bin2bcd(dt.hour()));
Wire._I2C_WRITE(bin2bcd(0));
Wire._I2C_WRITE(bin2bcd(dt.day()));
Wire._I2C_WRITE(bin2bcd(dt.month()));
Wire._I2C_WRITE(bin2bcd(dt.year() - 2000));
Wire.endTransmission();
uint8_t statreg = read_i2c_register(DS3231_ADDRESS, DS3231_STATUSREG);
statreg &= ~0x80; // flip OSF bit
write_i2c_register(DS3231_ADDRESS, DS3231_STATUSREG, statreg);
}
The following code snippet from RTCMHHlib.h shows where I think/thought the class member "setHour" was declared:
class RTC_DS3231 {
public:
boolean begin(void);
static void adjust(const DateTime& dt);
static void setHour(const DateTime& dt); [color=red]Function setHour should be declared here[/color]
bool lostPower(void);
static DateTime now();
static Ds3231SqwPinMode readSqwPinMode();
static void writeSqwPinMode(Ds3231SqwPinMode mode);
};
The forum post editor won't let me post the entire .cpp and .h files: "...exceeds the maximum allowed length (9000 characters)."
To my nonexpert eye it surely looks like the function "setHour" is correctly declared in RTCMHHlib.h
Anyone have any ideas or insights as to why the compiler doesn't think the function is properly declared? I would greatly appreciate any help/advice that could be offered. Thanks in advance.
MickH
9 June 17
2:08 PM PDT USA