Fix OLED autosleep timing and battery sampling cadence
- Track last OLED activity to avoid double timeout; keep power gating on transitions - Copy TZ before setenv() in timegm_fallback to avoid invalid pointer reuse - Add BATTERY_SAMPLE_INTERVAL_MS and only refresh cache at batch start when due - Keep battery sampling to a single ADC read (Arduino core lacks explicit ADC power gating)
This commit is contained in:
@@ -152,6 +152,10 @@ static void update_battery_cache() {
|
||||
g_last_battery_ms = millis();
|
||||
}
|
||||
|
||||
static bool battery_sample_due(uint32_t now_ms) {
|
||||
return g_last_battery_ms == 0 || now_ms - g_last_battery_ms >= BATTERY_SAMPLE_INTERVAL_MS;
|
||||
}
|
||||
|
||||
static bool sender_timesync_window_due() {
|
||||
uint32_t interval_sec = SENDER_TIMESYNC_CHECK_SEC_FAST;
|
||||
if (time_is_synced() && time_rtc_present()) {
|
||||
@@ -742,7 +746,7 @@ static void sender_loop() {
|
||||
note_fault(g_sender_faults, g_sender_last_error, g_sender_last_error_utc, g_sender_last_error_ms, FaultType::MeterRead);
|
||||
display_set_last_error(g_sender_last_error, g_sender_last_error_utc, g_sender_last_error_ms);
|
||||
}
|
||||
if (g_build_count == 0) {
|
||||
if (g_build_count == 0 && battery_sample_due(now_ms)) {
|
||||
update_battery_cache();
|
||||
}
|
||||
data.battery_voltage_v = g_last_battery_voltage_v;
|
||||
|
||||
Reference in New Issue
Block a user