Merge branch 'feat-additional-compensation' of https://github.com/jpirnay/crosspoint-reader into mybuild
# Conflicts: # lib/hal/HalClock.cpp # src/CrossPointSettings.h # src/activities/reader/KOReaderSyncActivity.cpp # src/activities/settings/SettingsActivity.cpp # src/activities/settings/SettingsActivity.h
This commit is contained in:
@@ -206,7 +206,12 @@ static double computeCorrectedElapsedSec(uint64_t lpNow, float tempNow) {
|
|||||||
// faster/slower than nominal, so the true elapsed wall-clock time
|
// faster/slower than nominal, so the true elapsed wall-clock time
|
||||||
// differs from the raw LP-derived time by that factor.
|
// differs from the raw LP-derived time by that factor.
|
||||||
float avgTemp = (rtcTemperatureC + tempNow) * 0.5f;
|
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;
|
float tempFactor = 1.0f + tempDelta * CLOCK_TEMP_DRIFT_SECONDS_PER_SECOND_PER_DEG * rtcDriftScale;
|
||||||
if (tempFactor < 0.5f) {
|
if (tempFactor < 0.5f) {
|
||||||
tempFactor = 0.5f;
|
tempFactor = 0.5f;
|
||||||
@@ -281,8 +286,8 @@ bool syncNtp() {
|
|||||||
if (prevSyncTime > 0 && preSyncTime > 0 && rtcEpoch > prevSyncTime) {
|
if (prevSyncTime > 0 && preSyncTime > 0 && rtcEpoch > prevSyncTime) {
|
||||||
float interval = (float)(rtcEpoch - prevSyncTime);
|
float interval = (float)(rtcEpoch - prevSyncTime);
|
||||||
// error = how far the local clock was off before NTP corrected it.
|
// 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 behind (NTP jumped us forward).
|
||||||
// Negative means local clock was ahead (NTP pulled us back).
|
// Positive means local clock was ahead (NTP pulled us back).
|
||||||
float error = (float)(preSyncTime - rtcEpoch);
|
float error = (float)(preSyncTime - rtcEpoch);
|
||||||
if (interval >= 60.0f) {
|
if (interval >= 60.0f) {
|
||||||
// Convert to seconds-of-drift per day.
|
// Convert to seconds-of-drift per day.
|
||||||
|
|||||||
@@ -136,8 +136,9 @@ void StatusBarSettingsActivity::render(RenderLock&&) {
|
|||||||
|
|
||||||
const int contentTop = metrics.topPadding + metrics.headerHeight + metrics.verticalSpacing;
|
const int contentTop = metrics.topPadding + metrics.headerHeight + metrics.verticalSpacing;
|
||||||
const int contentHeight = pageHeight - contentTop - metrics.buttonHintsHeight - metrics.verticalSpacing * 2;
|
const int contentHeight = pageHeight - contentTop - metrics.buttonHintsHeight - metrics.verticalSpacing * 2;
|
||||||
|
const int menuCount = SETTINGS.useClock ? MENU_ITEMS : MENU_ITEMS - 1;
|
||||||
GUI.drawList(
|
GUI.drawList(
|
||||||
renderer, Rect{0, contentTop, pageWidth, contentHeight}, static_cast<int>(MENU_ITEMS),
|
renderer, Rect{0, contentTop, pageWidth, contentHeight}, static_cast<int>(menuCount),
|
||||||
static_cast<int>(selectedIndex), [](int index) { return std::string(I18N.get(menuNames[index])); }, nullptr,
|
static_cast<int>(selectedIndex), [](int index) { return std::string(I18N.get(menuNames[index])); }, nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
[this](int index) {
|
[this](int index) {
|
||||||
|
|||||||
Reference in New Issue
Block a user