ui fixes including discover screen; clock fix

This commit is contained in:
pelgraine
2026-03-12 04:32:58 +11:00
parent 7ae9c47006
commit 565c2a4c9b
10 changed files with 326 additions and 28 deletions
+32 -3
View File
@@ -614,6 +614,25 @@ MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables, store
return KEY_ENTER; // file list: open
}
// Discovery screen: long press = rescan
if (ui_task.isOnDiscoveryScreen()) {
return 'f';
}
// Contacts screen: long press = open repeater admin (if on a repeater contact)
if (ui_task.isOnContactsScreen()) {
ContactsScreen* cs = (ContactsScreen*)ui_task.getContactsScreen();
if (cs) {
int idx = cs->getSelectedContactIdx();
ContactInfo ci;
if (the_mesh.getContactByIdx(idx, ci) && ci.type == ADV_TYPE_REPEATER) {
ui_task.gotoRepeaterAdmin(idx);
return 0;
}
}
return KEY_ENTER; // non-repeater: normal select
}
// Default: enter/select (settings toggle, etc.)
return KEY_ENTER;
}
@@ -959,9 +978,10 @@ void setup() {
#endif
// Initialize GT911 touch (T5S3 E-Paper Pro)
// Wire is already initialized by T5S3Board::begin(). The 4-arg begin() re-calls
// Wire.begin() which logs "bus already initialized" — cosmetic only, not harmful.
#if defined(LilyGo_T5S3_EPaper_Pro)
gt911Touch.setPins(GT911_PIN_RST, GT911_PIN_INT);
pinMode(GT911_PIN_INT, INPUT_PULLUP); // Ensure INT pin has pullup for clean transitions
if (gt911Touch.begin(Wire, GT911_SLAVE_ADDRESS_L, GT911_PIN_SDA, GT911_PIN_SCL)) {
gt911Ready = true;
Serial.println("setup() - GT911 touch initialized");
@@ -970,8 +990,17 @@ void setup() {
}
#endif
// ---------------------------------------------------------------------------
// SD card is already initialized (early init above).
// RTC diagnostic — verify the auto-discovered RTC is working
#if defined(LilyGo_T5S3_EPaper_Pro)
{
uint32_t rtcTime = rtc_clock.getCurrentTime();
Serial.printf("setup() - RTC time: %lu (valid=%s)\n", rtcTime,
rtcTime > 1700000000 ? "YES" : "NO");
if (rtcTime < 1700000000) {
Serial.println("setup() - RTC has no valid time (will be set by companion app)");
}
}
#endif
// Now set up SD-dependent features: message history + text reader.
// ---------------------------------------------------------------------------
#if defined(LilyGo_TDeck_Pro) && defined(HAS_SDCARD)
@@ -957,7 +957,7 @@ public:
#if defined(LilyGo_T5S3_EPaper_Pro)
display.setTextSize(0);
display.drawTextCentered(display.width() / 2, footerY, "Swipe: Scroll Tap: Select Boot: Home");
display.drawTextCentered(display.width() / 2, footerY, "Swipe: Scroll Tap: Select boot: home");
#else
// Left side: abbreviated controls
if (_replySelectMode) {
@@ -303,7 +303,7 @@ public:
#if defined(LilyGo_T5S3_EPaper_Pro)
display.setTextSize(0);
display.drawTextCentered(display.width() / 2, footerY, "Swipe: Scroll Tap: Select Boot: Home");
display.drawTextCentered(display.width() / 2, footerY, "Swipe: Scroll Tap: Select boot: home");
#else
// Left: Q:Bk
display.setCursor(0, footerY);
@@ -79,7 +79,11 @@ public:
display.print(active ? "Listening for adverts..." : "No nodes found");
if (!active) {
display.setCursor(4, 38);
#if defined(LilyGo_T5S3_EPaper_Pro)
display.print("Long press: Rescan");
#else
display.print("F: Scan again Q: Back");
#endif
}
} else {
// Center visible window around selected item
@@ -158,6 +162,17 @@ public:
display.setColor(DisplayDriver::YELLOW);
display.setCursor(0, footerY);
#if defined(LilyGo_T5S3_EPaper_Pro)
display.print("Swipe:Scroll");
const char* mid = "Tap:Add";
display.setCursor((display.width() - display.getTextWidth(mid)) / 2, footerY);
display.print(mid);
const char* right = "Hold:Rescan";
display.setCursor(display.width() - display.getTextWidth(right) - 2, footerY);
display.print(right);
#else
display.print("Q:Back");
const char* mid = "Ent:Add";
@@ -167,6 +182,7 @@ public:
const char* right = "F:Rescan";
display.setCursor(display.width() - display.getTextWidth(right) - 2, footerY);
display.print(right);
#endif
// Faster refresh while actively scanning
return active ? 1000 : 5000;
@@ -1008,17 +1008,17 @@ public:
#if defined(LilyGo_T5S3_EPaper_Pro)
display.setTextSize(0);
if (_editMode == EDIT_NONE) {
display.drawTextCentered(display.width() / 2, footerY, "Swipe: Scroll Tap: Select Hold: Edit Boot: Home");
display.drawTextCentered(display.width() / 2, footerY, "Swipe: Scroll Tap: Select Hold: Edit boot: home");
} else if (_editMode == EDIT_NUMBER) {
display.drawTextCentered(display.width() / 2, footerY, "Swipe Up/Down: Adjust Tap: OK Boot: Cancel");
display.drawTextCentered(display.width() / 2, footerY, "Swipe Up/Down: Adjust Tap: OK boot: cancel");
} else if (_editMode == EDIT_PICKER) {
display.drawTextCentered(display.width() / 2, footerY, "Swipe Left/Right: Choose Tap: OK");
} else if (_editMode == EDIT_CONFIRM) {
display.drawTextCentered(display.width() / 2, footerY, "Tap: Confirm Boot: Cancel");
display.drawTextCentered(display.width() / 2, footerY, "Tap: Confirm boot: cancel");
#ifdef MECK_WIFI_COMPANION
} else if (_editMode == EDIT_WIFI) {
if (_wifiPhase == WIFI_PHASE_SELECT) {
display.drawTextCentered(display.width() / 2, footerY, "Swipe: Pick Tap: Select Boot: Back");
display.drawTextCentered(display.width() / 2, footerY, "Swipe: Pick Tap: Select boot: back");
} else {
display.drawTextCentered(display.width() / 2, footerY, "Please wait...");
}
@@ -926,7 +926,7 @@ private:
#if defined(LilyGo_T5S3_EPaper_Pro)
display.setTextSize(0);
display.drawTextCentered(display.width() / 2, footerY, "Swipe: Scroll Tap: Open Boot: Home");
display.drawTextCentered(display.width() / 2, footerY, "Swipe: Scroll Tap: Open boot: home");
#else
display.setCursor(0, footerY);
display.print("Q:Back W/S:Nav");
@@ -960,6 +960,7 @@ private:
display.setCursor(0, y);
// Print line with UTF-8 decoding: multi-byte sequences are decoded
// to Unicode codepoints, then mapped to CP437 for the built-in font.
bool lineHasContent = false;
char charStr[2] = {0, 0};
int j = pos;
while (j < wrap.lineEnd && j < _pageBufLen) {
@@ -975,6 +976,7 @@ private:
// Plain ASCII — print directly
charStr[0] = (char)b;
display.print(charStr);
lineHasContent = true;
j++;
} else if (b >= 0xC0) {
// UTF-8 lead byte — decode full sequence and map to CP437
@@ -984,6 +986,7 @@ private:
if (glyph) {
charStr[0] = (char)glyph;
display.print(charStr);
lineHasContent = true;
}
// If unmappable (glyph==0), just skip the character
} else {
@@ -991,11 +994,20 @@ private:
// Treat as CP437 pass-through (e.g. from EPUB numeric entity decoding).
charStr[0] = (char)b;
display.print(charStr);
lineHasContent = true;
j++;
}
}
y += _lineHeight;
// Blank lines (paragraph breaks) get reduced height for compact layout.
// Full _lineHeight for blank lines wastes too much space — on T5S3 each
// blank line is ~34px, making paragraph gaps 7-8× the normal line spacing.
// Using 40% height gives a visible paragraph break without wasting space.
if (lineHasContent) {
y += _lineHeight;
} else {
y += max(2, _lineHeight * 2 / 5); // ~40% height for blank lines
}
lineCount++;
pos = wrap.nextStart;
if (pos >= _pageBufLen) break;
+41 -5
View File
@@ -32,7 +32,7 @@
#if UI_HAS_JOYSTICK
#define PRESS_LABEL "press Enter"
#elif defined(LilyGo_T5S3_EPaper_Pro)
#define PRESS_LABEL "hold Boot btn"
#define PRESS_LABEL "hold boot btn"
#else
#define PRESS_LABEL "long press"
#endif
@@ -159,9 +159,11 @@ void renderBatteryIndicator(DisplayDriver& display, uint16_t batteryMilliVolts,
int totalWidth = iconWidth + 2 + 2 + textWidth + 2;
int iconX = display.width() - totalWidth;
#if defined(LilyGo_T5S3_EPaper_Pro)
int iconY = 4; // Shift down to match header text offset
int iconY = 6; // Align with FreeSans12pt text baseline
int textY = 1; // Percentage text — setCursor adds +5 → baseline at (6)*scale_y
#else
int iconY = 0; // vertically align with node name text
int iconY = 0; // vertically align with node name text
int textY = iconY - 3; // offset up to vertically center with icon
#endif
if (outIconX) *outIconX = iconX;
@@ -179,7 +181,6 @@ void renderBatteryIndicator(DisplayDriver& display, uint16_t batteryMilliVolts,
// draw percentage text after the battery cap, offset upward to center with icon
// (setCursor adds +5 internally for baseline, so compensate for the tiny font)
int textX = iconX + iconWidth + 2 + 2; // after cap + gap
int textY = iconY - 3; // offset up to vertically center with icon
display.setCursor(textX, textY);
display.print(pctStr);
display.setTextSize(1); // restore default text size
@@ -490,23 +491,39 @@ public:
#ifdef BLE_PIN_CODE
} else if (_page == HomePage::BLUETOOTH) {
display.setColor(DisplayDriver::GREEN);
#if defined(LilyGo_T5S3_EPaper_Pro)
display.drawXbm((display.width() - 32) / 2, 28,
#else
display.drawXbm((display.width() - 32) / 2, 18,
#endif
_task->isSerialEnabled() ? bluetooth_on : bluetooth_off,
32, 32);
if (_task->hasConnection()) {
display.setColor(DisplayDriver::GREEN);
display.setTextSize(1);
#if defined(LilyGo_T5S3_EPaper_Pro)
display.drawTextCentered(display.width() / 2, 64, "< Connected >");
#else
display.drawTextCentered(display.width() / 2, 53, "< Connected >");
#endif
} else if (_task->isSerialEnabled() && the_mesh.getBLEPin() != 0) {
display.setColor(DisplayDriver::RED);
display.setTextSize(2);
sprintf(tmp, "Pin:%d", the_mesh.getBLEPin());
#if defined(LilyGo_T5S3_EPaper_Pro)
display.drawTextCentered(display.width() / 2, 64, tmp);
#else
display.drawTextCentered(display.width() / 2, 53, tmp);
#endif
}
display.setColor(DisplayDriver::GREEN);
display.setTextSize(1);
#if defined(LilyGo_T5S3_EPaper_Pro)
display.drawTextCentered(display.width() / 2, 80, "toggle: " PRESS_LABEL);
#else
display.drawTextCentered(display.width() / 2, 72, "toggle: " PRESS_LABEL);
#endif
#endif
#ifdef MECK_WIFI_COMPANION
} else if (_page == HomePage::WIFI_STATUS) {
display.setColor(DisplayDriver::GREEN);
@@ -547,8 +564,16 @@ public:
#endif
} else if (_page == HomePage::ADVERT) {
display.setColor(DisplayDriver::GREEN);
#if defined(LilyGo_T5S3_EPaper_Pro)
display.drawXbm((display.width() - 32) / 2, 28, advert_icon, 32, 32);
#else
display.drawXbm((display.width() - 32) / 2, 18, advert_icon, 32, 32);
#endif
#if defined(LilyGo_T5S3_EPaper_Pro)
display.drawTextCentered(display.width() / 2, 64, "advert: " PRESS_LABEL);
#else
display.drawTextCentered(display.width() / 2, 64 - 11, "advert: " PRESS_LABEL);
#endif
#if ENV_INCLUDE_GPS == 1
} else if (_page == HomePage::GPS) {
extern GPSStreamCounter gpsStream;
@@ -773,10 +798,21 @@ public:
display.setColor(DisplayDriver::GREEN);
display.setTextSize(1);
if (_shutdown_init) {
#if defined(LilyGo_T5S3_EPaper_Pro)
board.setBacklight(false); // Turn off backlight on hibernate
#endif
display.drawTextCentered(display.width() / 2, 34, "hibernating...");
} else {
#if defined(LilyGo_T5S3_EPaper_Pro)
display.drawXbm((display.width() - 32) / 2, 28, power_icon, 32, 32);
#else
display.drawXbm((display.width() - 32) / 2, 18, power_icon, 32, 32);
#endif
#if defined(LilyGo_T5S3_EPaper_Pro)
display.drawTextCentered(display.width() / 2, 64, "hibernate:" PRESS_LABEL);
#else
display.drawTextCentered(display.width() / 2, 64 - 11, "hibernate:" PRESS_LABEL);
#endif
}
}
return _editing_utc ? 700 : 5000; // match e-ink refresh cycle while editing UTC
@@ -1490,7 +1526,7 @@ char UITask::handleTripleClick(char c) {
if (board.isBacklightOn()) {
board.setBacklight(false); // If already on, turn off
} else {
board.setBacklightBrightness(40);
board.setBacklightBrightness(4);
board.setBacklight(true);
}
#else