Revert "remember which devices were scanned on which bus and set them accordingly." - this is not working at all.

This commit is contained in:
Thomas Göttgens
2022-11-13 14:56:52 +01:00
parent 037d6c253b
commit 6a696af8f6
23 changed files with 117 additions and 191 deletions

View File

@@ -20,16 +20,10 @@ void readFromRTC()
{
struct timeval tv; /* btw settimeofday() is helpfull here too*/
#ifdef RV3028_RTC
if(i2cScanMap[RV3028_RTC].addr == RV3028_RTC) {
if(rtc_found == RV3028_RTC) {
uint32_t now = millis();
Melopero_RV3028 rtc;
if (i2cScanMap[RV3028_RTC].bus == 1) {
#ifdef I2C_SDA1
rtc.initI2C(Wire1);
#endif
} else {
rtc.initI2C();
}
rtc.initI2C();
tm t;
t.tm_year = rtc.getYear() - 1900;
t.tm_mon = rtc.getMonth() - 1;
@@ -47,16 +41,14 @@ void readFromRTC()
}
}
#elif defined(PCF8563_RTC)
if(i2cScanMap[PCF8563_RTC].addr == PCF8563_RTC) {
if(rtc_found == PCF8563_RTC) {
uint32_t now = millis();
PCF8563_Class rtc;
if (i2cScanMap[PCF8563_RTC].bus == 1) {
#ifdef I2C_SDA1
rtc.begin(Wire1);
#ifdef RTC_USE_WIRE1
rtc.begin(Wire1);
#else
rtc.begin();
#endif
} else {
rtc.begin();
}
auto tc = rtc.getDateTime();
tm t;
t.tm_year = tc.year - 1900;
@@ -112,29 +104,21 @@ bool perhapsSetRTC(RTCQuality q, const struct timeval *tv)
// If this platform has a setable RTC, set it
#ifdef RV3028_RTC
if(i2cScanMap[RV3028_RTC].addr == RV3028_RTC) {
if(rtc_found == RV3028_RTC) {
Melopero_RV3028 rtc;
if (i2cScanMap[RV3028_RTC].bus == 1) {
#ifdef I2C_SDA1
rtc.initI2C(Wire1);
#endif
} else {
rtc.initI2C();
}
rtc.initI2C();
tm *t = localtime(&tv->tv_sec);
rtc.setTime(t->tm_year + 1900, t->tm_mon + 1, t->tm_wday, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
DEBUG_MSG("RV3028_RTC setTime %02d-%02d-%02d %02d:%02d:%02d %ld\n", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, tv->tv_sec);
}
#elif defined(PCF8563_RTC)
if(i2cScanMap[PCF8563_RTC].addr == PCF8563_RTC) {
if(rtc_found == PCF8563_RTC) {
PCF8563_Class rtc;
if (i2cScanMap[PCF8563_RTC].bus == 1) {
#ifdef I2C_SDA1
rtc.begin(Wire1);
#ifdef RTC_USE_WIRE1
rtc.begin(Wire1);
#else
rtc.begin();
#endif
} else {
rtc.begin();
}
tm *t = localtime(&tv->tv_sec);
rtc.setDateTime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
DEBUG_MSG("PCF8563_RTC setDateTime %02d-%02d-%02d %02d:%02d:%02d %ld\n", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, tv->tv_sec);