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
@@ -2180,6 +2180,23 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char*
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef PIN_BUZZER
|
||||
if (strcmp(command, "get buzzer") == 0) {
|
||||
sprintf(reply, "> %s", _prefs.buzzer_quiet ? "off" : "on");
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "set buzzer ", 11) == 0) {
|
||||
if (strcmp(&command[11], "on") == 0 || strcmp(&command[11], "off") == 0) {
|
||||
_prefs.buzzer_quiet = strcmp(&command[11], "off") == 0;
|
||||
savePrefs();
|
||||
strcpy(reply, "OK");
|
||||
} else {
|
||||
strcpy(reply, "Error: state must be on or off");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (memcmp(command, "set pin ", 8) == 0) {
|
||||
_prefs.ble_pin = atoi(&command[8]);
|
||||
savePrefs();
|
||||
@@ -2265,6 +2282,108 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char*
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#ifdef DISPLAY_CLASS
|
||||
if (memcmp(command, "set ui.show_clock", 17) == 0) {
|
||||
_prefs.ui_show_clock = atoi(&command[17]) ? 1 : 0;
|
||||
savePrefs();
|
||||
sprintf(reply, "> now %d", _prefs.ui_show_clock);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "set ui.auto_off_delay", 21) == 0) {
|
||||
_prefs.ui_auto_off_delay = atoi(&command[21]);
|
||||
savePrefs();
|
||||
sprintf(reply, "> now %d seconds", _prefs.ui_auto_off_delay);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "set ui.backlight_delay", 22) == 0) {
|
||||
_prefs.ui_backlight_delay = atoi(&command[22]);
|
||||
savePrefs();
|
||||
if (_prefs.ui_backlight_delay >= 0)
|
||||
sprintf(reply, "> now %d seconds", _prefs.ui_backlight_delay);
|
||||
else if (_prefs.ui_backlight_delay == -1)
|
||||
sprintf(reply, "> now always on (-1)");
|
||||
else
|
||||
sprintf(reply, "> now disabled (<-1)");
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "set ui.backlight_on_keys", 24) == 0) {
|
||||
_prefs.ui_backlight_on_keys = atoi(&command[24]);
|
||||
savePrefs();
|
||||
sprintf(reply, "> now %d", _prefs.ui_backlight_on_keys);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "set ui.backlight_on_msgs", 24) == 0) {
|
||||
_prefs.ui_backlight_on_msgs = atoi(&command[24]);
|
||||
savePrefs();
|
||||
sprintf(reply, "> now %d", _prefs.ui_backlight_on_msgs);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "set ui.auto_off_blank", 21) == 0) {
|
||||
_prefs.ui_auto_off_blank = atoi(&command[21]);
|
||||
savePrefs();
|
||||
sprintf(reply, "> now %d", _prefs.ui_auto_off_blank);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "set ui.auto_off_keep_msgs", 25) == 0) {
|
||||
_prefs.ui_auto_off_keep_msgs = atoi(&command[25]);
|
||||
savePrefs();
|
||||
sprintf(reply, "> now %d", _prefs.ui_auto_off_keep_msgs);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "set ui.max_partial", 18) == 0) {
|
||||
_prefs.ui_max_partial = atoi(&command[18]);
|
||||
savePrefs();
|
||||
sprintf(reply, "> now %d (applied at next screen wakeup)", _prefs.ui_max_partial);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "set ui.nd_name", 14) == 0) {
|
||||
_prefs.ui_nd_name = atoi(&command[14]);
|
||||
savePrefs();
|
||||
sprintf(reply, "> ui.nd_name is now %d", _prefs.ui_nd_name);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "get ui.show_clock", 17) == 0) {
|
||||
sprintf(reply, "> %d", _prefs.ui_show_clock);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "get ui.auto_off_delay", 21) == 0) {
|
||||
sprintf(reply, "> %d seconds", _prefs.ui_auto_off_delay);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "get ui.backlight_delay", 22) == 0) {
|
||||
if (_prefs.ui_backlight_delay >= 0)
|
||||
sprintf(reply, "> %d seconds", _prefs.ui_backlight_delay);
|
||||
else if (_prefs.ui_backlight_delay == -1)
|
||||
sprintf(reply, "> always on (-1)");
|
||||
else
|
||||
sprintf(reply, "> disabled (<-1)");
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "get ui.backlight_on_keys", 24) == 0) {
|
||||
sprintf(reply, "> %d", _prefs.ui_backlight_on_keys);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "get ui.backlight_on_msgs", 24) == 0) {
|
||||
sprintf(reply, "> %d", _prefs.ui_backlight_on_msgs);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "get ui.auto_off_blank", 21) == 0) {
|
||||
sprintf(reply, "> %d", _prefs.ui_auto_off_blank);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "get ui.auto_off_keep_msgs", 25) == 0) {
|
||||
sprintf(reply, "> %d", _prefs.ui_auto_off_keep_msgs);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "get ui.max_partial", 18) == 0) {
|
||||
sprintf(reply, "> %d", _prefs.ui_max_partial);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "get ui.nd_name", 14) == 0) {
|
||||
sprintf(reply, "> %d", _prefs.ui_nd_name);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false; // not handled
|
||||
}
|
||||
|
||||
@@ -58,6 +58,34 @@ public:
|
||||
// use ssid from prefs, or fallback to ssid from build flags
|
||||
const char* getWifiSSID() const { return wifi_ssid[0] ? wifi_ssid : WIFI_SSID; }
|
||||
#endif
|
||||
#ifdef DISPLAY_CLASS
|
||||
#ifndef UI_SHOW_CLOCK
|
||||
#define UI_SHOW_CLOCK 0
|
||||
#endif
|
||||
#ifndef AUTO_OFF_MILLIS
|
||||
#define AUTO_OFF_MILLIS 15000
|
||||
#endif
|
||||
#ifndef EINK_MAX_PARTIAL_REFRESH
|
||||
#define EINK_MAX_PARTIAL_REFRESH 0
|
||||
#endif
|
||||
uint8_t ui_show_clock = UI_SHOW_CLOCK;
|
||||
uint32_t ui_auto_off_delay = AUTO_OFF_MILLIS / 1000;
|
||||
int32_t ui_backlight_delay = 5;
|
||||
#if defined(BACKLIGHT_BTN)
|
||||
uint8_t ui_backlight_on_keys = 0;
|
||||
#else
|
||||
uint8_t ui_backlight_on_keys = 1;
|
||||
#endif
|
||||
uint8_t ui_backlight_on_msgs = 0;
|
||||
#ifdef UI_SCREENOFF_BLANK
|
||||
uint8_t ui_auto_off_blank = 1;
|
||||
#else
|
||||
uint8_t ui_auto_off_blank = 0;
|
||||
#endif
|
||||
uint8_t ui_auto_off_keep_msgs = 1;
|
||||
uint8_t ui_max_partial = EINK_MAX_PARTIAL_REFRESH;
|
||||
uint8_t ui_nd_name = 1;
|
||||
#endif
|
||||
|
||||
private:
|
||||
class RadioPrefs : public CommonRadioPrefs {
|
||||
@@ -189,6 +217,27 @@ private:
|
||||
WiFiPrefs wifi;
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
class UI_Prefs : public ConfigSerializer {
|
||||
NodePrefs* _parent;
|
||||
protected:
|
||||
void structure() override {
|
||||
def("show_clock", _parent->ui_show_clock);
|
||||
def("auto_off", _parent->ui_auto_off_delay);
|
||||
def("bl_dly", _parent->ui_backlight_delay);
|
||||
def("bl_keys", _parent->ui_backlight_on_keys);
|
||||
def("bl_msgs", _parent->ui_backlight_on_msgs);
|
||||
def("max_partial", _parent->ui_max_partial);
|
||||
def("off_blank", _parent->ui_auto_off_blank);
|
||||
def("off_keep_msgs", _parent->ui_auto_off_keep_msgs);
|
||||
def("nd_name", _parent->ui_nd_name);
|
||||
}
|
||||
public:
|
||||
UI_Prefs(NodePrefs* parent) : _parent(parent) {}
|
||||
};
|
||||
UI_Prefs ui;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void structure() override {
|
||||
def("name", node_name, sizeof(node_name));
|
||||
@@ -203,12 +252,18 @@ protected:
|
||||
def("custom", custom);
|
||||
#ifdef ENABLE_WIFI_INTERFACE
|
||||
def("wifi", wifi);
|
||||
#endif
|
||||
#ifdef DISPLAY_CLASS
|
||||
def("ui", ui);
|
||||
#endif
|
||||
}
|
||||
public:
|
||||
NodePrefs() : radio(this), gps(this), companion(this), custom(&radio)
|
||||
#ifdef ENABLE_WIFI_INTERFACE
|
||||
, wifi(this)
|
||||
#endif
|
||||
#ifdef DISPLAY_CLASS
|
||||
, ui(this)
|
||||
#endif
|
||||
{
|
||||
node_name[0] = 0;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -62,7 +62,7 @@ class UITask : public AbstractUITask {
|
||||
int _msgcount;
|
||||
unsigned long ui_started_at, next_batt_chck;
|
||||
unsigned long next_backlight_btn_check = 0;
|
||||
unsigned long backlight_btn_pressed_at = 0;
|
||||
unsigned long _backlight_off = 0;
|
||||
#ifdef PIN_STATUS_LED
|
||||
int led_state = 0;
|
||||
int next_led_change = 0;
|
||||
|
||||
@@ -485,6 +485,7 @@ void UITask::loop() {
|
||||
userLedHandler();
|
||||
|
||||
#ifdef PIN_BUZZER
|
||||
if (buzzer.isQuiet() != (bool)_node_prefs->buzzer_quiet) buzzer.quiet(_node_prefs->buzzer_quiet);
|
||||
if (buzzer.isPlaying()) buzzer.loop();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -691,6 +691,7 @@ void UITask::loop() {
|
||||
userLedHandler();
|
||||
|
||||
#ifdef PIN_BUZZER
|
||||
if (buzzer.isQuiet() != (bool)_node_prefs->buzzer_quiet) buzzer.quiet(_node_prefs->buzzer_quiet);
|
||||
if (buzzer.isPlaying()) buzzer.loop();
|
||||
#endif
|
||||
|
||||
|
||||
Reference in new issue
Block a user