Browse Source

Give priority to power off tune over other tunes (e.g. Battery Low)

Make Power Off tune not interruptable

This solves the case of Low Battery warning tune overriding the power
off tune, as now the Power off tune is not interruptable by any other
tune unless override flag is specified

commander_helper: resolve "redundant boolean literal in ternary expression result"
main
Junwoo Hwang 3 years ago committed by Matthias Grob
parent
commit
f66c3914f6
  1. 2
      src/lib/tunes/tune_definition.desc
  2. 8
      src/modules/commander/Commander.cpp
  3. 4
      src/modules/commander/commander_helper.cpp

2
src/lib/tunes/tune_definition.desc

@ -104,4 +104,4 @@ PX4_DEFINE_TUNE(15, SD_ERROR, "MNBG", @@ -104,4 +104,4 @@ PX4_DEFINE_TUNE(15, SD_ERROR, "MNBG",
PX4_DEFINE_TUNE(16, PROG_PX4IO, "MLL32CP8MB", false /* Program PX4IO */)
PX4_DEFINE_TUNE(17, PROG_PX4IO_OK, "MLL8CDE", false /* Program PX4IO success */)
PX4_DEFINE_TUNE(18, PROG_PX4IO_ERR, "ML<<CP4CP4CP4CP4CP4", true /* Program PX4IO fail */)
PX4_DEFINE_TUNE(19, POWER_OFF, "MFT255a8g8f8e8c8<b8a8g4", true /* When pressing off button */)
PX4_DEFINE_TUNE(19, POWER_OFF, "MFT255a8g8f8e8c8<b8a8g4", false /* When pressing off button */)

8
src/modules/commander/Commander.cpp

@ -107,13 +107,11 @@ static_assert(sizeof(actuator_armed_s) == 16, "actuator_armed equality operator @@ -107,13 +107,11 @@ static_assert(sizeof(actuator_armed_s) == 16, "actuator_armed equality operator
#if defined(BOARD_HAS_POWER_CONTROL)
static orb_advert_t tune_control_pub = nullptr;
static void play_power_button_down_tune()
{
tune_control_s tune_control{};
tune_control.volume = tune_control_s::VOLUME_LEVEL_DEFAULT;
tune_control.tune_id = tune_control_s::TUNE_ID_POWER_OFF;
tune_control.timestamp = hrt_absolute_time();
orb_publish(ORB_ID(tune_control), tune_control_pub, &tune_control);
// Override any other tunes because power-off sound should have the priority
set_tune_override(tune_control_s::TUNE_ID_POWER_OFF);
}
static void stop_tune()

4
src/modules/commander/commander_helper.cpp

@ -177,8 +177,8 @@ void set_tune(const int tune_id) @@ -177,8 +177,8 @@ void set_tune(const int tune_id)
{
const hrt_abstime current_time = hrt_absolute_time();
const unsigned int new_tune_duration = tune_durations[tune_id];
const bool current_tune_is_repeating = (tune_end == 0) ? true : false;
const bool new_tune_is_repeating = (new_tune_duration == 0) ? true : false;
const bool current_tune_is_repeating = (tune_end == 0);
const bool new_tune_is_repeating = (new_tune_duration == 0);
bool set_new_tune = false;

Loading…
Cancel
Save