mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-22 02:32:23 +00:00
Use INA for device battery level (#2536)
* WIP * Continued wip * We got em * Voltage sensor base class * INA voltage * Log it * Stacie's mom has got it going on * Move declaration up * Last one * Sneaky little bugger * Macro guard to avoid calling methods
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
||||
#include "NodeDB.h"
|
||||
#include "main.h"
|
||||
|
||||
#define DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
extern uint8_t nodeTelemetrySensorsMap[_meshtastic_TelemetrySensorType_MAX + 1];
|
||||
|
||||
class TelemetrySensor
|
||||
{
|
||||
@@ -18,6 +18,7 @@ class TelemetrySensor
|
||||
const char *sensorName;
|
||||
meshtastic_TelemetrySensorType sensorType;
|
||||
unsigned status;
|
||||
bool initialized = false;
|
||||
|
||||
int32_t initI2CSensor()
|
||||
{
|
||||
@@ -28,6 +29,7 @@ class TelemetrySensor
|
||||
LOG_INFO("Opened %s sensor on default i2c bus\n", sensorName);
|
||||
setup();
|
||||
}
|
||||
initialized = true;
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
virtual void setup();
|
||||
@@ -36,5 +38,8 @@ class TelemetrySensor
|
||||
bool hasSensor() { return sensorType < sizeof(nodeTelemetrySensorsMap) && nodeTelemetrySensorsMap[sensorType] > 0; }
|
||||
|
||||
virtual int32_t runOnce() = 0;
|
||||
virtual bool isInitialized() { return initialized; }
|
||||
virtual bool isRunning() { return status > 0; }
|
||||
|
||||
virtual bool getMetrics(meshtastic_Telemetry *measurement) = 0;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user