feat(ui): page radio and system status

This commit is contained in:
mikecarper committed 2026-09-21 15:35:46 -07:00
1 parent 653578c818
commit b089b745fa
28 files changed
+2075 -73

No files matched your search

+511 -18
View File
@@ -5,6 +5,261 @@
#include <helpers/CommonCLI.h>
#include <helpers/ui/WiFiSetupQrDisplay.h>
#include <helpers/ui/CompanionHomeLayout.h>
#include <helpers/ui/RadioProfileDisplayPage.h>
#include <RadioProfiles.h>
#include <Utils.h>
#include "MyMesh.h"
extern MyMesh the_mesh;
namespace {
const mesh::RadioProfiles* configuredRadioProfiles() {
const auto* radio = the_mesh.getProfileRadio();
return radio ? radio->profiles() : NULL;
}
const char* secondaryRadioProfileTag() {
const auto* profiles = configuredRadioProfiles();
return mesh::ui::radioProfileDisplayTag(true,
profiles != NULL && profiles->secondary_temporary);
}
// The complete system-status view needs four rows on a single-radio node and
// two more when radio2 is configured. Grouping related switches keeps a
// normal 128x64 OLED to one status page (rather than silently dropping the
// lower rows), while the measured page count below naturally splits this on
// a genuinely short display.
constexpr uint8_t RADIO_SYSTEM_STATUS_ROWS = 8;
constexpr uint8_t RADIO_SYSTEM_STATUS_ROWS_WITHOUT_RADIO2 = 5;
uint8_t radioSystemStatusRowsPerPage(DisplayDriver& display) {
const int line_height = display.textLineHeight();
if (line_height <= 0) return 1;
const int row_height = line_height + 2;
const int rows = (display.height() + 2) / row_height;
return rows > 0 ? rows : 1;
}
uint8_t radioSystemStatusPageCount(DisplayDriver& display,
bool dual_radio_enabled) {
const uint8_t row_count = dual_radio_enabled ? RADIO_SYSTEM_STATUS_ROWS
: RADIO_SYSTEM_STATUS_ROWS_WITHOUT_RADIO2;
const uint8_t rows_per_page = radioSystemStatusRowsPerPage(display);
return (row_count + rows_per_page - 1) / rows_per_page;
}
int drawRadioStatusState(DisplayDriver& display, int x, int y,
const char* label, bool enabled) {
const char* state = enabled ? "ON" : "OFF";
display.setColor(UIColor::primary_txt);
display.setCursor(x, y);
display.print(label);
x += display.getTextWidth(label);
display.setColor(enabled ? UIColor::primary_txt : UIColor::warning_txt);
display.setCursor(x, y);
display.print(state);
return x + display.getTextWidth(state);
}
void drawRadioStatusPair(DisplayDriver& display, int y,
const char* first_label, bool first_enabled,
const char* second_label, bool second_enabled) {
int x = drawRadioStatusState(display, 0, y, first_label, first_enabled);
drawRadioStatusState(display, x + display.getTextWidth(" "), y,
second_label, second_enabled);
display.setColor(UIColor::primary_txt);
}
void formatRadioNoiseFloor(char* noise_floor, size_t size, const char* label,
uint8_t profile = 0) {
const float dbm = radio_driver.getNoiseFloorDbm(profile);
if (dbm == 0.0f) {
const float seconds = radio_driver.getNoiseFloorCalibrationSecondsRemaining(profile);
if (seconds > 0.0f) {
snprintf(noise_floor, size, "%s:%.1fs", label, seconds);
} else {
snprintf(noise_floor, size, "%s:WAIT", label);
}
} else {
snprintf(noise_floor, size, "%s:%.1f", label, dbm);
}
}
void drawRadioNoiseFloor(DisplayDriver& display, int y, const char* label,
uint8_t profile = 0) {
char noise_floor[12];
formatRadioNoiseFloor(noise_floor, sizeof(noise_floor), label, profile);
display.setColor(UIColor::primary_txt);
display.setCursor(0, y);
display.print(noise_floor);
}
void drawRadioSystemStatusPage(DisplayDriver& display, const NodePrefs& prefs,
uint8_t status_page_index) {
display.setTextSize(1);
const auto* profiles = configuredRadioProfiles();
const bool dual_radio = profiles != NULL && profiles->enabled();
const uint8_t rows_per_page = radioSystemStatusRowsPerPage(display);
const uint8_t first_row = status_page_index * rows_per_page;
const uint8_t row_count = dual_radio ? RADIO_SYSTEM_STATUS_ROWS
: RADIO_SYSTEM_STATUS_ROWS_WITHOUT_RADIO2;
const int row_height = display.textLineHeight() + 2;
for (uint8_t row = first_row; row < row_count
&& row < first_row + rows_per_page; ++row) {
const int y = (row - first_row) * row_height;
switch (row) {
case 0: {
char identity_prefix[7];
mesh::Utils::toHex(identity_prefix, the_mesh.getSelfId().pub_key, 3);
display.setColor(UIColor::primary_txt);
display.setCursor(0, y);
display.print("ID:");
display.print(identity_prefix);
break;
}
case 1:
#if ENV_INCLUDE_GPS == 1
drawRadioStatusPair(display, y, "PS:", prefs.powersaving_enabled != 0,
"GPS:", prefs.gps_enabled != 0);
#else
drawRadioStatusPair(display, y, "PS:", prefs.powersaving_enabled != 0,
"GPS:", false);
#endif
break;
case 2:
drawRadioStatusPair(display, y, "FEM:",
board.canControlLoRaFemLna() && board.isLoRaFemLnaEnabled(),
"RXB:", prefs.rx_boosted_gain != 0);
break;
case 3:
drawRadioStatusPair(display, y, "RXPS:", prefs.rx_powersaving_enabled != 0,
"CAD:", prefs.cad_enabled != 0);
break;
case 4: {
char mode[10];
snprintf(mode, sizeof(mode), "%s:%s", secondaryRadioProfileTag(),
profiles->secondary.mode == mesh::RadioProfileMode::RxTx ? "RXTX" : "RX");
display.setColor(UIColor::primary_txt);
display.setCursor(0, y);
display.print(mode);
break;
}
case 5: {
const char* cross = profiles->cross == mesh::RadioCrossMode::On ? "X:ON"
: profiles->cross == mesh::RadioCrossMode::Off ? "X:OFF" : "X:AUTO";
display.setColor(UIColor::primary_txt);
display.setCursor(0, y);
display.print(cross);
break;
}
case 6:
drawRadioNoiseFloor(display, y, "N1", 0);
break;
case 7:
drawRadioNoiseFloor(display, y, "N2", 1);
break;
}
}
display.setColor(UIColor::primary_txt);
}
#if defined(HELTEC_T096)
// The native T096 canvas is 160x80. Compact F/B/S/C rows use the first 108
// pixels; this leaves a 50px status column plus a 2px right margin. The
// widest normal 6x8 label, "RXPS:OFF", is 48px, so it has a 2px buffer.
constexpr int T096_STATUS_PANEL_WIDTH = 50;
constexpr int T096_STATUS_RIGHT_MARGIN = 2;
constexpr int T096_STATUS_TOP = 10;
constexpr int T096_STATUS_LINE_HEIGHT = 10;
void drawT096State(DisplayDriver& display, int x, int y,
const char* label, bool enabled) {
const char* state = enabled ? "ON" : "OFF";
display.setColor(UIColor::primary_txt);
display.setCursor(x, y);
display.print(label);
display.setColor(enabled ? UIColor::primary_txt : UIColor::warning_txt);
display.setCursor(x + display.getTextWidth(label), y);
display.print(state);
}
void drawT096StatusRow(DisplayDriver& display, int y,
const char* name, bool enabled) {
char label[8]; // "RXPS:" plus its terminator
snprintf(label, sizeof(label), "%s:", name);
const char* state = enabled ? "ON" : "OFF";
const int x = display.width() - T096_STATUS_RIGHT_MARGIN
- display.getTextWidth(label) - display.getTextWidth(state);
drawT096State(display, x, y, label, enabled);
}
void drawT096NoiseFloorRow(DisplayDriver& display, int y, uint8_t profile) {
char noise_floor[12];
const bool dual_radio = the_mesh.isDualRadioActive();
const char* label = dual_radio ? (profile == 1 ? "N2" : "N1") : "N";
// "N1:-120.0" needs 54px in the normal 6px font. On this final line the
// left side contains only the short cross-mode marker, so it may safely use
// four pixels of the otherwise empty gutter while retaining decimal dBm.
formatRadioNoiseFloor(noise_floor, sizeof(noise_floor), label, profile);
display.setColor(UIColor::primary_txt);
display.setCursor(display.width() - T096_STATUS_RIGHT_MARGIN
- display.getTextWidth(noise_floor), y);
display.print(noise_floor);
}
void drawT096StatusPanel(DisplayDriver& display, const NodePrefs& prefs,
uint8_t profile) {
// This is the ST7735 driver's standard 6x8 font, rather than Squeezed6.
display.setTextSize(1);
int y = T096_STATUS_TOP;
#if ENV_INCLUDE_GPS == 1
drawT096StatusRow(display, y, "GPS", prefs.gps_enabled != 0);
#else
drawT096StatusRow(display, y, "GPS", false);
#endif
y += T096_STATUS_LINE_HEIGHT;
drawT096StatusRow(display, y, "FEM", board.canControlLoRaFemLna()
&& board.isLoRaFemLnaEnabled());
y += T096_STATUS_LINE_HEIGHT;
drawT096StatusRow(display, y, "RXB", prefs.rx_boosted_gain != 0);
y += T096_STATUS_LINE_HEIGHT;
drawT096StatusRow(display, y, "RXPS", prefs.rx_powersaving_enabled != 0);
// A configured secondary profile keeps both profiles live; show it only
// when it exists, so the panel does not imply a second radio on every T096.
if (the_mesh.isDualRadioActive()) {
y += T096_STATUS_LINE_HEIGHT;
drawT096StatusRow(display, y, secondaryRadioProfileTag(), true);
}
y += T096_STATUS_LINE_HEIGHT;
drawT096StatusRow(display, y, "CAD", prefs.cad_enabled != 0);
y += T096_STATUS_LINE_HEIGHT;
drawT096NoiseFloorRow(display, y, profile);
display.setColor(UIColor::primary_txt);
}
void drawT096Radio2Details(DisplayDriver& display, int mode_y, int cross_y) {
const auto* profiles = configuredRadioProfiles();
if (profiles == NULL || !profiles->enabled()) return;
char mode[10];
snprintf(mode, sizeof(mode), "%s:%s", secondaryRadioProfileTag(),
profiles->secondary.mode == mesh::RadioProfileMode::RxTx ? "RXTX" : "RX");
const char* cross = profiles->cross == mesh::RadioCrossMode::On ? "X:ON"
: profiles->cross == mesh::RadioCrossMode::Off ? "X:OFF" : "X:AUTO";
display.setColor(UIColor::primary_txt);
display.setCursor(0, mode_y);
display.print(mode);
display.setCursor(0, cross_y);
display.print(cross);
}
#endif // HELTEC_T096
} // namespace
#ifdef DISPLAY_REDRAW_ON_CHANGE
#include <helpers/ui/DisplayFrameSignature.h>
@@ -77,6 +332,7 @@ void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* fi
_prevBtnState = HIGH;
_started_at = millis();
_node_prefs = node_prefs;
resetRadioProfileDisplayPage();
#ifdef DISPLAY_ACTIVITY_DASHBOARD
ObserverDashboard::applyDarkPalette(); // retunes UIColor for this target only
#endif
@@ -106,6 +362,56 @@ void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* fi
free(version);
}
void UITask::resetRadioProfileDisplayPage() {
_radio_profile_display_page = 0;
_dual_radio_enabled_seen = the_mesh.isDualRadioActive();
}
uint8_t UITask::currentRadioProfileDisplayPage() {
const bool dual_radio_enabled = the_mesh.isDualRadioActive();
if (dual_radio_enabled != _dual_radio_enabled_seen) {
_dual_radio_enabled_seen = dual_radio_enabled;
_radio_profile_display_page = 0;
}
return mesh::ui::radioProfileManualPageIndex(dual_radio_enabled,
radioProfileSystemStatusPageCount(), _radio_profile_display_page);
}
void UITask::advanceRadioProfileDisplayPage() {
const bool dual_radio_enabled = the_mesh.isDualRadioActive();
const uint8_t page_count = mesh::ui::radioProfileDisplayPageCount(
dual_radio_enabled, radioProfileSystemStatusPageCount());
_radio_profile_display_page = (currentRadioProfileDisplayPage() + 1) % page_count;
_next_refresh = 0;
#ifdef DISPLAY_REDRAW_ON_CHANGE
_frame_valid = false;
#endif
#ifdef DISPLAY_ACTIVITY_DASHBOARD
_rows_valid = false;
#endif
}
bool UITask::showingSecondaryRadioProfilePage() {
return mesh::ui::showManualSecondaryRadioProfilePage(the_mesh.isDualRadioActive(),
currentRadioProfileDisplayPage());
}
uint8_t UITask::radioProfileSystemStatusPageCount() const {
#if defined(HELTEC_T096)
// The T096's dedicated 50px status column already shows every switch.
return 0;
#else
_display->setTextSize(1);
return radioSystemStatusPageCount(*_display, the_mesh.isDualRadioActive());
#endif
}
bool UITask::showingRadioProfileSystemStatusPage(uint8_t* status_page_index) {
return mesh::ui::showManualRadioProfileSystemStatusPage(the_mesh.isDualRadioActive(),
radioProfileSystemStatusPageCount(), currentRadioProfileDisplayPage(),
status_page_index);
}
void UITask::renderCurrScreen() {
char tmp[80];
#ifdef DISPLAY_ACTIVITY_DASHBOARD
@@ -192,23 +498,85 @@ void UITask::renderCurrScreen() {
return;
}
#endif
uint8_t status_page_index = 0;
if (showingRadioProfileSystemStatusPage(&status_page_index)) {
drawRadioSystemStatusPage(*_display, *_node_prefs, status_page_index);
return;
}
#ifdef DISPLAY_ACTIVITY_DASHBOARD
renderDashboard();
return;
#endif
// Reserve a full measured font-height for each row on OLED/TFT/e-paper.
mesh::ui::BoundedTextRows rows(*_display,
{0, 0, _display->width(), _display->height()});
#if defined(HELTEC_T096)
// Never let normal full-size rows overwrite the dedicated normal-font
// column at the right of the native 160x80 T096 screen.
const int content_width = _display->width() - T096_STATUS_PANEL_WIDTH
- T096_STATUS_RIGHT_MARGIN;
#else
const int content_width = _display->width();
#endif
_display->setTextSize(1);
_display->setColor(UIColor::primary_txt);
#if defined(HELTEC_T096)
// The name gets the entire top row. The status strip begins below it, so
// no part of the name is covered or forced into a second line.
_display->drawTextEllipsized(0, 0, _display->width(), _node_prefs->node_name);
const int rows_top = T096_STATUS_TOP;
mesh::ui::BoundedTextRows rows(*_display,
{0, rows_top, content_width, _display->height() - rows_top});
#else
mesh::ui::BoundedTextRows rows(*_display,
{0, 0, content_width, _display->height()});
rows.draw(_node_prefs->node_name, false);
#endif
// freq / sf
sprintf(tmp, "FREQ: %06.3f SF%d", _node_prefs->freq, _node_prefs->sf);
const mesh::RadioProfiles* profiles = configuredRadioProfiles();
const bool secondary_page = showingSecondaryRadioProfilePage();
const bool dual_radio = profiles != NULL && profiles->enabled();
float freq = _node_prefs->freq;
float bw = _node_prefs->bw;
uint8_t sf = _node_prefs->sf;
uint8_t cr = _node_prefs->cr;
const char* profile_tag = "";
if (dual_radio) {
const uint8_t profile = secondary_page ? 1 : 0;
const auto& params = profiles->params(profile);
freq = params.freq;
bw = params.bw;
sf = params.sf;
cr = params.cr;
profile_tag = mesh::ui::radioProfileDisplayTag(profile,
profile == 1 ? profiles->secondary_temporary : profiles->primary_temporary);
}
// T096's normal 6x8 right column needs compact radio labels. Other
// displays retain the longer labels for their roomier layouts.
#if defined(HELTEC_T096)
snprintf(tmp, sizeof(tmp), "%s%sF:%06.3f S:%d", profile_tag,
dual_radio ? " " : "", freq, sf);
#else
if (dual_radio) {
// R1/R2/T1/T2 needs three extra cells. Compact fields retain every RF
// value on a 128px OLED even at the widest legal frequency/SF pair.
snprintf(tmp, sizeof(tmp), "%s F:%06.3f S:%d", profile_tag, freq, sf);
} else {
snprintf(tmp, sizeof(tmp), "FREQ: %06.3f SF%d", freq, sf);
}
#endif
rows.draw(tmp, false);
// bw / cr
sprintf(tmp, "BW: %03.2f CR: %d", _node_prefs->bw, _node_prefs->cr);
// bandwidth / coding rate
#if defined(HELTEC_T096)
snprintf(tmp, sizeof(tmp), "%s%sB:%03.2f C:%d", profile_tag,
dual_radio ? " " : "", bw, cr);
#else
if (dual_radio) {
snprintf(tmp, sizeof(tmp), "%s B:%03.2f C:%d", profile_tag, bw, cr);
} else {
snprintf(tmp, sizeof(tmp), "BW: %03.2f CR: %d", bw, cr);
}
#endif
rows.draw(tmp, false);
#ifdef WITH_MQTT_BRIDGE
@@ -226,8 +594,38 @@ void UITask::renderCurrScreen() {
}
// Keep power-saving state visible even when the MQTT IP replaces battery.
snprintf(tmp, sizeof(tmp), "PowerSaving: %s", _node_prefs->powersaving_enabled ? "ON" : "off");
#if defined(HELTEC_T096)
// This is the fourth left-column row (after F, B, and battery/IP). Keep
// its label green, with just the saved ON/OFF value carrying the state
// color used by the status strip.
const int power_saving_y = rows.nextY();
if (rows.reserve()) {
drawT096State(*_display, 0, power_saving_y, "PS: ",
_node_prefs->powersaving_enabled != 0);
}
const int identity_y = rows.nextY();
if (rows.reserve()) {
char identity_prefix[7];
mesh::Utils::toHex(identity_prefix, the_mesh.getSelfId().pub_key, 3);
_display->setColor(UIColor::primary_txt);
_display->setCursor(0, identity_y);
_display->print("ID:");
_display->print(identity_prefix);
}
drawT096Radio2Details(*_display, rows.nextY(),
rows.nextY() + _display->textLineHeight() + 2);
#else
snprintf(tmp, sizeof(tmp), "PS: %s", _node_prefs->powersaving_enabled ? "ON" : "OFF");
rows.draw(tmp, false);
#endif
#if defined(HELTEC_T096)
drawT096StatusPanel(*_display, *_node_prefs, secondary_page ? 1 : 0);
#else
// The shared radio-profile layer reports this on every repeater board.
// BoundedTextRows simply omits this extra row on a screen too short to
// hold it, rather than overwriting an existing status line.
if (the_mesh.isDualRadioActive()) rows.draw("DualRadio: ON", false);
#endif
}
}
@@ -260,9 +658,61 @@ uint32_t UITask::getFrameSignature() {
signature = DisplayFrameSignature::append(signature, "home");
signature = DisplayFrameSignature::append(signature, _node_prefs->node_name);
snprintf(tmp, sizeof(tmp), "FREQ: %06.3f SF%d", _node_prefs->freq, _node_prefs->sf);
uint8_t status_page_index = 0;
if (showingRadioProfileSystemStatusPage(&status_page_index)) {
signature = DisplayFrameSignature::append(signature, "radio-system-status");
snprintf(tmp, sizeof(tmp), "status-page-%u", status_page_index);
signature = DisplayFrameSignature::append(signature, tmp);
signature = DisplayFrameSignature::append(
signature, _node_prefs->powersaving_enabled ? "powersaving-on" : "powersaving-off");
signature = DisplayFrameSignature::append(
signature, _node_prefs->gps_enabled ? "gps-on" : "gps-off");
signature = DisplayFrameSignature::append(
signature, _board->canControlLoRaFemLna() && _board->isLoRaFemLnaEnabled()
? "fem-on" : "fem-off");
signature = DisplayFrameSignature::append(
signature, _node_prefs->rx_boosted_gain ? "rxb-on" : "rxb-off");
signature = DisplayFrameSignature::append(
signature, _node_prefs->rx_powersaving_enabled ? "rxps-on" : "rxps-off");
signature = DisplayFrameSignature::append(
signature, _node_prefs->cad_enabled ? "cad-on" : "cad-off");
const mesh::RadioProfiles* status_profiles = configuredRadioProfiles();
if (status_profiles != NULL && status_profiles->enabled()) {
formatRadioNoiseFloor(tmp, sizeof(tmp), "N1", 0);
signature = DisplayFrameSignature::append(signature, tmp);
formatRadioNoiseFloor(tmp, sizeof(tmp), "N2", 1);
signature = DisplayFrameSignature::append(signature, tmp);
signature = DisplayFrameSignature::append(signature,
status_profiles->secondary.mode == mesh::RadioProfileMode::RxTx
? "radio2-rxtx" : "radio2-rx");
signature = DisplayFrameSignature::append(signature,
status_profiles->cross == mesh::RadioCrossMode::On ? "cross-on"
: status_profiles->cross == mesh::RadioCrossMode::Off
? "cross-off" : "cross-auto");
}
return signature;
}
const mesh::RadioProfiles* profiles = configuredRadioProfiles();
const bool secondary_page = showingSecondaryRadioProfilePage();
const bool dual_radio = profiles != NULL && profiles->enabled();
float freq = _node_prefs->freq;
float bw = _node_prefs->bw;
uint8_t sf = _node_prefs->sf;
uint8_t cr = _node_prefs->cr;
if (dual_radio) {
const uint8_t profile = secondary_page ? 1 : 0;
const auto& params = profiles->params(profile);
freq = params.freq;
bw = params.bw;
sf = params.sf;
cr = params.cr;
signature = DisplayFrameSignature::append(signature,
mesh::ui::radioProfileDisplayTag(profile,
profile == 1 ? profiles->secondary_temporary : profiles->primary_temporary));
}
snprintf(tmp, sizeof(tmp), "FREQ: %06.3f SF%d", freq, sf);
signature = DisplayFrameSignature::append(signature, tmp);
snprintf(tmp, sizeof(tmp), "BW: %03.2f CR: %d", _node_prefs->bw, _node_prefs->cr);
snprintf(tmp, sizeof(tmp), "BW: %03.2f CR: %d", bw, cr);
signature = DisplayFrameSignature::append(signature, tmp);
#if defined(WITH_MQTT_BRIDGE) && !defined(DISPLAY_ACTIVITY_DASHBOARD)
@@ -287,6 +737,24 @@ uint32_t UITask::getFrameSignature() {
#endif
signature = DisplayFrameSignature::append(
signature, _node_prefs->powersaving_enabled ? "powersaving-on" : "powersaving-off");
#if defined(HELTEC_T096)
signature = DisplayFrameSignature::append(
signature, _node_prefs->gps_enabled ? "gps-on" : "gps-off");
signature = DisplayFrameSignature::append(
signature, _board->canControlLoRaFemLna() && _board->isLoRaFemLnaEnabled()
? "fem-on" : "fem-off");
signature = DisplayFrameSignature::append(
signature, _node_prefs->rx_boosted_gain ? "rxb-on" : "rxb-off");
signature = DisplayFrameSignature::append(
signature, _node_prefs->rx_powersaving_enabled ? "rxps-on" : "rxps-off");
signature = DisplayFrameSignature::append(
signature, _node_prefs->cad_enabled ? "cad-on" : "cad-off");
formatRadioNoiseFloor(tmp, sizeof(tmp), dual_radio
? (secondary_page ? "N2" : "N1") : "N", secondary_page ? 1 : 0);
signature = DisplayFrameSignature::append(signature, tmp);
#endif
signature = DisplayFrameSignature::append(
signature, the_mesh.isDualRadioActive() ? "radio2-on" : "radio2-off");
#endif
return signature;
@@ -303,6 +771,18 @@ bool UITask::buildDashboardContext(ObserverDashboard::Context* ctx) {
ctx->freq = _node_prefs->freq;
ctx->sf = _node_prefs->sf;
ctx->bw = _node_prefs->bw;
ctx->radio_label = "";
const mesh::RadioProfiles* profiles = configuredRadioProfiles();
if (profiles != NULL && profiles->enabled()) {
const uint8_t profile = showingSecondaryRadioProfilePage() ? 1 : 0;
const auto& params = profiles->params(profile);
ctx->freq = params.freq;
ctx->sf = params.sf;
ctx->bw = params.bw;
ctx->radio_label = mesh::ui::radioProfileDisplayTag(profile,
profile == 1 ? profiles->secondary_temporary : profiles->primary_temporary);
}
ctx->dual_radio = the_mesh.isDualRadioActive();
#ifdef WITH_MQTT_BRIDGE
ctx->link_up = (WiFi.status() == WL_CONNECTED);
#else
@@ -347,6 +827,7 @@ void UITask::updateActivityRows() {
#ifdef DISPLAY_TOUCH_TOGGLE
void UITask::toggleDisplay(const char* source) {
_display->wake(mesh::ui::DisplayWake::Button);
resetRadioProfileDisplayPage();
#ifdef DISPLAY_TOUCH_DEBUG
mesh::usbConsolePort().printf("Display: %s -> %s\n", source, _display->isOn() ? "on" : "off");
#else
@@ -364,6 +845,7 @@ void UITask::toggleDisplay(const char* source) {
void UITask::loop() {
if (_display->servicePower(board.isExternalPowered() || board.isUsbHostConnected())) {
if (_display->isOn()) resetRadioProfileDisplayPage();
_next_refresh = 0;
#ifdef DISPLAY_REDRAW_ON_CHANGE
_frame_valid = false;
@@ -378,13 +860,15 @@ void UITask::loop() {
// WebConfig. Collapse a completed double-click into one display action
// instead of silently consuming both presses.
if (ev == BUTTON_EVENT_CLICK || ev == BUTTON_EVENT_DOUBLE_CLICK) {
#ifdef DISPLAY_TOUCH_TOGGLE
toggleDisplay("button"); // same action as tapping the panel
#else
if (_display->isOn()) {
// TODO: any action ?
// A page change is still user activity. Capture the old state first so
// the first press wakes to R1, while every subsequent press both extends
// the 15-second timer and advances to the next available detail page.
const bool display_was_on = _display->isOn();
_display->wake(mesh::ui::DisplayWake::Button);
if (display_was_on) {
advanceRadioProfileDisplayPage();
} else {
_display->wake(mesh::ui::DisplayWake::Button);
resetRadioProfileDisplayPage();
#ifdef DISPLAY_REDRAW_ON_CHANGE
_frame_valid = false;
#endif
@@ -392,10 +876,9 @@ void UITask::loop() {
_rows_valid = false;
#endif
}
_display->wake(mesh::ui::DisplayWake::Button);
#endif
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
_display->wake(mesh::ui::DisplayWake::Button);
resetRadioProfileDisplayPage();
mesh::usbConsolePort().printf("Powering Off\r\n");
_powering_off_at = millis() + POWEROFF_DELAY;
#ifdef DISPLAY_REDRAW_ON_CHANGE
@@ -411,6 +894,7 @@ void UITask::loop() {
// multiclick enabled specifically for this action.
WebConfigServer::requestToggleFromButton();
_display->wake(mesh::ui::DisplayWake::Button);
resetRadioProfileDisplayPage();
#endif
}
#endif
@@ -451,7 +935,16 @@ void UITask::loop() {
}
#endif
_next_refresh = millis() + 1000; // check for visible changes every second
unsigned long refresh_interval = 1000; // check normal status changes every second
#if defined(HELTEC_T096)
// The T096's TFT can show each tenth while the short, 3.2-second noise
// floor collection window is active. Keep every other screen at the
// normal cadence, particularly displays with slow/expensive refreshes.
if (radio_driver.getNoiseFloorCalibrationSecondsRemaining() > 0.0f) {
refresh_interval = 100;
}
#endif
_next_refresh = millis() + refresh_interval;
}
}