mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 13:53:34 +08:00
Code cleanup
This commit is contained in:
committed by
Julian Oes
parent
77cf081925
commit
11bbc8ae34
@@ -101,7 +101,7 @@ private:
|
||||
orb_advert_t _battery_topic;
|
||||
orb_advert_t _esc_topic;
|
||||
|
||||
Battery _battery;
|
||||
Battery _battery{1, nullptr};
|
||||
bool _armed;
|
||||
float _last_throttle;
|
||||
|
||||
@@ -114,7 +114,7 @@ private:
|
||||
};
|
||||
|
||||
DfBebopBusWrapper::DfBebopBusWrapper() :
|
||||
BebopBus(BEBOP_BUS_DEVICE_PATH), _battery_topic(nullptr), _esc_topic(nullptr), _battery(), _armed(false),
|
||||
BebopBus(BEBOP_BUS_DEVICE_PATH), _battery_topic(nullptr), _esc_topic(nullptr), _battery(1, nullptr), _armed(false),
|
||||
_last_throttle(0.0f),
|
||||
_battery_orb_class_instance(-1)
|
||||
{}
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
private:
|
||||
int _publish(const struct ltc2946_sensor_data &data);
|
||||
|
||||
Battery _battery{};
|
||||
Battery _battery{1, nullptr};
|
||||
|
||||
int _actuator_ctrl_0_sub{-1};
|
||||
int _vcontrol_mode_sub{-1};
|
||||
|
||||
@@ -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