Skip to content

Commit 1c0017b

Browse files
committed
thinknode_m5: gps support
1 parent ee4e87c commit 1c0017b

File tree

8 files changed

+53
-15
lines changed

8 files changed

+53
-15
lines changed

examples/companion_radio/ui-new/UITask.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,24 @@ class HomeScreen : public UIScreen {
260260
#if ENV_INCLUDE_GPS == 1
261261
} else if (_page == HomePage::GPS) {
262262
LocationProvider* nmea = sensors.getLocationProvider();
263+
char buf[50];
263264
int y = 18;
264-
display.drawTextLeftAlign(0, y, _task->getGPSState() ? "gps on" : "gps off");
265+
bool gps_state = _task->getGPSState();
266+
#ifdef PIN_GPS_SWITCH
267+
bool hw_gps_state = digitalRead(PIN_GPS_SWITCH);
268+
if (gps_state != hw_gps_state) {
269+
strcpy(buf, gps_state ? "gps off(hw)" : "gps off(sw)");
270+
} else {
271+
strcpy(buf, gps_state ? "gps on" : "gps off");
272+
}
273+
#else
274+
strcpy(buf, gps_state ? "gps on" : "gps off");
275+
#endif
276+
display.drawTextLeftAlign(0, y, buf);
265277
if (nmea == NULL) {
266278
y = y + 12;
267279
display.drawTextLeftAlign(0, y, "Can't access GPS");
268280
} else {
269-
char buf[50];
270281
strcpy(buf, nmea->isValid()?"fix":"no fix");
271282
display.drawTextRightAlign(display.width()-1, y, buf);
272283
y = y + 12;

src/helpers/sensors/EnvironmentSensorManager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,11 @@ void EnvironmentSensorManager::initBasicGPS() {
548548
delay(1000);
549549

550550
// We'll consider GPS detected if we see any data on Serial1
551+
#ifdef ENV_SKIP_GPS_DETECT
552+
gps_detected = true;
553+
#else
551554
gps_detected = (Serial1.available() > 0);
555+
#endif
552556

553557
if (gps_detected) {
554558
MESH_DEBUG_PRINTLN("GPS detected");

variants/thinknode_m5/ThinknodeM5Board.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ void ThinknodeM5Board::begin() {
1111
expander.digitalWrite(EXP_PIN_POWER, HIGH);
1212
expander.digitalWrite(EXP_PIN_BACKLIGHT, LOW);
1313
expander.digitalWrite(EXP_PIN_LED, LOW);
14+
15+
#ifdef PIN_GPS_SWITCH
16+
pinMode(PIN_GPS_SWITCH, INPUT);
17+
#endif
18+
1419
ESP32Board::begin();
1520
}
1621

variants/thinknode_m5/pins_arduino.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#define USB_PID 0x1001
1313

1414
// Serial
15-
static const uint8_t TX = GPS_TX;
16-
static const uint8_t RX = GPS_RX;
15+
static const uint8_t TX = PIN_GPS_TX;
16+
static const uint8_t RX = PIN_GPS_RX;
1717

1818
// Default SPI will be mapped to Radio
1919
static const uint8_t SS = P_LORA_NSS;

variants/thinknode_m5/platformio.ini

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ extends = esp32_base
33
board = ESP32-S3-WROOM-1-N4
44
build_flags = ${esp32_base.build_flags}
55
-I variants/thinknode_m5
6+
-I src/helpres/sensors
67
-D THINKNODE_M5
7-
-D GPS_RX=19
8-
-D GPS_TX=20
98
-D PIN_BUZZER=9
109
-D PIN_BOARD_SCL=1
1110
-D PIN_BOARD_SDA=2
@@ -19,10 +18,7 @@ build_flags = ${esp32_base.build_flags}
1918
-D P_LORA_MOSI=15
2019
-D PIN_USER_BTN=21
2120
-D PIN_BUTTON2=14
22-
-D EXP_PIN_LED=1
23-
# -D PIN_STATUS_LED=1 ; leds are on PCA !!!
24-
# -D LED_STATE_ON=HIGH
25-
# -D PIN_LED=3
21+
-D EXP_PIN_LED=1 ; led is on bus expander
2622
-D DISPLAY_ROTATION=4
2723
-D DISPLAY_CLASS=GxEPDDisplay
2824
-D EINK_DISPLAY_MODEL=GxEPD2_154_D67
@@ -32,6 +28,7 @@ build_flags = ${esp32_base.build_flags}
3228
-D EINK_Y_OFFSET=10
3329
-D BACKLIGHT_BTN=PIN_BUTTON2
3430
-D AUTO_OFF_MILLIS=0
31+
-D DISABLE_DIAGNOSTIC_OUTPUT
3532
-D SX126X_DIO2_AS_RF_SWITCH=true
3633
-D SX126X_DIO3_TCXO_VOLTAGE=3.3
3734
-D SX126X_CURRENT_LIMIT=140
@@ -40,7 +37,11 @@ build_flags = ${esp32_base.build_flags}
4037
-D LORA_TX_POWER=22
4138
-D SX126X_RX_BOOSTED_GAIN=1
4239
-D MESH_DEBUG=1
40+
-D ENV_INCLUDE_GPS=1
41+
-D PERSISTANT_GPS=1
42+
-D ENV_SKIP_GPS_DETECT=1
4343
build_src_filter = ${esp32_base.build_src_filter}
44+
+<helpers/sensors/EnvironmentSensorManager.cpp>
4445
+<helpers/ui/MomentaryButton.cpp>
4546
+<helpers/ui/GxEPDDisplay.cpp>
4647
+<helpers/ui/buzzer.cpp>
@@ -49,6 +50,7 @@ lib_deps = ${esp32_base.lib_deps}
4950
zinggjm/GxEPD2 @ 1.6.2
5051
bakercp/CRC32 @ ^2.0.0
5152
maxpromer/PCA9557-arduino
53+
stevemarple/MicroNMEA @ ^2.0.6
5254

5355
[env:ThinkNode_M5_Repeater]
5456
extends = ThinkNode_M5
@@ -109,7 +111,7 @@ lib_deps =
109111
${esp32_ota.lib_deps}
110112

111113
[env:ThinkNode_M5_room_server]
112-
extends = ThinkNode_M5
114+
extends = ThinkNonde_M5
113115
build_src_filter = ${ThinkNode_M5.build_src_filter}
114116
+<../examples/simple_room_server>
115117
build_flags =
@@ -148,9 +150,10 @@ build_flags =
148150
-D MAX_GROUP_CHANNELS=40
149151
-D BLE_PIN_CODE=123456
150152
-D OFFLINE_QUEUE_SIZE=256
153+
-D UI_RECENT_LIST_SIZE=9
151154
; -D BLE_DEBUG_LOGGING=1
152155
; -D MESH_PACKET_LOGGING=1
153-
; -D MESH_DEBUG=1
156+
; -D GPS_NMEA_DEBUG
154157
build_src_filter = ${ThinkNode_M5.build_src_filter}
155158
+<helpers/esp32/*.cpp>
156159
+<helpers/ui/MomentaryButton.cpp>

variants/thinknode_m5/target.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <Arduino.h>
22
#include "target.h"
3+
#include <helpers/sensors/MicroNMEALocationProvider.h>
34

45
ThinknodeM5Board board;
56

@@ -14,7 +15,13 @@ WRAPPER_CLASS radio_driver(radio, board);
1415

1516
ESP32RTCClock fallback_clock;
1617
AutoDiscoverRTCClock rtc_clock(fallback_clock);
17-
SensorManager sensors;
18+
19+
#ifdef ENV_INCLUDE_GPS
20+
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
21+
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
22+
#else
23+
EnvironmentSensorManager sensors = EnvironmentSensorManager();
24+
#endif
1825

1926
#ifdef DISPLAY_CLASS
2027
DISPLAY_CLASS display;

variants/thinknode_m5/target.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <helpers/radiolib/CustomSX1262Wrapper.h>
99
#include <helpers/AutoDiscoverRTCClock.h>
1010
#include <helpers/SensorManager.h>
11+
#include <helpers/sensors/EnvironmentSensorManager.h>
12+
#include <helpers/sensors/LocationProvider.h>
1113
#ifdef DISPLAY_CLASS
1214
#include <helpers/ui/GxEPDDisplay.h>
1315
#include <helpers/ui/MomentaryButton.h>
@@ -16,7 +18,7 @@
1618
extern ThinknodeM5Board board;
1719
extern WRAPPER_CLASS radio_driver;
1820
extern AutoDiscoverRTCClock rtc_clock;
19-
extern SensorManager sensors;
21+
extern EnvironmentSensorManager sensors;
2022
extern PCA9557 expander;
2123

2224
#ifdef DISPLAY_CLASS

variants/thinknode_m5/variant.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@
1919
#define PIN_DISPLAY_RST (41)
2020
#define PIN_DISPLAY_BUSY (42)
2121
#define EXP_PIN_BACKLIGHT (5)
22-
#define EXP_PIN_POWER (4)
22+
#define EXP_PIN_POWER (4)
23+
24+
#define PIN_GPS_EN (11)
25+
#define PIN_GPS_RESET (13)
26+
#define PIN_GPS_RX (20)
27+
#define PIN_GPS_TX (19)
28+
#define PIN_GPS_SWITCH (10)

0 commit comments

Comments
 (0)