mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
tune_control: use orb queue advertisement consistently
This commit is contained in:
@@ -13,3 +13,5 @@ uint8 volume # value between 0-100 if supported by backend
|
|||||||
uint8 VOLUME_LEVEL_MIN = 0
|
uint8 VOLUME_LEVEL_MIN = 0
|
||||||
uint8 VOLUME_LEVEL_DEFAULT = 40
|
uint8 VOLUME_LEVEL_DEFAULT = 40
|
||||||
uint8 VOLUME_LEVEL_MAX = 100
|
uint8 VOLUME_LEVEL_MAX = 100
|
||||||
|
|
||||||
|
uint8 ORB_QUEUE_LENGTH = 3
|
||||||
|
|||||||
@@ -495,7 +495,7 @@ MK::task_main()
|
|||||||
* advertise the tune_control.
|
* advertise the tune_control.
|
||||||
*/
|
*/
|
||||||
tune_control_s tune = {};
|
tune_control_s tune = {};
|
||||||
_tune_control_sub = orb_advertise(ORB_ID(tune_control), &tune);
|
_tune_control_sub = orb_advertise_queue(ORB_ID(tune_control), &tune, tune_control_s::ORB_QUEUE_LENGTH);
|
||||||
|
|
||||||
pollfd fds[2];
|
pollfd fds[2];
|
||||||
fds[0].fd = _t_actuators;
|
fds[0].fd = _t_actuators;
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ int buzzer_init()
|
|||||||
tune_durations[TONE_BATTERY_WARNING_FAST_TUNE] = 800000;
|
tune_durations[TONE_BATTERY_WARNING_FAST_TUNE] = 800000;
|
||||||
tune_durations[TONE_BATTERY_WARNING_SLOW_TUNE] = 800000;
|
tune_durations[TONE_BATTERY_WARNING_SLOW_TUNE] = 800000;
|
||||||
tune_durations[TONE_SINGLE_BEEP_TUNE] = 300000;
|
tune_durations[TONE_SINGLE_BEEP_TUNE] = 300000;
|
||||||
tune_control_pub = orb_advertise(ORB_ID(tune_control), &tune_control);
|
tune_control_pub = orb_advertise_queue(ORB_ID(tune_control), &tune_control, tune_control_s::ORB_QUEUE_LENGTH);
|
||||||
return PX4_OK;
|
return PX4_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ void RC_Loss_Alarm::play_tune()
|
|||||||
tune_control.volume = tune_control_s::VOLUME_LEVEL_MAX;
|
tune_control.volume = tune_control_s::VOLUME_LEVEL_MAX;
|
||||||
|
|
||||||
if (_tune_control_pub == nullptr) {
|
if (_tune_control_pub == nullptr) {
|
||||||
_tune_control_pub = orb_advertise(ORB_ID(tune_control), &tune_control);
|
_tune_control_pub = orb_advertise_queue(ORB_ID(tune_control), &tune_control, tune_control_s::ORB_QUEUE_LENGTH);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
orb_publish(ORB_ID(tune_control), _tune_control_pub, &tune_control);
|
orb_publish(ORB_ID(tune_control), _tune_control_pub, &tune_control);
|
||||||
@@ -118,7 +118,7 @@ void RC_Loss_Alarm::stop_tune()
|
|||||||
tune_control.timestamp = hrt_absolute_time();
|
tune_control.timestamp = hrt_absolute_time();
|
||||||
|
|
||||||
if (_tune_control_pub == nullptr) {
|
if (_tune_control_pub == nullptr) {
|
||||||
_tune_control_pub = orb_advertise(ORB_ID(tune_control), &tune_control);
|
_tune_control_pub = orb_advertise_queue(ORB_ID(tune_control), &tune_control, tune_control_s::ORB_QUEUE_LENGTH);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
orb_publish(ORB_ID(tune_control), _tune_control_pub, &tune_control);
|
orb_publish(ORB_ID(tune_control), _tune_control_pub, &tune_control);
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ int test_tone(int argc, char *argv[])
|
|||||||
tune_control_s tune_control = {};
|
tune_control_s tune_control = {};
|
||||||
tune_control.tune_id = static_cast<int>(TuneID::NOTIFY_NEGATIVE);
|
tune_control.tune_id = static_cast<int>(TuneID::NOTIFY_NEGATIVE);
|
||||||
|
|
||||||
orb_advert_t tune_control_pub = orb_advertise(ORB_ID(tune_control), &tune_control);
|
orb_advert_t tune_control_pub = orb_advertise_queue(ORB_ID(tune_control), &tune_control,
|
||||||
|
tune_control_s::ORB_QUEUE_LENGTH);
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
PX4_INFO("Volume silenced for testing predefined tunes 0-20.");
|
PX4_INFO("Volume silenced for testing predefined tunes 0-20.");
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ static void publish_tune_control(tune_control_s &tune_control)
|
|||||||
|
|
||||||
if (tune_control_pub == nullptr) {
|
if (tune_control_pub == nullptr) {
|
||||||
// We have a minimum of 3 so that tune, stop, tune will fit
|
// We have a minimum of 3 so that tune, stop, tune will fit
|
||||||
tune_control_pub = orb_advertise_queue(ORB_ID(tune_control), &tune_control, 3);
|
tune_control_pub = orb_advertise_queue(ORB_ID(tune_control), &tune_control, tune_control_s::ORB_QUEUE_LENGTH);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
orb_publish(ORB_ID(tune_control), tune_control_pub, &tune_control);
|
orb_publish(ORB_ID(tune_control), tune_control_pub, &tune_control);
|
||||||
|
|||||||
Reference in New Issue
Block a user