From 16ae867c2d0fb30927bbdc6a25b6fc3e1e4f92e2 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 10 Apr 2022 19:15:10 -0700 Subject: [PATCH 1/3] Show welcome screen if region unset --- platformio.ini | 2 +- src/graphics/Screen.cpp | 56 +++++++++++++++++++++++++++++++++-------- src/graphics/Screen.h | 2 ++ 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/platformio.ini b/platformio.ini index b2c375901..e692888c2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -42,7 +42,7 @@ build_flags = -Wno-missing-field-initializers monitor_speed = 921600 lib_deps = - https://github.com/meshtastic/esp8266-oled-ssd1306.git ; ESP8266_SSD1306 + https://github.com/meshtastic/esp8266-oled-ssd1306.git#53580644255b48ebb7a737343c6b4e71c7e11cf2 ; ESP8266_SSD1306 mathertel/OneButton@^2.0.3 ; OneButton library for non-blocking button debounce 1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib https://github.com/meshtastic/arduino-fsm.git diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 04d66ba87..d00106f0a 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -168,6 +168,28 @@ static void drawSSLScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16 } } +// Used when booting without a region set +static void drawWelcomeScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) +{ + + display->setFont(FONT_SMALL); + + display->setTextAlignment(TEXT_ALIGN_CENTER); + display->drawString(64 + x, y, "Welcome to Meshtastic!"); + + display->setTextAlignment(TEXT_ALIGN_LEFT); + + display->drawString(x, y + FONT_HEIGHT_SMALL * 2 - 3, "Set the region using the"); + display->drawString(x, y + FONT_HEIGHT_SMALL * 3 - 3, "Android, iOS, Flasher or"); + display->drawString(x, y + FONT_HEIGHT_SMALL * 4 - 3, "CLI."); + +#ifndef NO_ESP32 + yield(); + esp_task_wdt_reset(); +#endif + +} + #ifdef HAS_EINK /// Used on eink displays while in deep sleep static void drawSleepScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) @@ -766,7 +788,7 @@ void Screen::setup() useDisplay = true; #ifdef AutoOLEDWire_h - dispdev.setDetected(screen_model); + dispdev.setDetected(screen_model); #endif // I think this is not needed - redundant with ui.init @@ -862,6 +884,10 @@ int32_t Screen::runOnce() showingBootScreen = false; } + if (radioConfig.preferences.region == RegionCode_Unset) { + setWelcomeFrames(); + } + // Process incoming commands. for (;;) { ScreenCmd cmd; @@ -975,6 +1001,18 @@ void Screen::setSSLFrames() } } +/* show a message that the SSL cert is being built + * it is expected that this will be used during the boot phase */ +void Screen::setWelcomeFrames() +{ + if (address_found) { + // DEBUG_MSG("showing Welcome frames\n"); + static FrameCallback welcomeFrames[] = {drawWelcomeScreen}; + ui.setFrames(welcomeFrames, 1); + ui.update(); + } +} + // restore our regular frame list void Screen::setFrames() { @@ -1366,7 +1404,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat } auto mode = ""; - + if (channels.getPrimary().modem_config == 0) { mode = "VLongSlow"; } else if (channels.getPrimary().modem_config == 1) { @@ -1380,7 +1418,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat } else if (channels.getPrimary().modem_config == 5) { mode = "ShortSlow"; } else if (channels.getPrimary().modem_config == 6) { - mode = "ShortFast"; + mode = "ShortFast"; } else { mode = "Custom"; } @@ -1432,8 +1470,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat // Display Channel Utilization char chUtil[13]; sprintf(chUtil, "ChUtil %2.0f%%", airTime->channelUtilizationPercent()); - display->drawString(x + SCREEN_WIDTH - display->getStringWidth(chUtil), - y + FONT_HEIGHT_SMALL * 1, chUtil); + display->drawString(x + SCREEN_WIDTH - display->getStringWidth(chUtil), y + FONT_HEIGHT_SMALL * 1, chUtil); // Line 3 if (radioConfig.preferences.gps_format != GpsCoordinateFormat_GpsFormatDMS) // if DMS then don't draw altitude @@ -1491,16 +1528,13 @@ int Screen::handleTextMessage(const MeshPacket *packet) int Screen::handleUIFrameEvent(const UIFrameEvent *event) { if (showingNormalScreen) { - if (event->frameChanged) - { + if (event->frameChanged) { setFrames(); // Regen the list of screens (will show new text message) - } - else if (event->needRedraw) - { + } else if (event->needRedraw) { setFastFramerate(); // TODO: We might also want switch to corresponding frame, // but we don't know the exact frame number. - //ui.switchToFrame(0); + // ui.switchToFrame(0); } } diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index 2242532d7..59d68c902 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -235,6 +235,8 @@ class Screen : public concurrency::OSThread /// Draws our SSL cert screen during boot (called from WebServer) void setSSLFrames(); + void setWelcomeFrames(); + protected: /// Updates the UI. // From 14eef4276252a173c898de394165d9a3e987d3ba Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 10 Apr 2022 19:27:11 -0700 Subject: [PATCH 2/3] Disable indicator on welcome screen. --- src/graphics/Screen.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index d00106f0a..7bc7ea170 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -1007,6 +1007,8 @@ void Screen::setWelcomeFrames() { if (address_found) { // DEBUG_MSG("showing Welcome frames\n"); + ui.disableAllIndicators(); + static FrameCallback welcomeFrames[] = {drawWelcomeScreen}; ui.setFrames(welcomeFrames, 1); ui.update(); From 6eab8f84d10b0cee917082651793c70c5712190e Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 10 Apr 2022 19:34:13 -0700 Subject: [PATCH 3/3] Updated text for better fit --- src/graphics/Screen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 7bc7ea170..0ac19cbce 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -175,13 +175,13 @@ static void drawWelcomeScreen(OLEDDisplay *display, OLEDDisplayUiState *state, i display->setFont(FONT_SMALL); display->setTextAlignment(TEXT_ALIGN_CENTER); - display->drawString(64 + x, y, "Welcome to Meshtastic!"); + display->drawString(64 + x, y, "Meshtastic :)"); display->setTextAlignment(TEXT_ALIGN_LEFT); display->drawString(x, y + FONT_HEIGHT_SMALL * 2 - 3, "Set the region using the"); - display->drawString(x, y + FONT_HEIGHT_SMALL * 3 - 3, "Android, iOS, Flasher or"); - display->drawString(x, y + FONT_HEIGHT_SMALL * 4 - 3, "CLI."); + display->drawString(x, y + FONT_HEIGHT_SMALL * 3 - 3, "Meshtastic Android, iOS,"); + display->drawString(x, y + FONT_HEIGHT_SMALL * 4 - 3, "Flasher or CLI client."); #ifndef NO_ESP32 yield();