mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-23 10:47:35 +08:00
drivers/tone_alarm and tune_control small improvements/cleanup
- drivers/tone_alarm: move to ModuleBase and purge CDev (/dev/tone_alarm0) - drivers/tone_alarm: only run on tune_control publication (or scheduled note) rather than continuously - drivers/tone_alarm: use HRT to schedule tone stop (prevents potential disruption) - msg/tune_control: add tune_id numbering - systemcmds/tune_control: add "error" special case tune_id - move all tune_control publication to new uORB::PublicationQueued<> - start tone_alarm immediately after board defaults are loaded to fix potential startup issues - for SITL (or other boards with no TONE output) print common messages (startup, error, etc)
This commit is contained in:
@@ -74,6 +74,7 @@
|
||||
#include <systemlib/err.h>
|
||||
#include <lib/mixer/MixerGroup.hpp>
|
||||
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/topics/actuator_controls.h>
|
||||
#include <uORB/topics/actuator_outputs.h>
|
||||
#include <uORB/topics/actuator_armed.h>
|
||||
@@ -161,7 +162,7 @@ private:
|
||||
char _device[20];
|
||||
orb_advert_t _t_outputs;
|
||||
orb_advert_t _t_esc_status;
|
||||
orb_advert_t _tune_control_sub;
|
||||
uORB::PublicationQueued<tune_control_s> _tune_control_pub{ORB_ID(tune_control)};
|
||||
unsigned int _num_outputs;
|
||||
bool _primary_pwm_device;
|
||||
bool _motortest;
|
||||
@@ -448,14 +449,14 @@ MK::scaling(float val, float inMin, float inMax, float outMin, float outMax)
|
||||
void
|
||||
MK::play_beep(int count)
|
||||
{
|
||||
tune_control_s tune = {};
|
||||
tune_control_s tune{};
|
||||
tune.tune_id = static_cast<int>(TuneID::SINGLE_BEEP);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
orb_publish(ORB_ID(tune_control), _tune_control_sub, &tune);
|
||||
tune.timestamp = hrt_absolute_time();
|
||||
_tune_control_pub.publish(tune);
|
||||
usleep(300000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
@@ -490,12 +491,6 @@ MK::task_main()
|
||||
memset(&esc, 0, sizeof(esc));
|
||||
_t_esc_status = orb_advertise(ORB_ID(esc_status), &esc);
|
||||
|
||||
/*
|
||||
* advertise the tune_control.
|
||||
*/
|
||||
tune_control_s tune = {};
|
||||
_tune_control_sub = orb_advertise_queue(ORB_ID(tune_control), &tune, tune_control_s::ORB_QUEUE_LENGTH);
|
||||
|
||||
pollfd fds[2];
|
||||
fds[0].fd = _t_actuators;
|
||||
fds[0].events = POLLIN;
|
||||
|
||||
Reference in New Issue
Block a user