thinknode_m5: gps support

This commit is contained in:
Florent 2025-11-28 11:11:13 +01:00
parent ee4e87c3ee
commit 1c0017b634
8 changed files with 53 additions and 15 deletions

View file

@ -260,13 +260,24 @@ public:
#if ENV_INCLUDE_GPS == 1
} else if (_page == HomePage::GPS) {
LocationProvider* nmea = sensors.getLocationProvider();
char buf[50];
int y = 18;
display.drawTextLeftAlign(0, y, _task->getGPSState() ? "gps on" : "gps off");
bool gps_state = _task->getGPSState();
#ifdef PIN_GPS_SWITCH
bool hw_gps_state = digitalRead(PIN_GPS_SWITCH);
if (gps_state != hw_gps_state) {
strcpy(buf, gps_state ? "gps off(hw)" : "gps off(sw)");
} else {
strcpy(buf, gps_state ? "gps on" : "gps off");
}
#else
strcpy(buf, gps_state ? "gps on" : "gps off");
#endif
display.drawTextLeftAlign(0, y, buf);
if (nmea == NULL) {
y = y + 12;
display.drawTextLeftAlign(0, y, "Can't access GPS");
} else {
char buf[50];
strcpy(buf, nmea->isValid()?"fix":"no fix");
display.drawTextRightAlign(display.width()-1, y, buf);
y = y + 12;

View file

@ -548,7 +548,11 @@ void EnvironmentSensorManager::initBasicGPS() {
delay(1000);
// We'll consider GPS detected if we see any data on Serial1
#ifdef ENV_SKIP_GPS_DETECT
gps_detected = true;
#else
gps_detected = (Serial1.available() > 0);
#endif
if (gps_detected) {
MESH_DEBUG_PRINTLN("GPS detected");

View file

@ -11,6 +11,11 @@ void ThinknodeM5Board::begin() {
expander.digitalWrite(EXP_PIN_POWER, HIGH);
expander.digitalWrite(EXP_PIN_BACKLIGHT, LOW);
expander.digitalWrite(EXP_PIN_LED, LOW);
#ifdef PIN_GPS_SWITCH
pinMode(PIN_GPS_SWITCH, INPUT);
#endif
ESP32Board::begin();
}

View file

@ -12,8 +12,8 @@
#define USB_PID 0x1001
// Serial
static const uint8_t TX = GPS_TX;
static const uint8_t RX = GPS_RX;
static const uint8_t TX = PIN_GPS_TX;
static const uint8_t RX = PIN_GPS_RX;
// Default SPI will be mapped to Radio
static const uint8_t SS = P_LORA_NSS;

View file

@ -3,9 +3,8 @@ extends = esp32_base
board = ESP32-S3-WROOM-1-N4
build_flags = ${esp32_base.build_flags}
-I variants/thinknode_m5
-I src/helpres/sensors
-D THINKNODE_M5
-D GPS_RX=19
-D GPS_TX=20
-D PIN_BUZZER=9
-D PIN_BOARD_SCL=1
-D PIN_BOARD_SDA=2
@ -19,10 +18,7 @@ build_flags = ${esp32_base.build_flags}
-D P_LORA_MOSI=15
-D PIN_USER_BTN=21
-D PIN_BUTTON2=14
-D EXP_PIN_LED=1
# -D PIN_STATUS_LED=1 ; leds are on PCA !!!
# -D LED_STATE_ON=HIGH
# -D PIN_LED=3
-D EXP_PIN_LED=1 ; led is on bus expander
-D DISPLAY_ROTATION=4
-D DISPLAY_CLASS=GxEPDDisplay
-D EINK_DISPLAY_MODEL=GxEPD2_154_D67
@ -32,6 +28,7 @@ build_flags = ${esp32_base.build_flags}
-D EINK_Y_OFFSET=10
-D BACKLIGHT_BTN=PIN_BUTTON2
-D AUTO_OFF_MILLIS=0
-D DISABLE_DIAGNOSTIC_OUTPUT
-D SX126X_DIO2_AS_RF_SWITCH=true
-D SX126X_DIO3_TCXO_VOLTAGE=3.3
-D SX126X_CURRENT_LIMIT=140
@ -40,7 +37,11 @@ build_flags = ${esp32_base.build_flags}
-D LORA_TX_POWER=22
-D SX126X_RX_BOOSTED_GAIN=1
-D MESH_DEBUG=1
-D ENV_INCLUDE_GPS=1
-D PERSISTANT_GPS=1
-D ENV_SKIP_GPS_DETECT=1
build_src_filter = ${esp32_base.build_src_filter}
+<helpers/sensors/EnvironmentSensorManager.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/ui/GxEPDDisplay.cpp>
+<helpers/ui/buzzer.cpp>
@ -49,6 +50,7 @@ lib_deps = ${esp32_base.lib_deps}
zinggjm/GxEPD2 @ 1.6.2
bakercp/CRC32 @ ^2.0.0
maxpromer/PCA9557-arduino
stevemarple/MicroNMEA @ ^2.0.6
[env:ThinkNode_M5_Repeater]
extends = ThinkNode_M5
@ -109,7 +111,7 @@ lib_deps =
${esp32_ota.lib_deps}
[env:ThinkNode_M5_room_server]
extends = ThinkNode_M5
extends = ThinkNonde_M5
build_src_filter = ${ThinkNode_M5.build_src_filter}
+<../examples/simple_room_server>
build_flags =
@ -148,9 +150,10 @@ build_flags =
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
-D OFFLINE_QUEUE_SIZE=256
-D UI_RECENT_LIST_SIZE=9
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
; -D GPS_NMEA_DEBUG
build_src_filter = ${ThinkNode_M5.build_src_filter}
+<helpers/esp32/*.cpp>
+<helpers/ui/MomentaryButton.cpp>

View file

@ -1,5 +1,6 @@
#include <Arduino.h>
#include "target.h"
#include <helpers/sensors/MicroNMEALocationProvider.h>
ThinknodeM5Board board;
@ -14,7 +15,13 @@ WRAPPER_CLASS radio_driver(radio, board);
ESP32RTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
SensorManager sensors;
#ifdef ENV_INCLUDE_GPS
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors = EnvironmentSensorManager();
#endif
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;

View file

@ -8,6 +8,8 @@
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/EnvironmentSensorManager.h>
#include <helpers/sensors/LocationProvider.h>
#ifdef DISPLAY_CLASS
#include <helpers/ui/GxEPDDisplay.h>
#include <helpers/ui/MomentaryButton.h>
@ -16,7 +18,7 @@
extern ThinknodeM5Board board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern SensorManager sensors;
extern EnvironmentSensorManager sensors;
extern PCA9557 expander;
#ifdef DISPLAY_CLASS

View file

@ -19,4 +19,10 @@
#define PIN_DISPLAY_RST (41)
#define PIN_DISPLAY_BUSY (42)
#define EXP_PIN_BACKLIGHT (5)
#define EXP_PIN_POWER (4)
#define EXP_PIN_POWER (4)
#define PIN_GPS_EN (11)
#define PIN_GPS_RESET (13)
#define PIN_GPS_RX (20)
#define PIN_GPS_TX (19)
#define PIN_GPS_SWITCH (10)