mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-14 09:15:22 +00:00
Trunk....
This commit is contained in:
parent
81176de5a7
commit
57cf9ddd0a
@ -422,7 +422,7 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
|||||||
if (hasINA()) {
|
if (hasINA()) {
|
||||||
// get current flow from INA sensor - negative value means power flowing into the battery
|
// get current flow from INA sensor - negative value means power flowing into the battery
|
||||||
// default assuming BATTERY+ <--> INA_VIN+ <--> SHUNT RESISTOR <--> INA_VIN- <--> LOAD
|
// default assuming BATTERY+ <--> INA_VIN+ <--> SHUNT RESISTOR <--> INA_VIN- <--> LOAD
|
||||||
//LOG_DEBUG("Using INA on I2C addr 0x%x for charging detection", config.power.device_battery_ina_address);
|
// LOG_DEBUG("Using INA on I2C addr 0x%x for charging detection", config.power.device_battery_ina_address);
|
||||||
LOG_DEBUG("Using INA on I2C addr 0x%x for charging detection", INA_ADDR_LOCAL);
|
LOG_DEBUG("Using INA on I2C addr 0x%x for charging detection", INA_ADDR_LOCAL);
|
||||||
#if defined(INA_CHARGING_DETECTION_INVERT)
|
#if defined(INA_CHARGING_DETECTION_INVERT)
|
||||||
return getINACurrent() > 0;
|
return getINACurrent() > 0;
|
||||||
@ -464,9 +464,9 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
|
#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
|
||||||
/*
|
/*
|
||||||
Read Voltage from INA using autodetect of addr first else use addr in config.power.device_battery_ina_address
|
Read Voltage from INA using autodetect of addr first else use addr in config.power.device_battery_ina_address
|
||||||
*/
|
*/
|
||||||
uint16_t getINAVoltage()
|
uint16_t getINAVoltage()
|
||||||
{
|
{
|
||||||
if (!config.power.device_battery_ina_address) {
|
if (!config.power.device_battery_ina_address) {
|
||||||
@ -482,21 +482,24 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
|||||||
} else if (config.power.device_battery_ina_address) {
|
} else if (config.power.device_battery_ina_address) {
|
||||||
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first == config.power.device_battery_ina_address) {
|
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first == config.power.device_battery_ina_address) {
|
||||||
return ina219Sensor.getBusVoltageMv();
|
return ina219Sensor.getBusVoltageMv();
|
||||||
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA226].first == config.power.device_battery_ina_address) {
|
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA226].first ==
|
||||||
|
config.power.device_battery_ina_address) {
|
||||||
return ina226Sensor.getBusVoltageMv();
|
return ina226Sensor.getBusVoltageMv();
|
||||||
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA260].first == config.power.device_battery_ina_address) {
|
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA260].first ==
|
||||||
|
config.power.device_battery_ina_address) {
|
||||||
return ina260Sensor.getBusVoltageMv();
|
return ina260Sensor.getBusVoltageMv();
|
||||||
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA3221].first == config.power.device_battery_ina_address) {
|
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA3221].first ==
|
||||||
|
config.power.device_battery_ina_address) {
|
||||||
return ina3221Sensor.getBusVoltageMv();
|
return ina3221Sensor.getBusVoltageMv();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Read Current from INA using autodetect of addr first else use addr in config.power.device_battery_ina_address
|
Read Current from INA using autodetect of addr first else use addr in config.power.device_battery_ina_address
|
||||||
*/
|
*/
|
||||||
int16_t getINACurrent()
|
int16_t getINACurrent()
|
||||||
{
|
{
|
||||||
if (!config.power.device_battery_ina_address) {
|
if (!config.power.device_battery_ina_address) {
|
||||||
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first > 0) {
|
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first > 0) {
|
||||||
@ -509,9 +512,11 @@ int16_t getINACurrent()
|
|||||||
} else if (config.power.device_battery_ina_address) {
|
} else if (config.power.device_battery_ina_address) {
|
||||||
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first == config.power.device_battery_ina_address) {
|
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first == config.power.device_battery_ina_address) {
|
||||||
return ina219Sensor.getCurrentMa();
|
return ina219Sensor.getCurrentMa();
|
||||||
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA226].first == config.power.device_battery_ina_address) {
|
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA226].first ==
|
||||||
|
config.power.device_battery_ina_address) {
|
||||||
return ina226Sensor.getCurrentMa();
|
return ina226Sensor.getCurrentMa();
|
||||||
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA3221].first == config.power.device_battery_ina_address) {
|
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA3221].first ==
|
||||||
|
config.power.device_battery_ina_address) {
|
||||||
return ina3221Sensor.getCurrentMa();
|
return ina3221Sensor.getCurrentMa();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -519,10 +524,10 @@ int16_t getINACurrent()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool hasINA()
|
bool hasINA()
|
||||||
/*
|
/*
|
||||||
Use autodetect of addr first else use addr in config.power.device_battery_ina_address
|
Use autodetect of addr first else use addr in config.power.device_battery_ina_address
|
||||||
Store INA addr in local variable for later use.
|
Store INA addr in local variable for later use.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
if (!config.power.device_battery_ina_address) {
|
if (!config.power.device_battery_ina_address) {
|
||||||
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first > 0) {
|
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first > 0) {
|
||||||
@ -551,14 +556,17 @@ int16_t getINACurrent()
|
|||||||
if (!ina219Sensor.isInitialized())
|
if (!ina219Sensor.isInitialized())
|
||||||
return ina219Sensor.runOnce() > 0;
|
return ina219Sensor.runOnce() > 0;
|
||||||
return ina219Sensor.isRunning();
|
return ina219Sensor.isRunning();
|
||||||
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA226].first == config.power.device_battery_ina_address) {
|
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA226].first ==
|
||||||
|
config.power.device_battery_ina_address) {
|
||||||
if (!ina226Sensor.isInitialized())
|
if (!ina226Sensor.isInitialized())
|
||||||
return ina226Sensor.runOnce() > 0;
|
return ina226Sensor.runOnce() > 0;
|
||||||
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA260].first == config.power.device_battery_ina_address) {
|
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA260].first ==
|
||||||
|
config.power.device_battery_ina_address) {
|
||||||
if (!ina260Sensor.isInitialized())
|
if (!ina260Sensor.isInitialized())
|
||||||
return ina260Sensor.runOnce() > 0;
|
return ina260Sensor.runOnce() > 0;
|
||||||
return ina260Sensor.isRunning();
|
return ina260Sensor.isRunning();
|
||||||
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA3221].first == config.power.device_battery_ina_address) {
|
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA3221].first ==
|
||||||
|
config.power.device_battery_ina_address) {
|
||||||
if (!ina3221Sensor.isInitialized())
|
if (!ina3221Sensor.isInitialized())
|
||||||
return ina3221Sensor.runOnce() > 0;
|
return ina3221Sensor.runOnce() > 0;
|
||||||
return ina3221Sensor.isRunning();
|
return ina3221Sensor.isRunning();
|
||||||
|
Loading…
Reference in New Issue
Block a user