sforkowany z mirror/meshtastic-firmware
fix portduino rtc
rodzic
6dc4471bec
commit
f40c6f21d4
|
@ -48,14 +48,22 @@ bool perhapsSetRTC(RTCQuality q, const struct timeval *tv)
|
||||||
shouldSet = false;
|
shouldSet = false;
|
||||||
|
|
||||||
if (shouldSet) {
|
if (shouldSet) {
|
||||||
lastSetMsec = now;
|
lastSetMsec = now;
|
||||||
#ifndef NO_ESP32
|
|
||||||
settimeofday(tv, NULL);
|
// This delta value works on all platforms
|
||||||
readFromRTC();
|
|
||||||
#else
|
|
||||||
timeStartMsec = now;
|
timeStartMsec = now;
|
||||||
zeroOffsetSecs = tv->tv_sec;
|
zeroOffsetSecs = tv->tv_sec;
|
||||||
|
|
||||||
|
// If this platform has a setable RTC, set it
|
||||||
|
#ifndef NO_ESP32
|
||||||
|
settimeofday(tv, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// nrf52 doesn't have a readable RTC (yet - software not written)
|
||||||
|
#if defined(PORTDUINO) || !defined(NO_ESP32)
|
||||||
|
readFromRTC();
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -84,7 +92,7 @@ bool perhapsSetRTC(RTCQuality q, struct tm &t)
|
||||||
|
|
||||||
uint32_t getTime()
|
uint32_t getTime()
|
||||||
{
|
{
|
||||||
return ((millis() - timeStartMsec) / 1000) + zeroOffsetSecs;
|
return (((uint32_t) millis() - timeStartMsec) / 1000) + zeroOffsetSecs;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getValidTime(RTCQuality minQuality)
|
uint32_t getValidTime(RTCQuality minQuality)
|
||||||
|
|
Ładowanie…
Reference in New Issue