mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-10-24 00:42:28 +00:00
ui: make housekeeping refresh path on-demand
Stop doing UI work nobody asked for. The 5 s housekeeping tick was reading env sensors (I2C, 10-50 ms), the battery ADC (regulator toggle + 8 samples, every 60 s), and re-rendering the display unconditionally — all while the display might be off and nothing on-air had requested any of it. Now: - render_sensors() reads env sensors only when the user is on that page (event-driven, never fires during idle) - battery refresh is lazy on ui_pages_render() with a 30 s freshness guard; explicit ui_set_battery() calls also count - the unconditional OLED rerender from housekeeping is gone; real state changes (messages, BLE, button press) still fire schedule_render() directly Telemetry / stats paths read fresh ADC + sensors on demand and were never using the UI cache, so over-the-air consumers are unaffected.
This commit is contained in:
1 parent
c115803786
commit
3a35fec8b3
8 files changed
+75
-89
No files matched your search
@@ -276,6 +276,11 @@ static void gps_fix_callback(double lat, double lon, int64_t utc_time)
|
||||
#ifdef ZEPHCORE_LORA
|
||||
static mesh::ZephyrBoard zephyr_board;
|
||||
|
||||
static uint16_t get_battery_mv(void)
|
||||
{
|
||||
return zephyr_board.getBattMilliVolts();
|
||||
}
|
||||
|
||||
/* Radio is constructed with no prefs pointer; main() binds it to
|
||||
* repeater_mesh._prefs via setPrefs() before repeater_mesh.begin(). */
|
||||
|
||||
@@ -364,15 +369,9 @@ static void repeater_event_loop(void)
|
||||
lora_radio.getNoiseFloor());
|
||||
}
|
||||
|
||||
/* Battery every ~60s (12 × 5s housekeeping) */
|
||||
static uint8_t batt_counter;
|
||||
if (++batt_counter >= 12) {
|
||||
batt_counter = 0;
|
||||
ui_set_battery(zephyr_board.getBattMilliVolts(), 0);
|
||||
}
|
||||
/* Battery is now refreshed lazily from ui_pages_render() with
|
||||
* a 30 s freshness guard — no periodic ADC fire here. */
|
||||
#endif
|
||||
|
||||
ui_refresh_display();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -506,6 +505,7 @@ int main(void)
|
||||
prefs->cr,
|
||||
prefs->tx_power_dbm,
|
||||
lora_radio.getNoiseFloor());
|
||||
ui_set_battery_provider(get_battery_mv);
|
||||
ui_set_battery(zephyr_board.getBattMilliVolts(), 0);
|
||||
ui_set_gps_available(gps_is_available());
|
||||
|
||||
|
||||
Reference in new issue
Block a user