Review comments
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@
|
|||||||
/// Usage:
|
/// Usage:
|
||||||
/// 1. On boot, call `restore()` to seed the system clock from the best
|
/// 1. On boot, call `restore()` to seed the system clock from the best
|
||||||
/// available source (RTC memory + LP correction > NVS).
|
/// 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()`.
|
/// 3. Before entering deep sleep, call `saveBeforeSleep()`.
|
||||||
///
|
///
|
||||||
/// `now()` returns the best-effort epoch (0 if never synced).
|
/// `now()` returns the best-effort epoch (0 if never synced).
|
||||||
|
|||||||
@@ -52,6 +52,16 @@ void ClockSettingsActivity::loop() {
|
|||||||
selectedIndex = ButtonNavigator::previousIndex(selectedIndex, MENU_ITEMS);
|
selectedIndex = ButtonNavigator::previousIndex(selectedIndex, MENU_ITEMS);
|
||||||
requestUpdate();
|
requestUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
buttonNavigator.onNextContinuous([this] {
|
||||||
|
selectedIndex = ButtonNavigator::nextIndex(selectedIndex, MENU_ITEMS);
|
||||||
|
requestUpdate();
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonNavigator.onPreviousContinuous([this] {
|
||||||
|
selectedIndex = ButtonNavigator::previousIndex(selectedIndex, MENU_ITEMS);
|
||||||
|
requestUpdate();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClockSettingsActivity::handleSelection() {
|
void ClockSettingsActivity::handleSelection() {
|
||||||
|
|||||||
@@ -33,14 +33,14 @@ bool mapIanaTimezone(const std::string& tz, uint8_t& outSetting) {
|
|||||||
outSetting = TZ::TZ_EET;
|
outSetting = TZ::TZ_EET;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (tz.rfind("Europe/", 0) == 0) {
|
|
||||||
outSetting = TZ::TZ_CET;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (tz == "Europe/Moscow") {
|
if (tz == "Europe/Moscow") {
|
||||||
outSetting = TZ::TZ_MSK;
|
outSetting = TZ::TZ_MSK;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (tz.rfind("Europe/", 0) == 0) {
|
||||||
|
outSetting = TZ::TZ_CET;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (tz == "America/New_York" || tz == "America/Toronto") {
|
if (tz == "America/New_York" || tz == "America/Toronto") {
|
||||||
outSetting = TZ::TZ_EST;
|
outSetting = TZ::TZ_EST;
|
||||||
return true;
|
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");
|
LOG_ERR("CLK", "Timezone detect failed: fetch error");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -266,6 +266,12 @@ void DetectTimezoneActivity::render(RenderLock&&) {
|
|||||||
renderer.clearScreen();
|
renderer.clearScreen();
|
||||||
GUI.drawHeader(renderer, Rect{0, metrics.topPadding, pageWidth, metrics.headerHeight}, tr(STR_DETECT_TIMEZONE));
|
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) {
|
if (state == DETECTING) {
|
||||||
renderer.drawCenteredText(UI_10_FONT_ID, pageHeight / 2, tr(STR_DETECTING_TIMEZONE), true, EpdFontFamily::BOLD);
|
renderer.drawCenteredText(UI_10_FONT_ID, pageHeight / 2, tr(STR_DETECTING_TIMEZONE), true, EpdFontFamily::BOLD);
|
||||||
renderer.displayBuffer();
|
renderer.displayBuffer();
|
||||||
|
|||||||
@@ -220,14 +220,6 @@ void SettingsActivity::toggleCurrentSetting() {
|
|||||||
return;
|
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();
|
SETTINGS.saveToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ const int verticalPreviewTextPadding = 40;
|
|||||||
void StatusBarSettingsActivity::onEnter() {
|
void StatusBarSettingsActivity::onEnter() {
|
||||||
Activity::onEnter();
|
Activity::onEnter();
|
||||||
|
|
||||||
selectedIndex = 0;
|
const int menuCount = SETTINGS.useClock ? MENU_ITEMS : MENU_ITEMS - 1;
|
||||||
if (!SETTINGS.useClock && selectedIndex >= MENU_ITEMS - 1) {
|
if (selectedIndex >= menuCount) {
|
||||||
selectedIndex = 0;
|
selectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user