Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commander: Don't spam battery tune messages #11284

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/modules/commander/Commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,8 @@ Commander::run()
{
bool sensor_fail_tune_played = false;
bool arm_tune_played = false;
bool low_bat_tune_played = false;
bool crit_bat_tune_played = false;
bool was_landed = true;
bool was_falling = false;
bool was_armed = false;
Expand Down Expand Up @@ -2492,16 +2494,18 @@ Commander::run()
set_tune(TONE_ARMING_WARNING_TUNE);
arm_tune_played = true;

} else if (!status_flags.usb_connected &&
} else if (!crit_bat_tune_played && !status_flags.usb_connected &&
(status.hil_state != vehicle_status_s::HIL_STATE_ON) &&
(_battery_warning == battery_status_s::BATTERY_WARNING_CRITICAL)) {
/* play tune on battery critical */
set_tune(TONE_BATTERY_WARNING_FAST_TUNE);
crit_bat_tune_played = true;

} else if ((status.hil_state != vehicle_status_s::HIL_STATE_ON) &&
} else if (!low_bat_tune_played && (status.hil_state != vehicle_status_s::HIL_STATE_ON) &&
(_battery_warning == battery_status_s::BATTERY_WARNING_LOW)) {
/* play tune on battery warning */
set_tune(TONE_BATTERY_WARNING_SLOW_TUNE);
low_bat_tune_played = true;

} else if (status.failsafe) {
tune_failsafe(true);
Expand Down