t-beam supreme: minor GPS and BME fixes

Fixed GPS initial state to default to off after init.
Removed redundant current limit define
This commit is contained in:
cod3doomy
2025-05-22 16:50:06 -07:00
parent 77bfc0db1c
commit e742d1f722
3 changed files with 35 additions and 22 deletions

View File

@@ -12,7 +12,6 @@ build_flags =
-D RADIO_CLASS=CustomSX1262 -D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper -D WRAPPER_CLASS=CustomSX1262Wrapper
-D DISPLAY_CLASS=SH1106Display -D DISPLAY_CLASS=SH1106Display
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1 -D SX126X_RX_BOOSTED_GAIN=1
-D SX126X_CURRENT_LIMIT=140 -D SX126X_CURRENT_LIMIT=140
build_src_filter = ${esp32_base.build_src_filter} build_src_filter = ${esp32_base.build_src_filter}

View File

@@ -370,23 +370,28 @@ void TbeamSupSensorManager::sleep_gps() {
bool TbeamSupSensorManager::begin() { bool TbeamSupSensorManager::begin() {
//init BME280 //init BME280
if (! bme.begin(0x77, &Wire)) { 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 else
MESH_DEBUG_PRINTLN("BME280 found and init!"); MESH_DEBUG_PRINTLN("BME280 found and init!");
bme_active = true;
// init GPS port // init GPS port
Serial1.begin(GPS_BAUD_RATE, SERIAL_8N1, P_GPS_RX, P_GPS_TX); 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) { for ( int i = 0; i < 3; ++i) {
result = l76kProbe(); gps_alive = l76kProbe();
if (result) { if (gps_alive) {
gps_active = true; MESH_DEBUG_PRINTLN("GPS is init and active. Shutting down for initial state.");
return result; 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) { bool TbeamSupSensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) {
@@ -422,17 +427,17 @@ void TbeamSupSensorManager::loop() {
node_pres = (bme.readPressure() / 100.0F); node_pres = (bme.readPressure() / 100.0F);
#ifdef MESH_DEBUG #ifdef MESH_DEBUG
Serial.print("Temperature = "); // Serial.print("Temperature = ");
Serial.print(node_temp); // Serial.print(node_temp);
Serial.println(" *C"); // Serial.println(" *C");
Serial.print("Humidity = "); // Serial.print("Humidity = ");
Serial.print(node_hum); // Serial.print(node_hum);
Serial.println(" %"); // Serial.println(" %");
Serial.print("Pressure = "); // Serial.print("Pressure = ");
Serial.print(node_pres); // Serial.print(node_pres);
Serial.println(" hPa"); // Serial.println(" hPa");
// Serial.print("Approx. Altitude = "); // Serial.print("Approx. Altitude = ");
// Serial.print(node_alt); // 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 { 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 { const char* TbeamSupSensorManager::getSettingValue(int i) const {
if (i == 0) { switch(i){
return gps_active ? "1" : "0"; 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) { bool TbeamSupSensorManager::setSettingValue(const char* name, const char* value) {

View File

@@ -12,9 +12,11 @@
class TbeamSupSensorManager: public SensorManager { class TbeamSupSensorManager: public SensorManager {
bool gps_active = false; bool gps_active = false;
bool bme_active = false;
LocationProvider * _nmea; LocationProvider * _nmea;
Adafruit_BME280 bme; Adafruit_BME280 bme;
double node_temp, node_hum, node_pres; double node_temp, node_hum, node_pres;
int sensorNum = 2;
#define SEALEVELPRESSURE_HPA (1013.25) #define SEALEVELPRESSURE_HPA (1013.25)