PX4 Firmware
PX4 Autopilot Software http://px4.io
BatteryStatus Class Reference
Inheritance diagram for BatteryStatus:
Collaboration diagram for BatteryStatus:

Public Member Functions

 BatteryStatus ()
 
 ~BatteryStatus () override
 
void Run () override
 
bool init ()
 
int print_status () override
 

Static Public Member Functions

static int task_spawn (int argc, char *argv[])
 
static int custom_command (int argc, char *argv[])
 
static int print_usage (const char *reason=nullptr)
 

Private Member Functions

int parameters_update ()
 Update our local parameter cache. More...
 
int adc_init ()
 Do adc-related initialisation. More...
 
void parameter_update_poll (bool forced=false)
 Check for changes in parameters. More...
 
void adc_poll ()
 Poll the ADC and update readings to suit. More...
 

Private Attributes

DevHandle _h_adc
 ADC driver handle. More...
 
bool _armed {false}
 arming status of the vehicle More...
 
uORB::Subscription _actuator_ctrl_0_sub {ORB_ID(actuator_controls_0)}
 attitude controls sub More...
 
uORB::Subscription _parameter_update_sub {ORB_ID(parameter_update)}
 notification of parameter updates More...
 
uORB::Subscription _vcontrol_mode_sub {ORB_ID(vehicle_control_mode)}
 vehicle control mode subscription More...
 
orb_advert_t _battery_pub [BOARD_NUMBER_BRICKS] {}
 battery status More...
 
Battery _battery [BOARD_NUMBER_BRICKS]
 Helper lib to publish battery_status topic. More...
 
perf_counter_t _loop_perf
 loop performance counter More...
 
hrt_abstime _last_config_update {0}
 
Parameters _parameters {}
 local copies of interesting parameters More...
 
ParameterHandles _parameter_handles {}
 handles for interesting parameters More...
 

Detailed Description

Definition at line 110 of file battery_status.cpp.

Constructor & Destructor Documentation

◆ BatteryStatus()

BatteryStatus::BatteryStatus ( )

Definition at line 178 of file battery_status.cpp.

References _battery, _parameter_handles, and battery_status::initialize_parameter_handles().

Referenced by task_spawn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~BatteryStatus()

BatteryStatus::~BatteryStatus ( )
override

Definition at line 190 of file battery_status.cpp.

Member Function Documentation

◆ adc_init()

int BatteryStatus::adc_init ( )
private

Do adc-related initialisation.

Definition at line 209 of file battery_status.cpp.

References _h_adc, ADC0_DEVICE_PATH, and OK.

Referenced by Run().

Here is the caller graph for this function:

◆ adc_poll()

void BatteryStatus::adc_poll ( )
private

Poll the ADC and update readings to suit.

Parameters
rawCombined sensor data structure into which data should be returned.

Definition at line 237 of file battery_status.cpp.

References _actuator_ctrl_0_sub, _armed, _battery, _battery_pub, _h_adc, _parameters, battery_status::Parameters::battery_a_per_v, battery_status::Parameters::battery_adc_channel, battery_status::Parameters::battery_current_offset, battery_status::Parameters::battery_current_scaling, battery_status::Parameters::battery_source, battery_status::Parameters::battery_v_div, battery_status::Parameters::battery_voltage_scaling, uORB::Subscription::copy(), hrt_absolute_time(), ll40ls::instance, orb_advert_t, ORB_ID, ORB_PRIO_DEFAULT, orb_publish_auto(), px4_adc_msg_t, PX4_MAX_ADC_CHANNELS, and Battery::updateBatteryStatus().

Referenced by Run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ custom_command()

int BatteryStatus::custom_command ( int  argc,
char *  argv[] 
)
static
See also
ModuleBase

Definition at line 417 of file battery_status.cpp.

References print_usage().

Here is the call graph for this function:

◆ init()

bool BatteryStatus::init ( )

Definition at line 405 of file battery_status.cpp.

Referenced by task_spawn().

Here is the caller graph for this function:

◆ parameter_update_poll()

void BatteryStatus::parameter_update_poll ( bool  forced = false)
private

Check for changes in parameters.

Definition at line 222 of file battery_status.cpp.

References _parameter_update_sub, uORB::Subscription::copy(), parameters_update(), and uORB::Subscription::updated().

Referenced by Run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parameters_update()

int BatteryStatus::parameters_update ( )
private

Update our local parameter cache.

Definition at line 196 of file battery_status.cpp.

References _parameter_handles, _parameters, and battery_status::update_parameters().

Referenced by parameter_update_poll().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_status()

int BatteryStatus::print_status ( )
override
See also
ModuleBase::print_status()

Definition at line 412 of file battery_status.cpp.

◆ print_usage()

int BatteryStatus::print_usage ( const char *  reason = nullptr)
static
See also
ModuleBase

Definition at line 422 of file battery_status.cpp.

Referenced by custom_command().

Here is the caller graph for this function:

◆ Run()

void BatteryStatus::Run ( )
override

Definition at line 351 of file battery_status.cpp.

References _armed, _h_adc, _loop_perf, _vcontrol_mode_sub, adc_init(), adc_poll(), uORB::Subscription::copy(), parameter_update_poll(), perf_begin(), perf_end(), and uORB::Subscription::updated().

Here is the call graph for this function:

◆ task_spawn()

int BatteryStatus::task_spawn ( int  argc,
char *  argv[] 
)
static
See also
ModuleBase

Definition at line 381 of file battery_status.cpp.

References BatteryStatus(), init(), and ll40ls::instance.

Here is the call graph for this function:

Member Data Documentation

◆ _actuator_ctrl_0_sub

uORB::Subscription BatteryStatus::_actuator_ctrl_0_sub {ORB_ID(actuator_controls_0)}
private

attitude controls sub

Definition at line 136 of file battery_status.cpp.

Referenced by adc_poll().

◆ _armed

bool BatteryStatus::_armed {false}
private

arming status of the vehicle

Definition at line 134 of file battery_status.cpp.

Referenced by adc_poll(), and Run().

◆ _battery

Battery BatteryStatus::_battery[BOARD_NUMBER_BRICKS]
private

Helper lib to publish battery_status topic.

Definition at line 141 of file battery_status.cpp.

Referenced by adc_poll(), and BatteryStatus().

◆ _battery_pub

orb_advert_t BatteryStatus::_battery_pub[BOARD_NUMBER_BRICKS] {}
private

battery status

Definition at line 140 of file battery_status.cpp.

Referenced by adc_poll().

◆ _h_adc

DevHandle BatteryStatus::_h_adc
private

ADC driver handle.

Definition at line 132 of file battery_status.cpp.

Referenced by adc_init(), adc_poll(), and Run().

◆ _last_config_update

hrt_abstime BatteryStatus::_last_config_update {0}
private

Definition at line 149 of file battery_status.cpp.

◆ _loop_perf

perf_counter_t BatteryStatus::_loop_perf
private

loop performance counter

Definition at line 147 of file battery_status.cpp.

Referenced by Run().

◆ _parameter_handles

ParameterHandles BatteryStatus::_parameter_handles {}
private

handles for interesting parameters

Definition at line 152 of file battery_status.cpp.

Referenced by BatteryStatus(), and parameters_update().

◆ _parameter_update_sub

uORB::Subscription BatteryStatus::_parameter_update_sub {ORB_ID(parameter_update)}
private

notification of parameter updates

Definition at line 137 of file battery_status.cpp.

Referenced by parameter_update_poll().

◆ _parameters

Parameters BatteryStatus::_parameters {}
private

local copies of interesting parameters

Definition at line 151 of file battery_status.cpp.

Referenced by adc_poll(), and parameters_update().

◆ _vcontrol_mode_sub

uORB::Subscription BatteryStatus::_vcontrol_mode_sub {ORB_ID(vehicle_control_mode)}
private

vehicle control mode subscription

Definition at line 138 of file battery_status.cpp.

Referenced by Run().


The documentation for this class was generated from the following file: