From a4659b1228cb33544e6a8c201c5cd885dad7a363 Mon Sep 17 00:00:00 2001 From: Simone Guscetti Date: Tue, 30 May 2017 17:04:27 +0200 Subject: [PATCH] mkblctrl: Repalce old tune interface with the new one untested on real hardware --- src/drivers/mkblctrl/mkblctrl.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/drivers/mkblctrl/mkblctrl.cpp b/src/drivers/mkblctrl/mkblctrl.cpp index b2bb08849b..ae0e655448 100644 --- a/src/drivers/mkblctrl/mkblctrl.cpp +++ b/src/drivers/mkblctrl/mkblctrl.cpp @@ -79,6 +79,7 @@ #include #include #include +#include #include @@ -161,6 +162,7 @@ private: char _device[20]; orb_advert_t _t_outputs; orb_advert_t _t_esc_status; + orb_advert_t _tune_control_sub; unsigned int _num_outputs; bool _primary_pwm_device; bool _motortest; @@ -447,14 +449,14 @@ MK::scaling(float val, float inMin, float inMax, float outMin, float outMax) void MK::play_beep(int count) { - int buzzer = ::open(TONEALARM0_DEVICE_PATH, O_WRONLY); + tune_control_s tune = {}; + tune.tune_id = tune_control_s::TUNE_ID_SINGLE_BEEP; for (int i = 0; i < count; i++) { - ::ioctl(buzzer, TONE_SET_ALARM, TONE_SINGLE_BEEP_TUNE); + orb_publish(ORB_ID(tune_control), _tune_control_sub, &tune); usleep(300000); } - ::close(buzzer); } void @@ -490,6 +492,11 @@ 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(ORB_ID(tune_control), &tune); pollfd fds[2]; fds[0].fd = _t_actuators;