From cfd2d51f7976971b5ce109ee3cf7bc03c6fed7ed Mon Sep 17 00:00:00 2001 From: pelgraine <140762863+pelgraine@users.noreply.github.com> Date: Wed, 28 Jan 2026 19:38:01 +1100 Subject: [PATCH] =?UTF-8?q?=E2=80=9DAmend=20mymesh.h=20to=20Meck=20v0.3=20?= =?UTF-8?q?||=20=E2=80=98target.h=E2=80=99=20-=20Added=20#include=20"varia?= =?UTF-8?q?nt.h"=20at=20the=20top=20to=20ensure=20HAS=5FGPS=20is=20always?= =?UTF-8?q?=20defined=20before=20the=20conditional=20includes=20||=20targe?= =?UTF-8?q?t.cpp=20-=20Added=20debug=20output=20to=20verify=20HAS=5FGPS=20?= =?UTF-8?q?is=20defined=20at=20compile=20and=20runtime=20||=20=E2=80=98TDe?= =?UTF-8?q?ckBoard.h=E2=80=99=20-=20Added=20#include=20"variant.h"=20for?= =?UTF-8?q?=20pin=20definitions=20||=20Added=20#include=20"variant.h"=20to?= =?UTF-8?q?=20=E2=80=98main.cpp=E2=80=99=20to=20ensure=20HAS=5FGPS=20is=20?= =?UTF-8?q?defined=20||=20Added=20code=20to=20=E2=80=98main.cpp=E2=80=99?= =?UTF-8?q?=20to=20enable=20GPS=20by=20default=20after=20sensors.begin()?= =?UTF-8?q?=20as=20longpress=20not=20currently=20functional=20for=20gps=20?= =?UTF-8?q?toggle=20||=20Changed=20battery=20icon=20size=20in=20=E2=80=98u?= =?UTF-8?q?itask.cpp=E2=80=99=20from=2024=20to=2022=20width=20and=2010=20t?= =?UTF-8?q?o=208=20height.=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/companion_radio/MyMesh.h | 2 +- examples/companion_radio/main.cpp | 41 +++++++++++++++++++++- examples/companion_radio/ui-new/UITask.cpp | 4 +-- variants/lilygo_tdeck_pro/TDeckBoard.cpp | 16 +++++++++ variants/lilygo_tdeck_pro/TDeckBoard.h | 1 + variants/lilygo_tdeck_pro/platformio.ini | 7 ++-- variants/lilygo_tdeck_pro/target.cpp | 11 ++++++ variants/lilygo_tdeck_pro/target.h | 3 ++ 8 files changed, 78 insertions(+), 7 deletions(-) diff --git a/examples/companion_radio/MyMesh.h b/examples/companion_radio/MyMesh.h index fbcf037..a9f784d 100644 --- a/examples/companion_radio/MyMesh.h +++ b/examples/companion_radio/MyMesh.h @@ -12,7 +12,7 @@ #endif #ifndef FIRMWARE_VERSION -#define FIRMWARE_VERSION "Meck v0.2" +#define FIRMWARE_VERSION "Meck v0.3" #endif #if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 7124815..f2b7d5a 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -1,6 +1,8 @@ #include // needed for PlatformIO #include #include "MyMesh.h" +#include "variant.h" // Board-specific defines (HAS_GPS, etc.) +#include "target.h" // For sensors, board, etc. // Believe it or not, this std C function is busted on some platforms! static uint32_t _atoi(const char* sp) { @@ -287,12 +289,29 @@ void setup() { sensors.begin(); Serial.println("setup() - sensors.begin() done"); + // IMPORTANT: sensors.begin() calls initBasicGPS() which steals the GPS pins for Serial1 + // We need to reinitialize Serial2 to reclaim them + #if HAS_GPS + Serial2.end(); // Close any existing Serial2 + Serial2.begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN); + Serial.println("setup() - Reinitialized Serial2 for GPS after sensors.begin()"); + #endif + #ifdef DISPLAY_CLASS Serial.println("setup() - about to call ui_task.begin()"); ui_task.begin(disp, &sensors, the_mesh.getNodePrefs()); Serial.println("setup() - ui_task.begin() done"); #endif + // Enable GPS by default on T-Deck Pro + #if HAS_GPS + // Set GPS enabled in both sensor manager and node prefs + sensors.setSettingValue("gps", "1"); + the_mesh.getNodePrefs()->gps_enabled = 1; + the_mesh.savePrefs(); + Serial.println("setup() - GPS enabled by default"); + #endif + Serial.println("=== setup() - COMPLETE ==="); } @@ -303,4 +322,24 @@ void loop() { ui_task.loop(); #endif rtc_clock.tick(); -} + + // Debug: Check for GPS data on Serial2 + #if HAS_GPS + static unsigned long lastGpsDebug = 0; + if (millis() - lastGpsDebug > 5000) { // Every 5 seconds + lastGpsDebug = millis(); + Serial.print("GPS Debug - Serial2 available: "); + Serial.print(Serial2.available()); + Serial.print(" bytes"); + LocationProvider* loc = sensors.getLocationProvider(); + if (loc) { + Serial.print(", valid: "); + Serial.print(loc->isValid() ? "YES" : "NO"); + Serial.print(", sats: "); + Serial.println(loc->satellitesCount()); + } else { + Serial.println(", LocationProvider: NULL"); + } + } + #endif +} \ No newline at end of file diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 43c1bf6..aafb6f9 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -111,8 +111,8 @@ class HomeScreen : public UIScreen { if (batteryPercentage > 100) batteryPercentage = 100; // Clamp to 100% // battery icon - int iconWidth = 24; - int iconHeight = 10; + int iconWidth = 22; + int iconHeight = 8; int iconX = display.width() - iconWidth - 5; // Position the icon near the top-right corner int iconY = 0; display.setColor(DisplayDriver::GREEN); diff --git a/variants/lilygo_tdeck_pro/TDeckBoard.cpp b/variants/lilygo_tdeck_pro/TDeckBoard.cpp index 12bfc0a..0542c10 100644 --- a/variants/lilygo_tdeck_pro/TDeckBoard.cpp +++ b/variants/lilygo_tdeck_pro/TDeckBoard.cpp @@ -31,6 +31,22 @@ void TDeckBoard::begin() { Serial.println("TDeckBoard::begin() - LoRa power enabled"); #endif + // Enable GPS module power and initialize Serial2 + #if HAS_GPS + #ifdef PIN_GPS_EN + pinMode(PIN_GPS_EN, OUTPUT); + digitalWrite(PIN_GPS_EN, GPS_EN_ACTIVE); // GPS_EN_ACTIVE is 1 (HIGH) + delay(100); // Allow GPS to power up + Serial.println("TDeckBoard::begin() - GPS power enabled"); + #endif + + // Initialize Serial2 for GPS with correct pins + Serial2.begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN); + Serial.print("TDeckBoard::begin() - GPS Serial2 initialized at "); + Serial.print(GPS_BAUDRATE); + Serial.println(" baud"); + #endif + // Configure user button pinMode(PIN_USER_BTN, INPUT); diff --git a/variants/lilygo_tdeck_pro/TDeckBoard.h b/variants/lilygo_tdeck_pro/TDeckBoard.h index 980e478..42e8403 100644 --- a/variants/lilygo_tdeck_pro/TDeckBoard.h +++ b/variants/lilygo_tdeck_pro/TDeckBoard.h @@ -1,5 +1,6 @@ #pragma once +#include "variant.h" // Board-specific pin definitions #include #include #include "helpers/ESP32Board.h" diff --git a/variants/lilygo_tdeck_pro/platformio.ini b/variants/lilygo_tdeck_pro/platformio.ini index 71d2c79..36fca67 100644 --- a/variants/lilygo_tdeck_pro/platformio.ini +++ b/variants/lilygo_tdeck_pro/platformio.ini @@ -31,6 +31,7 @@ build_flags = -D P_LORA_MOSI=33 -D P_LORA_EN=46 -D ENV_INCLUDE_GPS=1 + -D ENV_SKIP_GPS_DETECT=1 -D PIN_GPS_RX=44 -D PIN_GPS_TX=43 -D GPS_BAUD_RATE=38400 @@ -112,9 +113,9 @@ extends = LilyGo_TDeck_Pro build_flags = ${LilyGo_TDeck_Pro.build_flags} -I examples/companion_radio/ui-new - -D MAX_CONTACTS=400 - -D MAX_GROUP_CHANNELS=20 - -D BLE_PIN_CODE=123456 + -D MAX_CONTACTS=350 + -D MAX_GROUP_CHANNELS=40 + -D BLE_PIN_CODE=234567 -D OFFLINE_QUEUE_SIZE=256 build_src_filter = ${LilyGo_TDeck_Pro.build_src_filter} + diff --git a/variants/lilygo_tdeck_pro/target.cpp b/variants/lilygo_tdeck_pro/target.cpp index e24d424..a045590 100644 --- a/variants/lilygo_tdeck_pro/target.cpp +++ b/variants/lilygo_tdeck_pro/target.cpp @@ -19,8 +19,10 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock); #if HAS_GPS MicroNMEALocationProvider gps(Serial2, &rtc_clock); EnvironmentSensorManager sensors(gps); + #pragma message "GPS enabled - using EnvironmentSensorManager with MicroNMEALocationProvider" #else SensorManager sensors; + #pragma message "GPS disabled - using basic SensorManager" #endif #ifdef DISPLAY_CLASS @@ -41,6 +43,15 @@ bool radio_init() { rtc_clock.begin(Wire); Serial.println("radio_init() - rtc_clock started"); + // Debug GPS status + #if HAS_GPS + Serial.println("radio_init() - HAS_GPS is defined"); + Serial.print("radio_init() - gps object address: "); + Serial.println((uint32_t)&gps, HEX); + #else + Serial.println("radio_init() - HAS_GPS is NOT defined"); + #endif + #if defined(P_LORA_SCLK) Serial.println("radio_init() - initializing LoRa SPI..."); loraSpi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI, P_LORA_NSS); diff --git a/variants/lilygo_tdeck_pro/target.h b/variants/lilygo_tdeck_pro/target.h index 6f54814..5e4193c 100644 --- a/variants/lilygo_tdeck_pro/target.h +++ b/variants/lilygo_tdeck_pro/target.h @@ -1,5 +1,8 @@ #pragma once +// Include variant.h first to ensure all board-specific defines are available +#include "variant.h" + #define RADIOLIB_STATIC_ONLY 1 #include #include