tone_alarm move to px4 work queue

This commit is contained in:
Daniel Agar
2019-02-22 10:52:52 -05:00
parent 8c3821c806
commit da6210151c
2 changed files with 12 additions and 16 deletions
+8 -9
View File
@@ -40,7 +40,8 @@
#include <px4_time.h>
ToneAlarm::ToneAlarm() :
CDev(TONE_ALARM0_DEVICE_PATH)
CDev(TONE_ALARM0_DEVICE_PATH),
ScheduledWorkItem(px4::wq_configurations::hp_default)
{
}
@@ -65,7 +66,9 @@ int ToneAlarm::init()
ToneAlarmInterface::init();
_running = true;
work_queue(HPWORK, &_work, (worker_t)&ToneAlarm::next_trampoline, this, 0);
ScheduleNow();
return OK;
}
@@ -122,13 +125,12 @@ void ToneAlarm::next_note()
}
// Schedule a callback when the note should stop.
work_queue(HPWORK, &_work, (worker_t)&ToneAlarm::next_trampoline, this, USEC2TICK(duration));
ScheduleDelayed(duration);
}
void ToneAlarm::next_trampoline(void *argv)
void ToneAlarm::Run()
{
ToneAlarm *toneAlarm = (ToneAlarm *)argv;
toneAlarm->next_note();
next_note();
}
void ToneAlarm::orb_update()
@@ -177,9 +179,6 @@ void ToneAlarm::stop_note()
ToneAlarmInterface::stop_note();
}
struct work_s ToneAlarm::_work = {};
/**
* Local functions in support of the shell command.
*/