Merge upstream/dev (11 commits) [upstream-sync]
Conflict in examples/companion_radio/ui-new/UITask.cpp: upstream replaced UI_SHOW_CLOCK with the runtime pref ui_show_clock; kept that and our BLE pin condition (shown only while Bluetooth is enabled). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
fd04fdf093
15 files changed
+818
-139
No files matched your search
@@ -122,7 +122,6 @@ class HomeScreen : public UIScreen {
|
||||
uint32_t disc_node_req_tag = 0;
|
||||
uint32_t disc_nodes_count = 0;
|
||||
uint32_t discovery_req_time = 0;
|
||||
bool discovery_disp_names = true; // by default desplay names if available (removes SNR_O)
|
||||
#endif
|
||||
|
||||
void renderBatteryIndicator(DisplayDriver& display, uint16_t batteryMilliVolts) {
|
||||
@@ -293,17 +292,17 @@ public:
|
||||
sprintf(tmp, "MSG: %d", _task->getMsgCount());
|
||||
display.drawTextCentered(display.width() / 2, 22, tmp);
|
||||
#endif
|
||||
#ifdef UI_SHOW_CLOCK
|
||||
display.setTextSize(3);
|
||||
uint32_t now = _rtc->getCurrentTime();
|
||||
now += (int32_t)(_node_prefs->tz_offset * 3600);
|
||||
DateTime dt (now);
|
||||
sprintf(tmp, "%02d:%02d", dt.hour(), dt.minute());
|
||||
display.drawTextCentered(display.width() / 2, 60, tmp);
|
||||
display.setTextSize(1);
|
||||
sprintf(tmp, "%02d/%02d/%d", dt.day(), dt.month(), dt.year());
|
||||
display.drawTextCentered(display.width() / 2, 80, tmp);
|
||||
#endif
|
||||
if (_node_prefs->ui_show_clock) {
|
||||
display.setTextSize(3);
|
||||
uint32_t now = _rtc->getCurrentTime();
|
||||
now += (int32_t)(_node_prefs->tz_offset * 3600);
|
||||
DateTime dt (now);
|
||||
sprintf(tmp, "%02d:%02d", dt.hour(), dt.minute());
|
||||
display.drawTextCentered(display.width() / 2, 60, tmp);
|
||||
display.setTextSize(1);
|
||||
sprintf(tmp, "%02d/%02d/%d", dt.day(), dt.month(), dt.year());
|
||||
display.drawTextCentered(display.width() / 2, 80, tmp);
|
||||
}
|
||||
#ifdef ENABLE_WIFI_INTERFACE
|
||||
IPAddress ip = WiFi.localIP();
|
||||
snprintf(tmp, sizeof(tmp), "IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
@@ -313,23 +312,22 @@ public:
|
||||
if (_task->hasConnection()) {
|
||||
display.setColor(UIColor::warning_txt);
|
||||
display.setTextSize(1);
|
||||
#ifdef UI_SHOW_CLOCK
|
||||
display.drawTextCentered(display.width() / 2, 110, "< Connected >");
|
||||
#else
|
||||
display.drawTextCentered(display.width() / 2, 43, "< Connected >");
|
||||
#endif
|
||||
if (_node_prefs->ui_show_clock)
|
||||
display.drawTextCentered(display.width() / 2, 110, "< Connected >");
|
||||
else
|
||||
display.drawTextCentered(display.width() / 2, 43, "< Connected >");
|
||||
// CUSTOM (TeTeHacko): jen kdyz BT opravdu bezi -- jinak displej nabizi PIN
|
||||
// k parovani, ktere neni jak navazat.
|
||||
} else if (the_mesh.getBLEPin() != 0 && _task->isBluetoothEnabled()) { // BT pin
|
||||
display.setColor(UIColor::warning_txt);
|
||||
sprintf(tmp, "Pin:%d", the_mesh.getBLEPin());
|
||||
#ifdef UI_SHOW_CLOCK
|
||||
display.setTextSize(1);
|
||||
display.drawTextCentered(display.width() / 2, 110, tmp);
|
||||
#else
|
||||
display.setTextSize(2);
|
||||
display.drawTextCentered(display.width() / 2, 43, tmp);
|
||||
#endif
|
||||
if (_node_prefs->ui_show_clock) {
|
||||
display.setTextSize(1);
|
||||
display.drawTextCentered(display.width() / 2, 110, tmp);
|
||||
} else {
|
||||
display.setTextSize(2);
|
||||
display.drawTextCentered(display.width() / 2, 43, tmp);
|
||||
}
|
||||
}
|
||||
} else if (_page == HomePage::RECENT) {
|
||||
the_mesh.getRecentlyHeard(recent, UI_RECENT_LIST_SIZE);
|
||||
@@ -520,7 +518,7 @@ public:
|
||||
for (int i = 0; i < count; i++, y += 11) {
|
||||
char name[32];
|
||||
auto a = &discovered[i];
|
||||
if ((a->name[0] == 0) || !discovery_disp_names) {
|
||||
if ((a->name[0] == 0) || !_node_prefs->ui_nd_name) {
|
||||
mesh::Utils::toHex(name, a->pubkey_prefix, 4);
|
||||
} else {
|
||||
strncpy(name, a->name, 32);
|
||||
@@ -620,7 +618,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
if (c == KEY_SELECT && _page == HomePage::DISCOVERY) {
|
||||
discovery_disp_names = !discovery_disp_names;
|
||||
_node_prefs->ui_nd_name = !_node_prefs->ui_nd_name;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
@@ -728,7 +726,6 @@ public:
|
||||
void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs) {
|
||||
_display = display;
|
||||
_sensors = sensors;
|
||||
_auto_off = millis() + AUTO_OFF_MILLIS;
|
||||
|
||||
#if defined(PIN_USER_BTN)
|
||||
user_btn.begin();
|
||||
@@ -741,9 +738,11 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
|
||||
#endif
|
||||
|
||||
_node_prefs = node_prefs;
|
||||
_auto_off = millis() + _node_prefs->ui_auto_off_delay * 1000;
|
||||
_backlight_off = millis() + _node_prefs->ui_backlight_delay * 1000;
|
||||
|
||||
if (_display != NULL) {
|
||||
_display->turnOn();
|
||||
_display->turnOn(_node_prefs->ui_max_partial);
|
||||
}
|
||||
|
||||
#ifdef PIN_BUZZER
|
||||
@@ -809,11 +808,14 @@ void UITask::onMessageRecv(mesh::Packet *pkt, const ContactInfo &from, uint8_t t
|
||||
|
||||
if (_display != NULL) {
|
||||
if (!_display->isOn() && !hasConnection()) {
|
||||
_display->turnOn();
|
||||
_display->turnOn(_node_prefs->ui_max_partial);
|
||||
}
|
||||
if (_display->isOn()) {
|
||||
_auto_off = millis() + AUTO_OFF_MILLIS; // extend the auto-off timer
|
||||
_next_refresh = 100; // trigger refresh
|
||||
_auto_off = millis() + _node_prefs->ui_auto_off_delay * 1000; // extend the auto-off timer
|
||||
_next_refresh = 100; // trigger refresh
|
||||
if (_node_prefs->ui_backlight_on_msgs) {
|
||||
_backlight_off = millis() + _node_prefs->ui_backlight_delay * 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -829,10 +831,10 @@ void UITask::onChannelMessageRecv(mesh::Packet *pkt, ChannelDetails& channel_det
|
||||
|
||||
if (_display != NULL) {
|
||||
if (!_display->isOn() && !hasConnection()) {
|
||||
_display->turnOn();
|
||||
_display->turnOn(_node_prefs->ui_max_partial);
|
||||
}
|
||||
if (_display->isOn()) {
|
||||
_auto_off = millis() + AUTO_OFF_MILLIS; // extend the auto-off timer
|
||||
_auto_off = millis() + _node_prefs->ui_auto_off_delay * 1000; // extend the auto-off timer
|
||||
_next_refresh = 100; // trigger refresh
|
||||
}
|
||||
}
|
||||
@@ -911,9 +913,7 @@ void UITask::shutdown(bool restart){
|
||||
_board->reboot();
|
||||
} else {
|
||||
if (_display->isEink()) {
|
||||
_display->blankScreen();
|
||||
_display->turnOff();
|
||||
_display->powerOff();
|
||||
_display->turnOff(true);
|
||||
}
|
||||
// Power off board including radio, display, GPS and components
|
||||
_board->powerOff();
|
||||
@@ -959,9 +959,7 @@ void UITask::loop() {
|
||||
if (ev == BUTTON_EVENT_CLICK) {
|
||||
c = checkDisplayOn(KEY_ENTER);
|
||||
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
|
||||
display.blankScreen();
|
||||
display.turnOff();
|
||||
display.powerOff();
|
||||
display.turnOff(true);
|
||||
} else if (ev == BUTTON_EVENT_DOUBLE_CLICK) {
|
||||
c = handleDoubleClick(KEY_SELECT);
|
||||
} else if (ev == BUTTON_EVENT_TRIPLE_CLICK) {
|
||||
@@ -981,11 +979,11 @@ void UITask::loop() {
|
||||
#endif
|
||||
#if defined(UI_HAS_ROTARY_INPUT)
|
||||
RotaryInputEvent rotaryEv = rotary_input.poll();
|
||||
if (c == 0 && _display != NULL && _display->isOn()) {
|
||||
if (c == 0 && _display != NULL) {
|
||||
if (rotaryEv == RotaryInputEvent::Next) {
|
||||
c = KEY_NEXT;
|
||||
c = checkDisplayOn(KEY_NEXT);
|
||||
} else if (rotaryEv == RotaryInputEvent::Prev) {
|
||||
c = KEY_PREV;
|
||||
c = checkDisplayOn(KEY_PREV);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1004,45 +1002,59 @@ void UITask::loop() {
|
||||
_analogue_pin_read_millis = millis();
|
||||
}
|
||||
#endif
|
||||
#if defined(DISP_BACKLIGHT) || defined(EXP_PIN_BACKLIGHT)
|
||||
#if defined(BACKLIGHT_BTN)
|
||||
if (millis() > next_backlight_btn_check) {
|
||||
if (backlight_btn.isPressed()) {
|
||||
if (!_display->isOn()) {
|
||||
_display->turnOn();
|
||||
_display->turnOn(_node_prefs->ui_max_partial);
|
||||
_next_refresh = 0;
|
||||
}
|
||||
_auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer
|
||||
backlight_btn_pressed_at = millis(); // still pressed
|
||||
_auto_off = millis() + _node_prefs->ui_auto_off_delay * 1000; // extend auto-off timer
|
||||
_backlight_off = millis() + _node_prefs->ui_backlight_delay * 1000; // extend auto_off for backlight
|
||||
}
|
||||
bool touch_state = (millis() - backlight_btn_pressed_at > 5000);
|
||||
// Backlight button events
|
||||
int bev = backlight_btn.check();
|
||||
if (bev == BUTTON_EVENT_DOUBLE_CLICK) {
|
||||
_display->forceFullRefresh();
|
||||
} else if (bev == BUTTON_EVENT_TRIPLE_CLICK) {
|
||||
_display->blankScreen();
|
||||
_display->turnOff();
|
||||
_display->powerOff();
|
||||
backlight_btn_pressed_at = 0;
|
||||
}
|
||||
#if defined(DISP_BACKLIGHT)
|
||||
digitalWrite(DISP_BACKLIGHT, !touch_state);
|
||||
#elif defined(EXP_PIN_BACKLIGHT)
|
||||
expander.digitalWrite(EXP_PIN_BACKLIGHT, !touch_state);
|
||||
#endif
|
||||
next_backlight_btn_check = millis() + 100;
|
||||
}
|
||||
int bev = backlight_btn.check();
|
||||
if (bev == BUTTON_EVENT_DOUBLE_CLICK) {
|
||||
_display->forceFullRefresh();
|
||||
} else if (bev == BUTTON_EVENT_TRIPLE_CLICK) {
|
||||
_display->turnOff(true);
|
||||
_backlight_off = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool backlight_state;
|
||||
if (_node_prefs->ui_backlight_delay == -1) {
|
||||
backlight_state = true;
|
||||
} else if (_node_prefs->ui_backlight_delay < -1) {
|
||||
backlight_state = false;
|
||||
} else if (_node_prefs->ui_backlight_delay == 0) {
|
||||
backlight_state = false;
|
||||
#ifdef BACKLIGHT_BTN
|
||||
backlight_state = backlight_btn.isPressed();
|
||||
#endif
|
||||
} else {
|
||||
backlight_state = (millis() < _backlight_off);
|
||||
}
|
||||
|
||||
#if defined(DISP_BACKLIGHT)
|
||||
digitalWrite(DISP_BACKLIGHT, backlight_state);
|
||||
#elif defined(EXP_PIN_BACKLIGHT)
|
||||
expander.digitalWrite(EXP_PIN_BACKLIGHT, backlight_state);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (c != 0 && curr) {
|
||||
curr->handleInput(c);
|
||||
_auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer
|
||||
_auto_off = millis() + _node_prefs->ui_auto_off_delay * 1000; // extend auto-off timer
|
||||
_next_refresh = 100; // trigger refresh
|
||||
}
|
||||
|
||||
userLedHandler();
|
||||
|
||||
#ifdef PIN_BUZZER
|
||||
if (buzzer.isQuiet() != (bool)_node_prefs->buzzer_quiet) buzzer.quiet(_node_prefs->buzzer_quiet);
|
||||
if (buzzer.isPlaying()) buzzer.loop();
|
||||
#endif
|
||||
|
||||
@@ -1067,26 +1079,27 @@ void UITask::loop() {
|
||||
}
|
||||
_display->endFrame();
|
||||
}
|
||||
#if AUTO_OFF_MILLIS > 0
|
||||
if (_node_prefs->ui_auto_off_delay > 0) {
|
||||
#ifdef KEEP_DISPLAY_ON_USB
|
||||
// Opt-in: refresh the auto-off deadline while externally powered, so the
|
||||
// timer counts from the moment external power is removed. Off by default
|
||||
// because OLED panels burn in quickly; only enable for LCD targets or
|
||||
// where the display is replaceable.
|
||||
if (board.isExternalPowered()) {
|
||||
_auto_off = millis() + AUTO_OFF_MILLIS;
|
||||
}
|
||||
// Opt-in: refresh the auto-off deadline while externally powered, so the
|
||||
// timer counts from the moment external power is removed. Off by default
|
||||
// because OLED panels burn in quickly; only enable for LCD targets or
|
||||
// where the display is replaceable.
|
||||
if (board.isExternalPowered()) {
|
||||
_auto_off = millis() + _node_prefs->ui_auto_off_delay * 1000;
|
||||
}
|
||||
#endif
|
||||
if (millis() > _auto_off) {
|
||||
#ifdef EINK_SCREENOFF_BLANK
|
||||
if (curr != msg_preview) { // don't blank if messages are waiting
|
||||
_display->blankScreen();
|
||||
_display->powerOff();
|
||||
if (millis() > _auto_off) {
|
||||
if (_node_prefs->ui_auto_off_blank &&
|
||||
!(_node_prefs->ui_auto_off_keep_msgs
|
||||
&& curr == msg_preview)) {
|
||||
// don't blank if messages are waiting
|
||||
_display->turnOff(true);
|
||||
} else {
|
||||
_display->turnOff();
|
||||
}
|
||||
#endif
|
||||
_display->turnOff();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PIN_VIBRATION
|
||||
@@ -1118,10 +1131,13 @@ void UITask::loop() {
|
||||
char UITask::checkDisplayOn(char c) {
|
||||
if (_display != NULL) {
|
||||
if (!_display->isOn()) {
|
||||
_display->turnOn(); // turn display on and consume event
|
||||
_display->turnOn(_node_prefs->ui_max_partial); // turn display on and consume event
|
||||
c = 0;
|
||||
}
|
||||
_auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer
|
||||
_auto_off = millis() + _node_prefs->ui_auto_off_delay * 1000; // extend auto-off timer
|
||||
if (_node_prefs->ui_backlight_on_keys) {
|
||||
_backlight_off = millis() + _node_prefs->ui_backlight_delay * 1000;
|
||||
}
|
||||
_next_refresh = 0; // trigger refresh
|
||||
}
|
||||
return c;
|
||||
|
||||
Reference in new issue
Block a user