tone_alarm move to uORB::Subscription

This commit is contained in:
Daniel Agar
2019-08-20 19:44:03 -04:00
parent 5ae408382b
commit b439e08e24
2 changed files with 6 additions and 16 deletions
+2 -14
View File
@@ -75,19 +75,10 @@ int ToneAlarm::init()
void ToneAlarm::next_note()
{
if (!_should_run) {
if (_tune_control_sub >= 0) {
orb_unsubscribe(_tune_control_sub);
}
_running = false;
return;
}
// Subscribe to tune_control.
if (_tune_control_sub < 0) {
_tune_control_sub = orb_subscribe(ORB_ID(tune_control));
}
// Check for updates
orb_update();
@@ -136,11 +127,8 @@ void ToneAlarm::Run()
void ToneAlarm::orb_update()
{
// Check for updates
bool updated = false;
orb_check(_tune_control_sub, &updated);
if (updated) {
orb_copy(ORB_ID(tune_control), _tune_control_sub, &_tune);
if (_tune_control_sub.updated()) {
_tune_control_sub.copy(&_tune);
if (_tune.timestamp > 0) {
_play_tone = _tunes.set_control(_tune) == 0;