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:
Daniel Agar
2020-10-05 21:39:26 -04:00
committed by GitHub
parent c7072b61a3
commit 08bf71b73d
39 changed files with 429 additions and 577 deletions
+8 -22
View File
@@ -45,8 +45,6 @@
#include <tunes/tune_definition.h>
#include <uORB/topics/tune_control.h>
namespace events
{
namespace rc_loss
@@ -84,32 +82,20 @@ void RC_Loss_Alarm::process()
void RC_Loss_Alarm::play_tune()
{
struct tune_control_s tune_control = {};
tune_control.timestamp = hrt_absolute_time();
tune_control.tune_id = static_cast<int>(TuneID::ERROR_TUNE);
tune_control.tune_override = 1;
tune_control.volume = tune_control_s::VOLUME_LEVEL_MAX;
if (_tune_control_pub == nullptr) {
_tune_control_pub = orb_advertise_queue(ORB_ID(tune_control), &tune_control, tune_control_s::ORB_QUEUE_LENGTH);
} else {
orb_publish(ORB_ID(tune_control), _tune_control_pub, &tune_control);
}
tune_control_s tune_control{};
tune_control.tune_id = tune_control_s::TUNE_ID_ERROR;
tune_control.tune_override = true;
tune_control.volume = tune_control_s::VOLUME_LEVEL_MAX;
tune_control.timestamp = hrt_absolute_time();
_tune_control_pub.publish(tune_control);
}
void RC_Loss_Alarm::stop_tune()
{
struct tune_control_s tune_control = {};
tune_control_s tune_control{};
tune_control.tune_override = true;
tune_control.timestamp = hrt_absolute_time();
if (_tune_control_pub == nullptr) {
_tune_control_pub = orb_advertise_queue(ORB_ID(tune_control), &tune_control, tune_control_s::ORB_QUEUE_LENGTH);
} else {
orb_publish(ORB_ID(tune_control), _tune_control_pub, &tune_control);
}
_tune_control_pub.publish(tune_control);
}
} /* namespace rc_loss */
+3 -1
View File
@@ -39,8 +39,10 @@
#pragma once
#include <uORB/Publication.hpp>
#include <uORB/Subscription.hpp>
#include <uORB/topics/vehicle_status.h>
#include <uORB/topics/tune_control.h>
namespace events
{
@@ -63,12 +65,12 @@ private:
/** Publish tune control to interrupt any sound */
void stop_tune();
uORB::PublicationQueued<tune_control_s> _tune_control_pub{ORB_ID(tune_control)};
uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)};
bool _was_armed = false;
bool _had_rc = false; // Don't trigger alarm for systems without RC
bool _alarm_playing = false;
orb_advert_t _tune_control_pub = nullptr;
};
} /* namespace rc_loss */