Ver código fonte

move StationG2Board.h to variants, enable ESM, add companion wifi, cleanup

recrof 10 meses atrás
pai
commit
7cb2e0863a

+ 1 - 16
src/helpers/StationG2Board.h → variants/station_g2/StationG2Board.h

@@ -1,22 +1,7 @@
 #pragma once
 
 #include <Arduino.h>
-
-// LoRa radio module pins for Station G2
-#define  P_LORA_DIO_1   48
-#define  P_LORA_NSS     11
-#define  P_LORA_RESET   21
-#define  P_LORA_BUSY    47
-#define  P_LORA_SCLK    12
-#define  P_LORA_MISO    14
-#define  P_LORA_MOSI    13
-
-// built-ins
-//#define  PIN_LED_BUILTIN 35
-//#define  PIN_VEXT_EN     36
-
-#include "ESP32Board.h"
-
+#include <helpers/ESP32Board.h>
 #include <driver/rtc_io.h>
 
 class StationG2Board : public ESP32Board {

+ 33 - 3
variants/station_g2/platformio.ini

@@ -3,28 +3,40 @@ extends = esp32_base
 board = station-g2
 build_flags =
   ${esp32_base.build_flags}
+  ${sensor_base.build_flags}
   -I variants/station_g2
+  -I src/helpers/ui
   -D STATION_G2
   -D RADIO_CLASS=CustomSX1262
   -D WRAPPER_CLASS=CustomSX1262Wrapper
+  -D P_LORA_DIO_1=48
+  -D P_LORA_NSS=11
+  -D P_LORA_RESET=21
+  -D P_LORA_BUSY=47
+  -D P_LORA_SCLK=12
+  -D P_LORA_MISO=14
+  -D P_LORA_MOSI=13
   -D LORA_TX_POWER=19
 ;  -D P_LORA_TX_LED=35
   -D PIN_BOARD_SDA=5
   -D PIN_BOARD_SCL=6
   -D PIN_USER_BTN=38
+  -D PIN_GPS_RX=7
+  -D PIN_GPS_TX=15
   -D SX126X_DIO2_AS_RF_SWITCH=true
   -D SX126X_DIO3_TCXO_VOLTAGE=1.8
   -D SX126X_CURRENT_LIMIT=140
 ;  -D SX126X_RX_BOOSTED_GAIN=1 - DO NOT ENABLE THIS!
 ;  https://wiki.uniteng.com/en/meshtastic/station-g2#impact-of-lora-node-dense-areashigh-noise-environments-on-rf-performance
-  -I src/helpers/ui
   -D DISPLAY_CLASS=SH1106Display
 build_src_filter = ${esp32_base.build_src_filter}
   +<../variants/station_g2>
+  +<helpers/sensors>
   +<helpers/ui/SH1106Display.cpp>
   +<helpers/ui/MomentaryButton.cpp>
 lib_deps =
   ${esp32_base.lib_deps}
+  ${sensor_base.lib_deps}
   adafruit/Adafruit SH110X @ ~2.1.13
   adafruit/Adafruit GFX Library @ ^1.12.1
 
@@ -172,7 +184,6 @@ extends = Station_G2
 build_flags =
   ${Station_G2.build_flags}
   -I examples/companion_radio/ui-new
-  -D DISPLAY_CLASS=SH1106Display
   -D MAX_CONTACTS=300
   -D MAX_GROUP_CHANNELS=8
 ; NOTE: DO NOT ENABLE -->  -D MESH_PACKET_LOGGING=1
@@ -190,7 +201,6 @@ extends = Station_G2
 build_flags =
   ${Station_G2.build_flags}
   -I examples/companion_radio/ui-new
-  -D DISPLAY_CLASS=SH1106Display
   -D MAX_CONTACTS=300
   -D MAX_GROUP_CHANNELS=8
   -D BLE_PIN_CODE=123456
@@ -205,3 +215,23 @@ build_src_filter = ${Station_G2.build_src_filter}
 lib_deps =
   ${Station_G2.lib_deps}
   densaugeo/base64 @ ~1.4.0
+
+[env:Station_G2_companion_radio_wifi]
+extends = Station_G2
+build_flags =
+  ${Station_G2.build_flags}
+  -I examples/companion_radio/ui-new
+  -D MAX_CONTACTS=300
+  -D MAX_GROUP_CHANNELS=8
+  -D WIFI_DEBUG_LOGGING=1
+  -D WIFI_SSID='"myssid"'
+  -D WIFI_PWD='"mypwd"'
+; -D MESH_PACKET_LOGGING=1
+; -D MESH_DEBUG=1
+build_src_filter = ${Station_G2.build_src_filter}
+  +<helpers/esp32/*.cpp>
+  +<../examples/companion_radio/*.cpp>
+  +<../examples/companion_radio/ui-new/*.cpp>
+lib_deps =
+  ${Station_G2.lib_deps}
+  densaugeo/base64 @ ~1.4.0

+ 8 - 1
variants/station_g2/target.cpp

@@ -14,7 +14,14 @@ WRAPPER_CLASS radio_driver(radio, board);
 
 ESP32RTCClock fallback_clock;
 AutoDiscoverRTCClock rtc_clock(fallback_clock);
-SensorManager sensors;
+
+#if ENV_INCLUDE_GPS
+  #include <helpers/sensors/MicroNMEALocationProvider.h>
+  MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
+  EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
+#else
+  EnvironmentSensorManager sensors;
+#endif
 
 #ifdef DISPLAY_CLASS
   DISPLAY_CLASS display;

+ 3 - 3
variants/station_g2/target.h

@@ -3,10 +3,10 @@
 #define RADIOLIB_STATIC_ONLY 1
 #include <RadioLib.h>
 #include <helpers/radiolib/RadioLibWrappers.h>
-#include <helpers/StationG2Board.h>
+#include <StationG2Board.h>
 #include <helpers/radiolib/CustomSX1262Wrapper.h>
 #include <helpers/AutoDiscoverRTCClock.h>
-#include <helpers/SensorManager.h>
+#include <helpers/sensors/EnvironmentSensorManager.h>
 
 #ifdef DISPLAY_CLASS
   #include <helpers/ui/SH1106Display.h>
@@ -16,7 +16,7 @@
 extern StationG2Board board;
 extern WRAPPER_CLASS radio_driver;
 extern AutoDiscoverRTCClock rtc_clock;
-extern SensorManager sensors;
+extern EnvironmentSensorManager sensors;
 
 #ifdef DISPLAY_CLASS
   extern DISPLAY_CLASS display;