allow overriding INA3221 channels (#7035)

Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz>
This commit is contained in:
Andy Shinn
2025-06-15 07:39:49 -05:00
committed by GitHub
parent ac52edd11a
commit f1dd623ce9
2 changed files with 14 additions and 2 deletions

View File

@@ -8,16 +8,24 @@
#include "VoltageSensor.h"
#include <INA3221.h>
#ifndef INA3221_ENV_CH
#define INA3221_ENV_CH INA3221_CH1
#endif
#ifndef INA3221_BAT_CH
#define INA3221_BAT_CH INA3221_CH1
#endif
class INA3221Sensor : public TelemetrySensor, VoltageSensor, CurrentSensor
{
private:
INA3221 ina3221 = INA3221(INA3221_ADDR42_SDA);
// channel to report voltage/current for environment metrics
ina3221_ch_t ENV_CH = INA3221_CH1;
static const ina3221_ch_t ENV_CH = INA3221_ENV_CH;
// channel to report battery voltage for device_battery_ina_address
ina3221_ch_t BAT_CH = INA3221_CH1;
static const ina3221_ch_t BAT_CH = INA3221_BAT_CH;
// get a single measurement for a channel
struct _INA3221Measurement getMeasurement(ina3221_ch_t ch);