diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index b575937d1..8c6146efb 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -121,6 +121,30 @@ static uint16_t displayWidth, displayHeight; #define getStringCenteredX(s) ((SCREEN_WIDTH - display->getStringWidth(s)) / 2) +/// Check if the display can render a string (detect special chars; emoji) +static bool haveGlyphs(const char *str) +{ +#if defined(OLED_UA) || defined(OLED_RU) + // Don't want to make any assumptions about custom language support + return true; +#endif + + // Check each character with the lookup function for the OLED library + // We're not really meant to use this directly.. + bool have = true; + for (uint16_t i = 0; i < strlen(str); i++) { + uint8_t result = Screen::customFontTableLookup((uint8_t)str[i]); + // If font doesn't support a character, it is substituted for ¿ + if (result == 191 && (uint8_t)str[i] != 191) { + have = false; + break; + } + } + + LOG_DEBUG("haveGlyphs=%d\n", have); + return have; +} + /** * Draw the icon with extra info printed around the corners */ @@ -144,13 +168,15 @@ static void drawIconScreen(const char *upperMsg, OLEDDisplay *display, OLEDDispl if (upperMsg) display->drawString(x + 0, y + 0, upperMsg); - // Draw version in upper right - char buf[16]; - snprintf(buf, sizeof(buf), "%s", - xstr(APP_VERSION_SHORT)); // Note: we don't bother printing region or now, it makes the string too long - display->drawString(x + SCREEN_WIDTH - display->getStringWidth(buf), y + 0, buf); + // Draw version and short name in upper right + char buf[25]; + snprintf(buf, sizeof(buf), "%s\n%s", xstr(APP_VERSION_SHORT), haveGlyphs(owner.short_name) ? owner.short_name : ""); + + display->setTextAlignment(TEXT_ALIGN_RIGHT); + display->drawString(x + SCREEN_WIDTH, y + 0, buf); screen->forceDisplay(); - // FIXME - draw serial # somewhere? + + display->setTextAlignment(TEXT_ALIGN_LEFT); // Restore left align, just to be kind to any other unsuspecting code } static void drawOEMIconScreen(const char *upperMsg, OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) @@ -185,14 +211,15 @@ static void drawOEMIconScreen(const char *upperMsg, OLEDDisplay *display, OLEDDi if (upperMsg) display->drawString(x + 0, y + 0, upperMsg); - // Draw version in upper right - char buf[16]; - snprintf(buf, sizeof(buf), "%s", - xstr(APP_VERSION_SHORT)); // Note: we don't bother printing region or now, it makes the string too long - display->drawString(x + SCREEN_WIDTH - display->getStringWidth(buf), y + 0, buf); + // Draw version and shortname in upper right + char buf[25]; + snprintf(buf, sizeof(buf), "%s\n%s", xstr(APP_VERSION_SHORT), haveGlyphs(owner.short_name) ? owner.short_name : ""); + + display->setTextAlignment(TEXT_ALIGN_RIGHT); + display->drawString(x + SCREEN_WIDTH, y + 0, buf); screen->forceDisplay(); - // FIXME - draw serial # somewhere? + display->setTextAlignment(TEXT_ALIGN_LEFT); // Restore left align, just to be kind to any other unsuspecting code } static void drawOEMBootScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) @@ -218,7 +245,6 @@ static void drawBootScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int1 } else #endif { - // Draw region in upper left const char *region = myRegion ? myRegion->name : NULL; drawIconScreen(region, display, state, x, y); } @@ -281,40 +307,19 @@ static void drawFunctionOverlay(OLEDDisplay *display, OLEDDisplayUiState *state) } } -/// Check if the display can render a string (detect special chars; emoji) -static bool haveGlyphs(const char *str) -{ -#if defined(OLED_UA) || defined(OLED_RU) - // Don't want to make any assumptions about custom language support - return true; -#endif - - // Check each character with the lookup function for the OLED library - // We're not really meant to use this directly.. - bool have = true; - for (uint16_t i = 0; i < strlen(str); i++) { - uint8_t result = Screen::customFontTableLookup((uint8_t)str[i]); - // If font doesn't support a character, it is substituted for ¿ - if (result == 191 && (uint8_t)str[i] != 191) { - have = false; - break; - } - } - - LOG_DEBUG("haveGlyphs=%d\n", have); - return have; -} - #ifdef USE_EINK /// Used on eink displays while in deep sleep static void drawDeepSleepScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { + // Next frame should use full-refresh, and block while running, else device will sleep before async callback EINK_ADD_FRAMEFLAG(display, COSMETIC); EINK_ADD_FRAMEFLAG(display, BLOCKING); LOG_DEBUG("Drawing deep sleep screen\n"); - drawIconScreen("Sleeping...", display, state, x, y); + + // Display displayStr on the screen + drawIconScreen("Sleeping", display, state, x, y); } /// Used on eink displays when screen updates are paused @@ -2718,4 +2723,4 @@ int Screen::handleWaypoint(const meshtastic_MeshPacket *arg) } // namespace graphics #else graphics::Screen::Screen(ScanI2C::DeviceAddress, meshtastic_Config_DisplayConfig_OledType, OLEDDISPLAY_GEOMETRY) {} -#endif // HAS_SCREEN \ No newline at end of file +#endif // HAS_SCREEN diff --git a/src/mesh/PhoneAPI.h b/src/mesh/PhoneAPI.h index a957dd395..3ef641fc0 100644 --- a/src/mesh/PhoneAPI.h +++ b/src/mesh/PhoneAPI.h @@ -8,6 +8,14 @@ // Make sure that we never let our packets grow too large for one BLE packet #define MAX_TO_FROM_RADIO_SIZE 512 + +#if meshtastic_FromRadio_size > MAX_TO_FROM_RADIO_SIZE +#error "meshtastic_FromRadio_size is too large for our BLE packets" +#endif +#if meshtastic_ToRadio_size > MAX_TO_FROM_RADIO_SIZE +#error "meshtastic_ToRadio_size is too large for our BLE packets" +#endif + #define SPECIAL_NONCE 69420 /** diff --git a/src/platform/nrf52/main-nrf52.cpp b/src/platform/nrf52/main-nrf52.cpp index 86575bda6..b79f28f13 100644 --- a/src/platform/nrf52/main-nrf52.cpp +++ b/src/platform/nrf52/main-nrf52.cpp @@ -63,7 +63,8 @@ static void initBrownout() // We don't bother with setting up brownout if soft device is disabled - because during production we always use softdevice } -static const bool useSoftDevice = true; // Set to false for easier debugging +// This is a public global so that the debugger can set it to false automatically from our gdbinit +bool useSoftDevice = true; // Set to false for easier debugging #if !MESHTASTIC_EXCLUDE_BLUETOOTH void setBluetoothEnable(bool enable) diff --git a/variants/rak4631/platformio.ini b/variants/rak4631/platformio.ini index beffa7d3d..6a67b0083 100644 --- a/variants/rak4631/platformio.ini +++ b/variants/rak4631/platformio.ini @@ -79,6 +79,7 @@ debug_extra_cmds = commands 1 echo Breakpoint at setup() has semihosting console, connect to it with "telnet localhost 5555" set wantSemihost = true + set useSoftDevice = false end diff --git a/variants/wio-sdk-wm1110/platformio.ini b/variants/wio-sdk-wm1110/platformio.ini index 7ca82e4c6..4a23e7a11 100644 --- a/variants/wio-sdk-wm1110/platformio.ini +++ b/variants/wio-sdk-wm1110/platformio.ini @@ -15,5 +15,19 @@ build_src_filter = ${nrf52_base.build_src_filter} +<../variants/wio-sdk-wm1110> lib_deps = ${nrf52840_base.lib_deps} debug_tool = jlink +;debug_tool = stlink +;debug_speed = 4000 +; No need to reflash if the binary hasn't changed +debug_load_mode = modified ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) upload_protocol = jlink +;upload_protocol = stlink +; we prefer to stop in setup() because we are an 'ardiuno' app +debug_init_break = tbreak setup + +; we need to turn off BLE/soft device if we are debugging otherwise it will watchdog reset us. +debug_extra_cmds = + echo Running .gdbinit script + commands 1 + set useSoftDevice = false + end \ No newline at end of file diff --git a/variants/xiao_ble/platformio.ini b/variants/xiao_ble/platformio.ini index 9d533c0ad..76e91e844 100644 --- a/variants/xiao_ble/platformio.ini +++ b/variants/xiao_ble/platformio.ini @@ -3,7 +3,7 @@ extends = nrf52840_base board = xiao_ble_sense board_level = extra -build_flags = ${nrf52840_base.build_flags} -Ivariants/xiao_ble -Ivariants/xiao_ble/softdevice -Ivariants/xiao_ble/softdevice/nrf52 -D EBYTE_E22 -DEBYTE_E22_900M30S -DPRIVATE_HW +build_flags = ${nrf52840_base.build_flags} -Ivariants/xiao_ble -Ivariants/xiao_ble/softdevice -Ivariants/xiao_ble/softdevice/nrf52 -DEBYTE_E22 -DEBYTE_E22_900M30S -DPRIVATE_HW -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" board_build.ldscript = variants/xiao_ble/nrf52840_s140_v7.ld build_src_filter = ${nrf52_base.build_src_filter} +<../variants/xiao_ble> @@ -11,4 +11,4 @@ lib_deps = ${nrf52840_base.lib_deps} debug_tool = jlink ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) -;upload_protocol = jlink \ No newline at end of file +;upload_protocol = jlink