mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-12 12:57:27 +00:00
* rework I2C sensor init the goal is to only instantiate sensors that are pressend to save memory. side effacts: - easyer sensor integration (less C&P code) - nodeTelemetrySensorsMap can be removed when all devices are migrated * add missing ifdef * refactor a bunch of more sensors RAM -816 Flash -916 * fix build for t1000 * refactor more sensors RAM -192 Flash -60 * improve error handling Flash -112 * fix build * fix build * fix IndicatorSensor * fix tracker-t1000-e build not sure what magic is used but it works * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Telemetry/Sensor/DFRobotGravitySensor.h Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
45 lines
1.5 KiB
C++
45 lines
1.5 KiB
C++
#include "configuration.h"
|
|
|
|
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && __has_include(<bsec2.h>)
|
|
|
|
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
|
#include "TelemetrySensor.h"
|
|
#include <bsec2.h>
|
|
|
|
#define STATE_SAVE_PERIOD UINT32_C(360 * 60 * 1000) // That's 6 hours worth of millis()
|
|
|
|
const uint8_t bsec_config[] = {
|
|
#include "config/bme680/bme680_iaq_33v_3s_4d/bsec_iaq.txt"
|
|
};
|
|
|
|
class BME680Sensor : public TelemetrySensor
|
|
{
|
|
private:
|
|
Bsec2 bme680;
|
|
|
|
protected:
|
|
const char *bsecConfigFileName = "/prefs/bsec.dat";
|
|
uint8_t bsecState[BSEC_MAX_STATE_BLOB_SIZE] = {0};
|
|
uint8_t accuracy = 0;
|
|
uint16_t stateUpdateCounter = 0;
|
|
bsecSensor sensorList[9] = {BSEC_OUTPUT_IAQ,
|
|
BSEC_OUTPUT_RAW_TEMPERATURE,
|
|
BSEC_OUTPUT_RAW_PRESSURE,
|
|
BSEC_OUTPUT_RAW_HUMIDITY,
|
|
BSEC_OUTPUT_RAW_GAS,
|
|
BSEC_OUTPUT_STABILIZATION_STATUS,
|
|
BSEC_OUTPUT_RUN_IN_STATUS,
|
|
BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE,
|
|
BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY};
|
|
void loadState();
|
|
void updateState();
|
|
void checkStatus(const char *functionName);
|
|
|
|
public:
|
|
BME680Sensor();
|
|
virtual int32_t runOnce() override;
|
|
virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
|
|
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
|
|
};
|
|
|
|
#endif |