mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-03-30 06:20:00 +00:00
t-beam supreme: display fix, BME add, user btn fix
-Fixed build issues after display refactor -Added BME280 support and updated SensorManager to include this data -Fixed user button and verified it turns the display on
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,3 +8,4 @@ out/
|
||||
.direnv/
|
||||
.DS_Store
|
||||
.vscode/settings.json
|
||||
.vscode/extensions.json
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
|
||||
class SensorManager {
|
||||
public:
|
||||
double node_lat, node_lon; // modify these, if you want to affect Advert location
|
||||
double node_lat, node_lon, node_temp, node_hum, node_pres; // modify these, if you want to affect Advert location
|
||||
double node_altitude; // altitude in meters
|
||||
|
||||
SensorManager() { node_lat = 0; node_lon = 0; node_altitude = 0; }
|
||||
SensorManager() { node_lat = 0; node_lon = 0; node_altitude = 0; node_temp = 0; node_hum = 0; node_pres = 0;}
|
||||
virtual bool begin() { return false; }
|
||||
virtual bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) { return false; }
|
||||
virtual void loop() { }
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#define PIN_BOARD_SCL1 41 //SCL for PMU and PFC8563 (RTC)
|
||||
#define PIN_PMU_IRQ 40 //IRQ pin for PMU
|
||||
|
||||
#define PIN_USER_BTN 0
|
||||
//#define PIN_USER_BTN 0
|
||||
|
||||
#define P_BOARD_SPI_MOSI 35 //SPI for SD Card and QMI8653 (IMU)
|
||||
#define P_BOARD_SPI_MISO 37 //SPI for SD Card and QMI8653 (IMU)
|
||||
@@ -55,7 +55,9 @@ class TBeamS3SupremeBoard : public ESP32Board {
|
||||
XPowersAXP2101 PMU;
|
||||
public:
|
||||
#ifdef MESH_DEBUG
|
||||
void scanDevices(TwoWire *w);
|
||||
void printPMU();
|
||||
void printBMEValues();
|
||||
#endif
|
||||
bool power_init();
|
||||
|
||||
|
||||
@@ -8,18 +8,21 @@ build_flags =
|
||||
-D P_LORA_TX_LED=6
|
||||
-D PIN_BOARD_SDA=17
|
||||
-D PIN_BOARD_SCL=18
|
||||
-D PIN_USER_BTN=0
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
;-D DISPLAY_CLASS=SSD1306Display ;Needs to be modified for SH1106
|
||||
-D DISPLAY_CLASS=SH1106Display
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<../variants/lilygo_tbeam_supreme_SX1262>
|
||||
+<helpers/ui/SH1106Display.cpp>
|
||||
board_build.partitions = min_spiffs.csv ; get around 4mb flash limit
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
lewisxhe/XPowersLib @ ^0.2.7
|
||||
;adafruit/Adafruit SSD1306 @ ^2.5.13
|
||||
adafruit/Adafruit SH110X @ ^2.1.13
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
adafruit/Adafruit BME280 Library @ ^2.3.0
|
||||
|
||||
; === LILYGO T-Beam S3 Supreme with SX1262 environments ===
|
||||
[env:T_Beam_S3_Supreme_SX1262_repeater]
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
#include <Adafruit_BME280.h>
|
||||
|
||||
TBeamS3SupremeBoard board;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
bool pmuIntFlag;
|
||||
//#define SEALEVELPRESSURE_HPA (1013.25)
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
@@ -23,6 +29,7 @@ ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||
TbeamSupSensorManager sensors = TbeamSupSensorManager(nmea);
|
||||
Adafruit_BME280 bme;
|
||||
|
||||
static void setPMUIntFlag(){
|
||||
pmuIntFlag = true;
|
||||
@@ -46,7 +53,7 @@ void scanDevices(TwoWire *w)
|
||||
switch (addr) {
|
||||
case 0x77:
|
||||
case 0x76:
|
||||
Serial.println("\tFound BMX280 Sensor");
|
||||
Serial.println("\tFound BME280 Sensor");
|
||||
deviceOnline |= BME280_ONLINE;
|
||||
break;
|
||||
case 0x34:
|
||||
@@ -107,6 +114,26 @@ void TBeamS3SupremeBoard::printPMU()
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
void printBMEValues() {
|
||||
Serial.print("Temperature = ");
|
||||
Serial.print(bme.readTemperature());
|
||||
Serial.println(" *C");
|
||||
|
||||
Serial.print("Pressure = ");
|
||||
|
||||
Serial.print(bme.readPressure() / 100.0F);
|
||||
Serial.println(" hPa");
|
||||
|
||||
Serial.print("Approx. Altitude = ");
|
||||
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
|
||||
Serial.println(" m");
|
||||
|
||||
Serial.print("Humidity = ");
|
||||
Serial.print(bme.readHumidity());
|
||||
Serial.println(" %");
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool TBeamS3SupremeBoard::power_init()
|
||||
@@ -289,6 +316,10 @@ bool radio_init() {
|
||||
fallback_clock.begin();
|
||||
|
||||
rtc_clock.begin(Wire1);
|
||||
|
||||
// #ifdef MESH_DEBUG
|
||||
// printBMEValues();
|
||||
// #endif
|
||||
|
||||
#ifdef SX126X_DIO3_TCXO_VOLTAGE
|
||||
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
|
||||
@@ -340,8 +371,14 @@ 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!");
|
||||
}
|
||||
else
|
||||
MESH_DEBUG_PRINTLN("BME280 found and init!");
|
||||
|
||||
// init GPS port
|
||||
|
||||
Serial1.begin(GPS_BAUD_RATE, SERIAL_8N1, P_GPS_RX, P_GPS_TX);
|
||||
|
||||
bool result = false;
|
||||
@@ -359,22 +396,53 @@ bool TbeamSupSensorManager::querySensors(uint8_t requester_permissions, CayenneL
|
||||
if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission?
|
||||
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
|
||||
}
|
||||
if (requester_permissions & TELEM_PERM_ENVIRONMENT) { // does requester have permission?
|
||||
telemetry.addTemperature(TELEM_CHANNEL_SELF, node_temp);
|
||||
telemetry.addRelativeHumidity(TELEM_CHANNEL_SELF, node_hum);
|
||||
telemetry.addBarometricPressure(TELEM_CHANNEL_SELF, node_pres);
|
||||
//telemetry.addAltitude(TELEM_CHANNEL_SELF, node_alt);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void TbeamSupSensorManager::loop() {
|
||||
static long next_gps_update = 0;
|
||||
static long next_update = 0;
|
||||
|
||||
_nmea->loop();
|
||||
|
||||
if (millis() > next_gps_update) {
|
||||
if (millis() > next_update) {
|
||||
if (_nmea->isValid()) {
|
||||
node_lat = ((double)_nmea->getLatitude())/1000000.;
|
||||
node_lon = ((double)_nmea->getLongitude())/1000000.;
|
||||
node_altitude = ((double)_nmea->getAltitude()) / 1000.0;
|
||||
//Serial.printf("lat %f lon %f\r\n", _lat, _lon);
|
||||
}
|
||||
next_gps_update = millis() + 1000;
|
||||
|
||||
//read BME280 values
|
||||
//node_alt = bme.readAltitude(SEALEVELPRESSURE_HPA);
|
||||
node_temp = bme.readTemperature();
|
||||
node_hum = bme.readHumidity();
|
||||
node_pres = (bme.readPressure() / 100.0F);
|
||||
|
||||
#ifdef MESH_DEBUG
|
||||
Serial.print("Temperature = ");
|
||||
Serial.print(node_temp);
|
||||
Serial.println(" *C");
|
||||
|
||||
Serial.print("Humidity = ");
|
||||
Serial.print(node_hum);
|
||||
Serial.println(" %");
|
||||
|
||||
Serial.print("Pressure = ");
|
||||
Serial.print(node_pres);
|
||||
Serial.println(" hPa");
|
||||
|
||||
// Serial.print("Approx. Altitude = ");
|
||||
// Serial.print(node_alt);
|
||||
// Serial.println(" m");
|
||||
#endif
|
||||
|
||||
next_update = millis() + 1000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,11 @@ extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern TbeamSupSensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SH1106Display.h>
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
enum {
|
||||
POWERMANAGE_ONLINE = _BV(0),
|
||||
DISPLAY_ONLINE = _BV(1),
|
||||
|
||||
Reference in New Issue
Block a user