* EnvironmentSensorManager: some tidy ups
This commit is contained in:
@@ -1,15 +1,29 @@
|
|||||||
#include "EnvironmentSensorManager.h"
|
#include "EnvironmentSensorManager.h"
|
||||||
|
|
||||||
#if ENV_INCLUDE_AHTX0
|
#if ENV_INCLUDE_AHTX0
|
||||||
|
#define TELEM_AHTX_ADDRESS 0x38 // AHT10, AHT20 temperature and humidity sensor I2C address
|
||||||
|
#include <Adafruit_AHTX0.h>
|
||||||
static Adafruit_AHTX0 AHTX0;
|
static Adafruit_AHTX0 AHTX0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENV_INCLUDE_BME280
|
#if ENV_INCLUDE_BME280
|
||||||
|
#define TELEM_BME280_ADDRESS 0x76 // BME280 environmental sensor I2C address
|
||||||
|
#define TELEM_BME280_SEALEVELPRESSURE_HPA (1013.25) // Athmospheric pressure at sea level
|
||||||
|
#include <Adafruit_BME280.h>
|
||||||
static Adafruit_BME280 BME280;
|
static Adafruit_BME280 BME280;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENV_INCLUDE_INA3221
|
#if ENV_INCLUDE_INA3221
|
||||||
|
#define TELEM_INA3221_ADDRESS 0x42 // INA3221 3 channel current sensor I2C address
|
||||||
|
#define TELEM_INA3221_SHUNT_VALUE 0.100 // most variants will have a 0.1 ohm shunts
|
||||||
|
#define TELEM_INA3221_NUM_CHANNELS 3
|
||||||
|
#include <Adafruit_INA3221.h>
|
||||||
static Adafruit_INA3221 INA3221;
|
static Adafruit_INA3221 INA3221;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENV_INCLUDE_INA219
|
#if ENV_INCLUDE_INA219
|
||||||
|
#define TELEM_INA219_ADDRESS 0x40 // INA219 single channel current sensor I2C address
|
||||||
|
#include <Adafruit_INA219.h>
|
||||||
static Adafruit_INA219 INA219(TELEM_INA219_ADDRESS);
|
static Adafruit_INA219 INA219(TELEM_INA219_ADDRESS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -128,15 +142,17 @@ bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, Cayen
|
|||||||
int EnvironmentSensorManager::getNumSettings() const {
|
int EnvironmentSensorManager::getNumSettings() const {
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
return gps_detected ? 1 : 0; // only show GPS setting if GPS is detected
|
return gps_detected ? 1 : 0; // only show GPS setting if GPS is detected
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* EnvironmentSensorManager::getSettingName(int i) const {
|
const char* EnvironmentSensorManager::getSettingName(int i) const {
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
return (gps_detected && i == 0) ? "gps" : NULL;
|
return (gps_detected && i == 0) ? "gps" : NULL;
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* EnvironmentSensorManager::getSettingValue(int i) const {
|
const char* EnvironmentSensorManager::getSettingValue(int i) const {
|
||||||
@@ -184,10 +200,8 @@ void EnvironmentSensorManager::initBasicGPS() {
|
|||||||
MESH_DEBUG_PRINTLN("No GPS detected");
|
MESH_DEBUG_PRINTLN("No GPS detected");
|
||||||
digitalWrite(PIN_GPS_EN, LOW);
|
digitalWrite(PIN_GPS_EN, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EnvironmentSensorManager::start_gps() {
|
void EnvironmentSensorManager::start_gps() {
|
||||||
gps_active = true;
|
gps_active = true;
|
||||||
pinMode(PIN_GPS_EN, OUTPUT);
|
pinMode(PIN_GPS_EN, OUTPUT);
|
||||||
|
|||||||
@@ -4,29 +4,6 @@
|
|||||||
#include <helpers/SensorManager.h>
|
#include <helpers/SensorManager.h>
|
||||||
#include <helpers/sensors/LocationProvider.h>
|
#include <helpers/sensors/LocationProvider.h>
|
||||||
|
|
||||||
|
|
||||||
#if ENV_INCLUDE_AHTX0
|
|
||||||
#define TELEM_AHTX_ADDRESS 0x38 // AHT10, AHT20 temperature and humidity sensor I2C address
|
|
||||||
#include <Adafruit_AHTX0.h>
|
|
||||||
#endif
|
|
||||||
#if ENV_INCLUDE_BME280
|
|
||||||
#define TELEM_BME280_ADDRESS 0x76 // BME280 environmental sensor I2C address
|
|
||||||
#define TELEM_BME280_SEALEVELPRESSURE_HPA (1013.25) // Athmospheric pressure at sea level
|
|
||||||
#include <Adafruit_BME280.h>
|
|
||||||
#endif
|
|
||||||
#if ENV_INCLUDE_INA3221
|
|
||||||
#define TELEM_INA3221_ADDRESS 0x42 // INA3221 3 channel current sensor I2C address
|
|
||||||
#define TELEM_INA3221_SHUNT_VALUE 0.100 // most variants will have a 0.1 ohm shunts
|
|
||||||
#define TELEM_INA3221_NUM_CHANNELS 3
|
|
||||||
#include <Adafruit_INA3221.h>
|
|
||||||
#endif
|
|
||||||
#if ENV_INCLUDE_INA219
|
|
||||||
#define TELEM_INA219_ADDRESS 0x40 // INA219 single channel current sensor I2C address
|
|
||||||
#include <Adafruit_INA219.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class EnvironmentSensorManager : public SensorManager {
|
class EnvironmentSensorManager : public SensorManager {
|
||||||
protected:
|
protected:
|
||||||
int next_available_channel = TELEM_CHANNEL_SELF + 1;
|
int next_available_channel = TELEM_CHANNEL_SELF + 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user