From e742d1f7228a4e155b2b98178744c39cf8dd884c Mon Sep 17 00:00:00 2001 From: cod3doomy Date: Thu, 22 May 2025 16:50:06 -0700 Subject: [PATCH] t-beam supreme: minor GPS and BME fixes Fixed GPS initial state to default to off after init. Removed redundant current limit define --- .../platformio.ini | 1 - .../lilygo_tbeam_supreme_SX1262/target.cpp | 54 +++++++++++-------- variants/lilygo_tbeam_supreme_SX1262/target.h | 2 + 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/variants/lilygo_tbeam_supreme_SX1262/platformio.ini b/variants/lilygo_tbeam_supreme_SX1262/platformio.ini index 4367dc15..8e46f22c 100644 --- a/variants/lilygo_tbeam_supreme_SX1262/platformio.ini +++ b/variants/lilygo_tbeam_supreme_SX1262/platformio.ini @@ -12,7 +12,6 @@ build_flags = -D RADIO_CLASS=CustomSX1262 -D WRAPPER_CLASS=CustomSX1262Wrapper -D DISPLAY_CLASS=SH1106Display - -D SX126X_CURRENT_LIMIT=140 -D SX126X_RX_BOOSTED_GAIN=1 -D SX126X_CURRENT_LIMIT=140 build_src_filter = ${esp32_base.build_src_filter} diff --git a/variants/lilygo_tbeam_supreme_SX1262/target.cpp b/variants/lilygo_tbeam_supreme_SX1262/target.cpp index 4dbfd625..dfe453ee 100644 --- a/variants/lilygo_tbeam_supreme_SX1262/target.cpp +++ b/variants/lilygo_tbeam_supreme_SX1262/target.cpp @@ -370,23 +370,28 @@ void TbeamSupSensorManager::sleep_gps() { bool TbeamSupSensorManager::begin() { //init BME280 if (! bme.begin(0x77, &Wire)) { - MESH_DEBUG_PRINTLN("Could not find a valid BME280 sensor, check wiring!"); + MESH_DEBUG_PRINTLN("Could not find a valid BME280 sensor"); + bme_active = false; } else MESH_DEBUG_PRINTLN("BME280 found and init!"); + bme_active = true; // init GPS port Serial1.begin(GPS_BAUD_RATE, SERIAL_8N1, P_GPS_RX, P_GPS_TX); - bool result = false; + bool gps_alive = false; for ( int i = 0; i < 3; ++i) { - result = l76kProbe(); - if (result) { - gps_active = true; - return result; + gps_alive = l76kProbe(); + if (gps_alive) { + MESH_DEBUG_PRINTLN("GPS is init and active. Shutting down for initial state."); + sleep_gps(); + return gps_alive; } } - return result; + gps_active = gps_alive; + MESH_DEBUG_PRINTLN("GPS init failed and GPS is not active"); + return gps_alive; } bool TbeamSupSensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) { @@ -422,17 +427,17 @@ void TbeamSupSensorManager::loop() { node_pres = (bme.readPressure() / 100.0F); #ifdef MESH_DEBUG - Serial.print("Temperature = "); - Serial.print(node_temp); - Serial.println(" *C"); + // Serial.print("Temperature = "); + // Serial.print(node_temp); + // Serial.println(" *C"); - Serial.print("Humidity = "); - Serial.print(node_hum); - Serial.println(" %"); + // Serial.print("Humidity = "); + // Serial.print(node_hum); + // Serial.println(" %"); - Serial.print("Pressure = "); - Serial.print(node_pres); - Serial.println(" hPa"); + // Serial.print("Pressure = "); + // Serial.print(node_pres); + // Serial.println(" hPa"); // Serial.print("Approx. Altitude = "); // Serial.print(node_alt); @@ -443,17 +448,24 @@ void TbeamSupSensorManager::loop() { } } -int TbeamSupSensorManager::getNumSettings() const { return 1; } // just one supported: "gps" (power switch) +int TbeamSupSensorManager::getNumSettings() const { + return sensorNum; +} const char* TbeamSupSensorManager::getSettingName(int i) const { - return i == 0 ? "gps" : NULL; + switch(i){ + case 0: return "gps"; + case 1: return "bme280"; + default: NULL; + } } const char* TbeamSupSensorManager::getSettingValue(int i) const { - if (i == 0) { - return gps_active ? "1" : "0"; + switch(i){ + case 0: return gps_active == true ? "1" : "0"; + case 1: return bme_active == true ? "1" : "0"; + default: NULL; } - return NULL; } bool TbeamSupSensorManager::setSettingValue(const char* name, const char* value) { diff --git a/variants/lilygo_tbeam_supreme_SX1262/target.h b/variants/lilygo_tbeam_supreme_SX1262/target.h index dbb24a8e..6acf6cdf 100644 --- a/variants/lilygo_tbeam_supreme_SX1262/target.h +++ b/variants/lilygo_tbeam_supreme_SX1262/target.h @@ -12,9 +12,11 @@ class TbeamSupSensorManager: public SensorManager { bool gps_active = false; + bool bme_active = false; LocationProvider * _nmea; Adafruit_BME280 bme; double node_temp, node_hum, node_pres; + int sensorNum = 2; #define SEALEVELPRESSURE_HPA (1013.25)