Skip to content
Snippets Groups Projects
Commit 39d1751b authored by Alessandro Simovic's avatar Alessandro Simovic Committed by Lorenz Meier
Browse files

rc loss alarm: stop on RC reconnect

parent 3d668d87
No related branches found
No related tags found
No related merge requests found
......@@ -86,8 +86,12 @@ void RC_Loss_Alarm::process()
if (_was_armed && _had_rc && _vehicle_status.rc_signal_lost &&
_vehicle_status.arming_state != vehicle_status_s::ARMING_STATE_ARMED) {
play_tune();
_alarm_playing = true;
} else if (_alarm_playing) {
stop_tune();
_alarm_playing = false;
}
}
......@@ -107,5 +111,19 @@ void RC_Loss_Alarm::play_tune()
}
}
void RC_Loss_Alarm::stop_tune()
{
struct tune_control_s tune_control = {};
tune_control.tune_override = true;
tune_control.timestamp = hrt_absolute_time();
if (_tune_control_pub == nullptr) {
_tune_control_pub = orb_advertise(ORB_ID(tune_control), &tune_control);
} else {
orb_publish(ORB_ID(tune_control), _tune_control_pub, &tune_control);
}
}
} /* namespace rc_loss */
} /* namespace events */
......@@ -68,9 +68,13 @@ private:
/** Publish tune control to sound alarm */
void play_tune();
/** Publish tune control to interrupt any sound */
void stop_tune();
struct vehicle_status_s _vehicle_status = {};
bool _was_armed = false;
bool _had_rc = false; // Don't trigger alarm for systems without RC
bool _alarm_playing = false;
orb_advert_t _tune_control_pub = nullptr;
const events::SubscriberHandler &_subscriber_handler;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment