mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
rc loss alarm: stop on RC reconnect
This commit is contained in:
committed by
Lorenz Meier
parent
3d668d871b
commit
39d1751bbe
@@ -86,8 +86,12 @@ void RC_Loss_Alarm::process()
|
|||||||
|
|
||||||
if (_was_armed && _had_rc && _vehicle_status.rc_signal_lost &&
|
if (_was_armed && _had_rc && _vehicle_status.rc_signal_lost &&
|
||||||
_vehicle_status.arming_state != vehicle_status_s::ARMING_STATE_ARMED) {
|
_vehicle_status.arming_state != vehicle_status_s::ARMING_STATE_ARMED) {
|
||||||
|
|
||||||
play_tune();
|
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 rc_loss */
|
||||||
} /* namespace events */
|
} /* namespace events */
|
||||||
|
|||||||
@@ -68,9 +68,13 @@ private:
|
|||||||
/** Publish tune control to sound alarm */
|
/** Publish tune control to sound alarm */
|
||||||
void play_tune();
|
void play_tune();
|
||||||
|
|
||||||
|
/** Publish tune control to interrupt any sound */
|
||||||
|
void stop_tune();
|
||||||
|
|
||||||
struct vehicle_status_s _vehicle_status = {};
|
struct vehicle_status_s _vehicle_status = {};
|
||||||
bool _was_armed = false;
|
bool _was_armed = false;
|
||||||
bool _had_rc = false; // Don't trigger alarm for systems without RC
|
bool _had_rc = false; // Don't trigger alarm for systems without RC
|
||||||
|
bool _alarm_playing = false;
|
||||||
orb_advert_t _tune_control_pub = nullptr;
|
orb_advert_t _tune_control_pub = nullptr;
|
||||||
const events::SubscriberHandler &_subscriber_handler;
|
const events::SubscriberHandler &_subscriber_handler;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user