Merge pull request #922 from recrof/station_g2_cleanup

station g2 cleanup
This commit is contained in:
ripplebiz 2025-10-19 14:11:20 +11:00 committed by GitHub
commit 798725d450
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 45 additions and 23 deletions

View file

@ -0,0 +1,54 @@
#pragma once
#include <Arduino.h>
#include <helpers/ESP32Board.h>
#include <driver/rtc_io.h>
class StationG2Board : public ESP32Board {
public:
void begin() {
ESP32Board::begin();
esp_reset_reason_t reason = esp_reset_reason();
if (reason == ESP_RST_DEEPSLEEP) {
long wakeup_source = esp_sleep_get_ext1_wakeup_status();
if (wakeup_source & (1 << P_LORA_DIO_1)) { // received a LoRa packet (while in deep sleep)
startup_reason = BD_STARTUP_RX_PACKET;
}
rtc_gpio_hold_dis((gpio_num_t)P_LORA_NSS);
rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_1);
}
}
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
if (pin_wake_btn < 0) {
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
} else {
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
}
if (secs > 0) {
esp_sleep_enable_timer_wakeup(secs * 1000000);
}
// Finally set ESP32 into sleep
esp_deep_sleep_start(); // CPU halts here and never returns!
}
uint16_t getBattMilliVolts() override {
return 0;
}
const char* getManufacturerName() const override {
return "Station G2";
}
};

View file

@ -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

View file

@ -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;

View file

@ -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;