mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-09 14:42:05 +00:00
Last heard fix
This commit is contained in:
parent
bf9a7d3a7f
commit
6b2e03e9d2
@ -1923,7 +1923,7 @@ static int scrollIndex = 0;
|
|||||||
|
|
||||||
// Use dynamic timing based on mode
|
// Use dynamic timing based on mode
|
||||||
unsigned long getModeCycleIntervalMs() {
|
unsigned long getModeCycleIntervalMs() {
|
||||||
return (currentMode == MODE_DISTANCE) ? 4000 : 2000;
|
return (currentMode == MODE_DISTANCE) ? 3000 : 2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
// h! Calculates bearing between two lat/lon points (used for compass)
|
// h! Calculates bearing between two lat/lon points (used for compass)
|
||||||
@ -2283,21 +2283,30 @@ const char* getCurrentModeTitle()
|
|||||||
#ifndef USE_EINK
|
#ifndef USE_EINK
|
||||||
static void drawDynamicNodeListScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
static void drawDynamicNodeListScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
|
// Static variables to track mode and duration
|
||||||
|
static NodeListMode lastRenderedMode = MODE_COUNT;
|
||||||
|
static unsigned long modeStartTime = 0;
|
||||||
|
|
||||||
unsigned long now = millis();
|
unsigned long now = millis();
|
||||||
|
|
||||||
// Always start with MODE_LAST_HEARD on screen entry
|
// On very first call (on boot or state enter)
|
||||||
if (state->ticksSinceLastStateSwitch == 0) {
|
if (lastRenderedMode == MODE_COUNT) {
|
||||||
currentMode = MODE_LAST_HEARD;
|
currentMode = MODE_LAST_HEARD;
|
||||||
lastModeSwitchTime = now;
|
modeStartTime = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now - lastModeSwitchTime >= getModeCycleIntervalMs()) {
|
// Time to switch to next mode?
|
||||||
lastModeSwitchTime = now;
|
if (now - modeStartTime >= getModeCycleIntervalMs()) {
|
||||||
currentMode = static_cast<NodeListMode>((currentMode + 1) % MODE_COUNT);
|
currentMode = static_cast<NodeListMode>((currentMode + 1) % MODE_COUNT);
|
||||||
|
modeStartTime = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Render screen based on currentMode
|
||||||
const char* title = getCurrentModeTitle();
|
const char* title = getCurrentModeTitle();
|
||||||
drawNodeListScreen(display, state, x, y, title, drawEntryDynamic);
|
drawNodeListScreen(display, state, x, y, title, drawEntryDynamic);
|
||||||
|
|
||||||
|
// Track the last mode to avoid reinitializing modeStartTime
|
||||||
|
lastRenderedMode = currentMode;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user