mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 23:08:11 +00:00
Sensors page: show placeholders for all connected sensors; support all LPP types
- SensorManager::getAvailableLPPTypes() reports which LPP types will be present based on initialized sensor flags (temp, humidity, pressure, etc.) - Sensors page renders one row per available type; shows "--" for any sensor that hasn't produced a reading yet instead of hiding the row entirely - LPPReader: add readLuminosity, readPercentage, readConcentration, readDistance - All known LPP types now have proper names and units in the sensor display Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,7 @@ public:
|
||||
virtual const char* getSettingValue(int i) const { return NULL; }
|
||||
virtual bool setSettingValue(const char* name, const char* value) { return false; }
|
||||
virtual LocationProvider* getLocationProvider() { return NULL; }
|
||||
virtual int getAvailableLPPTypes(uint8_t* types, int max_count) const { return 0; }
|
||||
|
||||
// Helper functions to manage setting by keys (useful in many places ...)
|
||||
const char* getSettingByKey(const char* key) {
|
||||
|
||||
@@ -540,6 +540,46 @@ bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, Cayen
|
||||
}
|
||||
|
||||
|
||||
int EnvironmentSensorManager::getAvailableLPPTypes(uint8_t* types, int max_count) const {
|
||||
int n = 0;
|
||||
auto add = [&](uint8_t t) { if (n < max_count) types[n++] = t; };
|
||||
|
||||
add(LPP_VOLTAGE); // battery voltage — always present
|
||||
|
||||
#if ENV_INCLUDE_GPS
|
||||
add(LPP_GPS);
|
||||
#endif
|
||||
|
||||
bool has_temp = AHTX0_initialized || BME680_initialized || BME280_initialized ||
|
||||
BMP280_initialized || SHTC3_initialized || SHT4X_initialized ||
|
||||
LPS22HB_initialized || MLX90614_initialized || BMP085_initialized ||
|
||||
RAK12035_initialized;
|
||||
if (has_temp) add(LPP_TEMPERATURE);
|
||||
|
||||
bool has_hum = AHTX0_initialized || BME680_initialized || BME280_initialized ||
|
||||
SHTC3_initialized || SHT4X_initialized || RAK12035_initialized;
|
||||
if (has_hum) add(LPP_RELATIVE_HUMIDITY);
|
||||
|
||||
bool has_press = BME680_initialized || LPS22HB_initialized;
|
||||
if (has_press) add(LPP_BAROMETRIC_PRESSURE);
|
||||
|
||||
bool has_alt = BME680_initialized || BME280_initialized || BMP280_initialized || BMP085_initialized;
|
||||
if (has_alt) add(LPP_ALTITUDE);
|
||||
|
||||
bool has_power = INA3221_initialized || INA219_initialized || INA260_initialized || INA226_initialized;
|
||||
if (has_power) { add(LPP_CURRENT); add(LPP_POWER); }
|
||||
|
||||
#if ENV_INCLUDE_VL53L0X
|
||||
if (VL53L0X_initialized) add(LPP_DISTANCE);
|
||||
#endif
|
||||
|
||||
#if ENV_INCLUDE_RAK12035
|
||||
if (RAK12035_initialized) add(LPP_PERCENTAGE);
|
||||
#endif
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int EnvironmentSensorManager::getNumSettings() const {
|
||||
int settings = 0;
|
||||
#if ENV_INCLUDE_GPS
|
||||
|
||||
@@ -49,6 +49,7 @@ public:
|
||||
#endif
|
||||
bool begin() override;
|
||||
bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) override;
|
||||
int getAvailableLPPTypes(uint8_t* types, int max_count) const override;
|
||||
#if ENV_INCLUDE_GPS
|
||||
void loop() override;
|
||||
#endif
|
||||
|
||||
@@ -136,6 +136,22 @@ public:
|
||||
m = getFloat(&_buf[_pos], 2, 1, true); _pos += 2;
|
||||
return _pos <= _len;
|
||||
}
|
||||
bool readLuminosity(float& lux) {
|
||||
lux = getFloat(&_buf[_pos], 2, 1, false); _pos += 2;
|
||||
return _pos <= _len;
|
||||
}
|
||||
bool readPercentage(float& pct) {
|
||||
pct = getFloat(&_buf[_pos], 1, 1, false); _pos += 1;
|
||||
return _pos <= _len;
|
||||
}
|
||||
bool readConcentration(float& ppm) {
|
||||
ppm = getFloat(&_buf[_pos], 2, 1, false); _pos += 2;
|
||||
return _pos <= _len;
|
||||
}
|
||||
bool readDistance(float& m) {
|
||||
m = getFloat(&_buf[_pos], 4, 1000, false); _pos += 4;
|
||||
return _pos <= _len;
|
||||
}
|
||||
|
||||
void skipData(uint8_t type) {
|
||||
switch (type) {
|
||||
|
||||
Reference in New Issue
Block a user