rc loss alarm: stop on RC reconnect

This commit is contained in:
Alessandro Simovic
2019-03-29 14:28:39 +01:00
committed by Lorenz Meier
parent 3d668d871b
commit 39d1751bbe
2 changed files with 23 additions and 1 deletions
+19 -1
View File
@@ -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 */
+4
View File
@@ -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;
};