diff --git a/lib/hal/HalClock.cpp b/lib/hal/HalClock.cpp index a03576af..324eb58c 100644 --- a/lib/hal/HalClock.cpp +++ b/lib/hal/HalClock.cpp @@ -206,7 +206,12 @@ static double computeCorrectedElapsedSec(uint64_t lpNow, float tempNow) { // faster/slower than nominal, so the true elapsed wall-clock time // differs from the raw LP-derived time by that factor. float avgTemp = (rtcTemperatureC + tempNow) * 0.5f; - float tempDelta = avgTemp - rtcTemperatureC; // = (tempNow - rtcTemperatureC) / 2 + // Positive when COOLED DOWN relative to capture temperature. + // ESP32 RC oscillator has a positive temperature coefficient: it runs faster + // when hotter, causing the LP timer to over-count. To recover true elapsed + // time we must REDUCE the raw LP-derived seconds when the device is warmer + // than at capture (and INCREASE them when cooler). Hence the sign inversion. + float tempDelta = rtcTemperatureC - avgTemp; // = (rtcTemperatureC - tempNow) / 2 float tempFactor = 1.0f + tempDelta * CLOCK_TEMP_DRIFT_SECONDS_PER_SECOND_PER_DEG * rtcDriftScale; if (tempFactor < 0.5f) { tempFactor = 0.5f; @@ -281,8 +286,8 @@ bool syncNtp() { if (prevSyncTime > 0 && preSyncTime > 0 && rtcEpoch > prevSyncTime) { float interval = (float)(rtcEpoch - prevSyncTime); // error = how far the local clock was off before NTP corrected it. - // Positive means local clock was behind (NTP jumped us forward). - // Negative means local clock was ahead (NTP pulled us back). + // Negative means local clock was behind (NTP jumped us forward). + // Positive means local clock was ahead (NTP pulled us back). float error = (float)(preSyncTime - rtcEpoch); if (interval >= 60.0f) { // Convert to seconds-of-drift per day. diff --git a/src/activities/settings/StatusBarSettingsActivity.cpp b/src/activities/settings/StatusBarSettingsActivity.cpp index 09aa7919..48afdd5c 100644 --- a/src/activities/settings/StatusBarSettingsActivity.cpp +++ b/src/activities/settings/StatusBarSettingsActivity.cpp @@ -136,8 +136,9 @@ void StatusBarSettingsActivity::render(RenderLock&&) { const int contentTop = metrics.topPadding + metrics.headerHeight + metrics.verticalSpacing; const int contentHeight = pageHeight - contentTop - metrics.buttonHintsHeight - metrics.verticalSpacing * 2; + const int menuCount = SETTINGS.useClock ? MENU_ITEMS : MENU_ITEMS - 1; GUI.drawList( - renderer, Rect{0, contentTop, pageWidth, contentHeight}, static_cast(MENU_ITEMS), + renderer, Rect{0, contentTop, pageWidth, contentHeight}, static_cast(menuCount), static_cast(selectedIndex), [](int index) { return std::string(I18N.get(menuNames[index])); }, nullptr, nullptr, [this](int index) {