mirror of
https://github.com/wled/WLED.git
synced 2025-07-09 20:06:33 +00:00
Fixed difference calculation
This commit is contained in:
parent
55b26751ae
commit
7cbc9d21b5
@ -437,12 +437,13 @@ void calculateSunriseAndSunset() {
|
||||
//time from JSON and HTTP API
|
||||
void setTimeFromAPI(uint32_t timein) {
|
||||
if (timein == 0 || timein == UINT32_MAX) return;
|
||||
time_t prev = toki.second();
|
||||
uint32_t prev = toki.second();
|
||||
//only apply if more accurate or there is a significant difference to the "more accurate" time source
|
||||
if (toki.getTimeSource() > TOKI_TS_JSON && abs(timein - prev) < 60L) return;
|
||||
uint32_t diff = (timein > prev) ? timein - prev : prev - timein;
|
||||
if (toki.getTimeSource() > TOKI_TS_JSON && diff < 60U) return;
|
||||
|
||||
toki.setTime(timein, TOKI_NO_MS_ACCURACY, TOKI_TS_JSON);
|
||||
if (abs(timein - prev) > 60L) {
|
||||
if (diff >= 60U) {
|
||||
updateLocalTime();
|
||||
calculateSunriseAndSunset();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user