battery-monitoring: allow disabling analog battery monitoring through BAT{i}_V_CHANNEL param

This commit is contained in:
mahima-yoga 2025-07-15 14:52:17 +02:00 committed by Mahima Yoga
parent 5125059b8f
commit db85e12b9f
3 changed files with 11 additions and 2 deletions

View File

@ -127,7 +127,10 @@ bool AnalogBattery::is_valid()
int AnalogBattery::get_voltage_channel()
{
if (_analog_params.v_channel >= 0) {
if (_analog_params.v_channel == V_CHANNEL_DISABLED) {
return -1;
} else if (_analog_params.v_channel >= 0) {
return _analog_params.v_channel;
} else {
@ -135,6 +138,7 @@ int AnalogBattery::get_voltage_channel()
}
}
int AnalogBattery::get_current_channel()
{
if (_analog_params.i_channel >= 0) {

View File

@ -94,6 +94,9 @@ protected:
virtual void updateParams() override;
private:
static constexpr int V_CHANNEL_DISABLED = -2;
uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)};
uint8_t _arming_state{0};

View File

@ -41,7 +41,9 @@ parameters:
short: Battery ${i} Voltage ADC Channel
long: |
This parameter specifies the ADC channel used to monitor voltage of main power battery.
A value of -1 means to use the board default.
A value of -1 means to use the board default. A value of -2 disables analog monitoring.
This is useful when the FMU supports both analog and digital voltage monitoring and you want
to use digital monitoring exclusively.
type: int32
reboot_required: true