diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 61530587..ff991c4e 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -46,7 +46,8 @@ // а килогерцы — по символам (сотни, десятки, единицы). Разряд 0 — МГц, 1..3 — кГц. #define UI_RADIO_FREQ_KHZ_DIGITS 3 #define UI_RADIO_MENU_TIMEOUT_MILLIS 300000UL // 5 минут простоя — выйти из меню без сохранения -#define NOTIFY_MAIN_ROWS 7 // строк в меню уведомлений +#define NOTIFY_MAIN_ROWS 8 // строк в меню уведомлений (включая Timezone) +#define NOTIFY_ROW_TZ 5 // строка Timezone (стоит перед Quiet hours) // Строка меню: выбранная — инверсией, значение — справа вторичным цветом static void drawMenuRow(DisplayDriver& display, int y, bool sel, const char* label, const char* value) { @@ -272,7 +273,7 @@ class HomeScreen : public UIScreen { enum NotifyScreen { NOTIFY_OFF, NOTIFY_MAIN, NOTIFY_CHANNELS, NOTIFY_QUIET }; uint8_t _notify_screen; uint8_t _notify_sel; - bool _notify_val_edit; // правка часа в подменю тихих часов + bool _notify_val_edit; // правка значения в меню уведомлений (час тишины, часовой пояс) unsigned long _notify_last_activity; void notifyEnter() { @@ -1436,7 +1437,7 @@ uint8_t HomeScreen::channelIdxAt(uint8_t pos) { uint8_t HomeScreen::notifyRowCount() { switch (_notify_screen) { - case NOTIFY_QUIET: return 5; // Quiet hours / From / To / Timezone / Back + case NOTIFY_QUIET: return 4; // Quiet hours / From / To / Back case NOTIFY_CHANNELS: return (uint8_t)(channelCount() + 1); // каналы + Back default: return NOTIFY_MAIN_ROWS; } @@ -1448,7 +1449,15 @@ void HomeScreen::notifyStep(int8_t dir) { _notify_sel = (uint8_t)((_notify_sel + rows + dir) % rows); } -void HomeScreen::notifyValueStep(int8_t dir) { // правка часа тишины и часового пояса +void HomeScreen::notifyValueStep(int8_t dir) { // правка значения: часы тишины и часовой пояс + if (!_notify_val_edit) return; + if (_notify_screen == NOTIFY_MAIN && _notify_sel == NOTIFY_ROW_TZ) { // timezone, -12..+14 + int v = (int)_node_prefs->tz_offset + dir; + if (v < -12) v = -12; + if (v > 14) v = 14; + _node_prefs->tz_offset = (int8_t)v; + return; + } if (_notify_screen != NOTIFY_QUIET) return; if (_notify_sel == 1 || _notify_sel == 2) { int v = (int)(_notify_sel == 1 ? _node_prefs->quiet_from : _node_prefs->quiet_to) + dir; @@ -1456,11 +1465,6 @@ void HomeScreen::notifyValueStep(int8_t dir) { // правка часа тиш if (v < 0) v += 24; if (_notify_sel == 1) _node_prefs->quiet_from = (uint8_t)v; else _node_prefs->quiet_to = (uint8_t)v; - } else if (_notify_sel == 3) { // timezone, -12..+14 - int v = (int)_node_prefs->tz_offset + dir; - if (v < -12) v = -12; - if (v > 14) v = 14; - _node_prefs->tz_offset = (int8_t)v; } } @@ -1479,7 +1483,8 @@ void HomeScreen::notifyActivate() { // длинное нажатие case 2: _node_prefs->msg_wake_display = _node_prefs->msg_wake_display ? 0 : 1; return; case 3: alertsCycle(); return; case 4: _notify_screen = NOTIFY_CHANNELS; _notify_sel = 0; return; - case 5: _notify_screen = NOTIFY_QUIET; _notify_sel = 0; return; + case NOTIFY_ROW_TZ: _notify_val_edit = true; return; // часовой пояс: правка значения + case 6: _notify_screen = NOTIFY_QUIET; _notify_sel = 0; return; default: notifyLeave(true); return; // Save & exit } } @@ -1487,9 +1492,8 @@ void HomeScreen::notifyActivate() { // длинное нажатие switch (_notify_sel) { case 0: _node_prefs->quiet_en = _node_prefs->quiet_en ? 0 : 1; return; case 1: - case 2: - case 3: _notify_val_edit = true; return; // править час / часовой пояс - default: _notify_screen = NOTIFY_MAIN; _notify_sel = 5; return; // Back + case 2: _notify_val_edit = true; return; // править час + default: _notify_screen = NOTIFY_MAIN; _notify_sel = 6; return; // Back — на строку Quiet hours } } if (_notify_screen == NOTIFY_CHANNELS) { @@ -1512,14 +1516,13 @@ void HomeScreen::renderNotifyMenu(DisplayDriver& display) { display.setTextSize(1); if (_notify_screen == NOTIFY_QUIET) { - static const char* names[5] = { "Quiet hours", "From", "To", "Timezone", "Back" }; + static const char* names[4] = { "Quiet hours", "From", "To", "Back" }; int y = 2; - for (uint8_t r = 0; r < 5; r++, y += 10) { + for (uint8_t r = 0; r < 4; r++, y += 10) { val[0] = 0; if (r == 0) strcpy(val, _node_prefs->quiet_en ? "on" : "off"); else if (r == 1) snprintf(val, sizeof(val), "%02d:00", _node_prefs->quiet_from); else if (r == 2) snprintf(val, sizeof(val), "%02d:00", _node_prefs->quiet_to); - else if (r == 3) snprintf(val, sizeof(val), "%+03d", (int)_node_prefs->tz_offset); drawMenuRow(display, y, r == _notify_sel, names[r], val); } if (_notify_val_edit) { @@ -1558,11 +1561,14 @@ void HomeScreen::renderNotifyMenu(DisplayDriver& display) { // NOTIFY_MAIN static const char* labels[NOTIFY_MAIN_ROWS] = { - "Unread", "Popups", "Wake screen", "Alerts", "Channels", "Quiet hours", "Save & exit" + "Unread", "Popups", "Wake screen", "Alerts", "Channels", "Timezone", "Quiet hours", "Save & exit" }; static const char* alert_names[4] = { "sound+vibe", "sound", "vibe", "off" }; + // на узких экранах (128x64) все восемь строк не помещаются — список прокручивается + const uint8_t visible = display.height() >= 100 ? NOTIFY_MAIN_ROWS : 7; + uint8_t first = _notify_sel >= visible ? (uint8_t)(_notify_sel - visible + 1) : 0; int y = 1; - for (uint8_t r = 0; r < NOTIFY_MAIN_ROWS; r++, y += 9) { + for (uint8_t r = first; r < NOTIFY_MAIN_ROWS; r++, y += 9) { val[0] = 0; switch (r) { case 0: snprintf(val, sizeof(val), "%d", _task->getMsgCount()); break; @@ -1570,7 +1576,8 @@ void HomeScreen::renderNotifyMenu(DisplayDriver& display) { case 2: strcpy(val, _node_prefs->msg_wake_display ? "on" : "off"); break; case 3: strcpy(val, alert_names[alertsMode()]); break; case 4: snprintf(val, sizeof(val), "%d >", channelCount()); break; - case 5: + case NOTIFY_ROW_TZ: snprintf(val, sizeof(val), "UTC%+03d", (int)_node_prefs->tz_offset); break; + case 6: if (_node_prefs->quiet_en) snprintf(val, sizeof(val), "%02d-%02d", _node_prefs->quiet_from, _node_prefs->quiet_to); else strcpy(val, "off"); break; @@ -1578,6 +1585,10 @@ void HomeScreen::renderNotifyMenu(DisplayDriver& display) { } drawMenuRow(display, y, r == _notify_sel, labels[r], val); } + if (_notify_val_edit) { + display.setColor(UIColor::warning_txt); + display.drawTextCentered(display.width() / 2, display.height() - 10, "click+ dbl- hold=back"); + } } #ifndef UI_MSG_PREVIEW_SIZE