mirror of
https://github.com/pelgraine/Meck.git
synced 2026-03-28 17:42:44 +01:00
”Amend mymesh.h to Meck v0.3 || ‘target.h’ - Added #include "variant.h" at the top to ensure HAS_GPS is always defined before the conditional includes || target.cpp - Added debug output to verify HAS_GPS is defined at compile and runtime || ‘TDeckBoard.h’ - Added #include "variant.h" for pin definitions || Added #include "variant.h" to ‘main.cpp’ to ensure HAS_GPS is defined || Added code to ‘main.cpp’ to enable GPS by default after sensors.begin() as longpress not currently functional for gps toggle || Changed battery icon size in ‘uitask.cpp’ from 24 to 22 width and 10 to 8 height.”
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <Arduino.h> // needed for PlatformIO
|
||||
#include <Mesh.h>
|
||||
#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
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "variant.h" // Board-specific pin definitions
|
||||
#include <Wire.h>
|
||||
#include <Arduino.h>
|
||||
#include "helpers/ESP32Board.h"
|
||||
|
||||
@@ -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}
|
||||
+<helpers/esp32/*.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);
|
||||
|
||||
@@ -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 <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
|
||||
Reference in New Issue
Block a user