Review comments

This commit is contained in:
jpirnay
2026-03-26 20:31:41 +01:00
parent ec6835ee79
commit 1112a36806
5 changed files with 24 additions and 16 deletions
+1 -1
View File
@@ -19,7 +19,7 @@
/// Usage:
/// 1. On boot, call `restore()` to seed the system clock from the best
/// available source (RTC memory + LP correction > NVS).
/// 2. After a successful NTP sync, call `onNtpSynced()`.
/// 2. After a successful NTP sync, call `syncNtp()`.
/// 3. Before entering deep sleep, call `saveBeforeSleep()`.
///
/// `now()` returns the best-effort epoch (0 if never synced).
@@ -52,6 +52,16 @@ void ClockSettingsActivity::loop() {
selectedIndex = ButtonNavigator::previousIndex(selectedIndex, MENU_ITEMS);
requestUpdate();
});
buttonNavigator.onNextContinuous([this] {
selectedIndex = ButtonNavigator::nextIndex(selectedIndex, MENU_ITEMS);
requestUpdate();
});
buttonNavigator.onPreviousContinuous([this] {
selectedIndex = ButtonNavigator::previousIndex(selectedIndex, MENU_ITEMS);
requestUpdate();
});
}
void ClockSettingsActivity::handleSelection() {
@@ -33,14 +33,14 @@ bool mapIanaTimezone(const std::string& tz, uint8_t& outSetting) {
outSetting = TZ::TZ_EET;
return true;
}
if (tz.rfind("Europe/", 0) == 0) {
outSetting = TZ::TZ_CET;
return true;
}
if (tz == "Europe/Moscow") {
outSetting = TZ::TZ_MSK;
return true;
}
if (tz.rfind("Europe/", 0) == 0) {
outSetting = TZ::TZ_CET;
return true;
}
if (tz == "America/New_York" || tz == "America/Toronto") {
outSetting = TZ::TZ_EST;
return true;
@@ -136,7 +136,7 @@ bool detectTimezoneSetting(uint8_t& outSetting, std::string& outIana, bool& outD
}
}
if (payload.empty() && !fetchTimezonePayload("http://ip-api.com/json/?fields=timezone,dst", payload)) {
if (payload.empty() && !fetchTimezonePayload("https://ip-api.com/json/?fields=timezone,dst", payload)) {
LOG_ERR("CLK", "Timezone detect failed: fetch error");
return false;
}
@@ -266,6 +266,12 @@ void DetectTimezoneActivity::render(RenderLock&&) {
renderer.clearScreen();
GUI.drawHeader(renderer, Rect{0, metrics.topPadding, pageWidth, metrics.headerHeight}, tr(STR_DETECT_TIMEZONE));
if (state == CONNECTING) {
renderer.drawCenteredText(UI_10_FONT_ID, pageHeight / 2, tr(STR_CONNECTING), true, EpdFontFamily::BOLD);
renderer.displayBuffer();
return;
}
if (state == DETECTING) {
renderer.drawCenteredText(UI_10_FONT_ID, pageHeight / 2, tr(STR_DETECTING_TIMEZONE), true, EpdFontFamily::BOLD);
renderer.displayBuffer();
@@ -220,14 +220,6 @@ void SettingsActivity::toggleCurrentSetting() {
return;
}
if (setting.nameId == StrId::STR_TIMEZONE) {
HalClock::applyTimezone(SETTINGS.timeZone);
}
if (setting.nameId == StrId::STR_USE_CLOCK && !SETTINGS.useClock) {
SETTINGS.statusBarClock = 0;
}
SETTINGS.saveToFile();
}
@@ -37,8 +37,8 @@ const int verticalPreviewTextPadding = 40;
void StatusBarSettingsActivity::onEnter() {
Activity::onEnter();
selectedIndex = 0;
if (!SETTINGS.useClock && selectedIndex >= MENU_ITEMS - 1) {
const int menuCount = SETTINGS.useClock ? MENU_ITEMS : MENU_ITEMS - 1;
if (selectedIndex >= menuCount) {
selectedIndex = 0;
}