mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 05:53:34 +08:00
Code cleanup
This commit is contained in:
committed by
Julian Oes
parent
77cf081925
commit
11bbc8ae34
@@ -46,7 +46,9 @@
|
||||
VOXLPM::VOXLPM(const char *path, int bus, int address, VOXLPM_CH_TYPE ch_type) :
|
||||
I2C("voxlpm", path, bus, address, 400000),
|
||||
ScheduledWorkItem(MODULE_NAME, px4::device_bus_to_wq(I2C::get_device_id())),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": sample"))
|
||||
ModuleParams(nullptr),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": sample")),
|
||||
_battery(1, this)
|
||||
{
|
||||
_ch_type = ch_type;
|
||||
|
||||
@@ -129,6 +131,13 @@ VOXLPM::Run()
|
||||
int
|
||||
VOXLPM::measure()
|
||||
{
|
||||
parameter_update_s update;
|
||||
|
||||
if (_parameter_sub.update(&update)) {
|
||||
updateParams();
|
||||
}
|
||||
|
||||
|
||||
_voltage = 0.0f;
|
||||
_amperage = 0.0f;
|
||||
|
||||
|
||||
@@ -68,8 +68,10 @@
|
||||
#include <battery/battery.h>
|
||||
|
||||
#include <uORB/PublicationMulti.hpp>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/battery_status.h>
|
||||
#include <uORB/topics/power_monitor.h>
|
||||
#include <uORB/topics/parameter_update.h>
|
||||
|
||||
/*
|
||||
* Note that these are unshifted addresses.
|
||||
@@ -142,7 +144,7 @@ enum VOXLPM_CH_TYPE {
|
||||
VOXLPM_CH_TYPE_P5VDC
|
||||
};
|
||||
|
||||
class VOXLPM : public device::I2C, public px4::ScheduledWorkItem
|
||||
class VOXLPM : public device::I2C, public px4::ScheduledWorkItem, public ModuleParams
|
||||
{
|
||||
public:
|
||||
VOXLPM(const char *path, int bus, int address, VOXLPM_CH_TYPE ch_type);
|
||||
@@ -161,6 +163,7 @@ private:
|
||||
perf_counter_t _sample_perf;
|
||||
|
||||
uORB::PublicationMulti<power_monitor_s> _pm_pub_topic{ORB_ID(power_monitor)};
|
||||
uORB::Subscription _parameter_sub{ORB_ID(parameter_update)};
|
||||
|
||||
power_monitor_s _pm_status{};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user