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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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);

View File

@ -219,6 +219,10 @@ SO GPIO 39/TXEN MAY NOT BE DEFINED FOR SUCCESSFUL OPERATION OF THE SX1262 - TG
// Testing USB detection
#define NRF_APM
// If using a power chip like the INA3221 you can override the default battery voltage channel below
// and comment out NRF_APM to use the INA3221 instead of the USB detection for charging
// #define INA3221_BAT_CH INA3221_CH2
// #define INA3221_ENV_CH INA3221_CH1
// enables 3.3V periphery like GPS or IO Module
// Do not toggle this for GPS power savings