AP_Notify: Add tone and light pattern for leak detection

This commit is contained in:
Jacob Walser 2017-02-07 13:54:57 -05:00 committed by Andrew Tridgell
parent a217b4c684
commit f3fa8403f8
4 changed files with 31 additions and 11 deletions

View File

@ -70,6 +70,7 @@ public:
uint32_t autopilot_mode : 1; // 1 if vehicle is in an autopilot flight mode (only used by OreoLEDs)
uint32_t firmware_update : 1; // 1 just before vehicle firmware is updated
uint32_t compass_cal_running: 1; // 1 if a compass calibration is running
uint32_t leak_detected : 1; // 1 if leak detected
float battery_voltage ; // battery voltage
// additional flags

View File

@ -180,7 +180,7 @@ void RGBLed::update_colours(void)
// gps failsafe pattern : flashing yellow and blue
// ekf_bad pattern : flashing yellow and red
if (AP_Notify::flags.failsafe_radio || AP_Notify::flags.failsafe_battery ||
AP_Notify::flags.ekf_bad) {
AP_Notify::flags.ekf_bad || AP_Notify::flags.leak_detected) {
switch(step) {
case 0:
case 1:
@ -197,7 +197,12 @@ void RGBLed::update_colours(void)
case 7:
case 8:
case 9:
if (AP_Notify::flags.ekf_bad) {
if (AP_Notify::flags.leak_detected) {
// purple if leak detected
_red_des = brightness;
_blue_des = brightness;
_green_des = brightness;
} else if (AP_Notify::flags.ekf_bad) {
// red on if ekf bad
_red_des = brightness;
_blue_des = _led_off;

View File

@ -87,6 +87,8 @@ const ToneAlarm_PX4::Tone ToneAlarm_PX4::_tones[] {
{ "MFT100L10DBDB>", false},
#define AP_NOTIFY_PX4_TONE_TUNING_ERROR 25
{ "MFT100L10>BBBBBBBB", false},
#define AP_NOTIFY_PX4_TONE_LEAK_DETECTED 26
{ "MBT255L8>A+AA-", true},
};
bool ToneAlarm_PX4::init()
@ -275,7 +277,9 @@ void ToneAlarm_PX4::update()
}else{
// disarming tune
play_tone(AP_NOTIFY_PX4_TONE_QUIET_NEU_FEEDBACK);
stop_cont_tone();
if (!flags.leak_detected) {
stop_cont_tone();
}
}
}
@ -317,6 +321,15 @@ void ToneAlarm_PX4::update()
}
}
if (flags.leak_detected != AP_Notify::flags.leak_detected) {
flags.leak_detected = AP_Notify::flags.leak_detected;
if (flags.leak_detected) {
play_tone(AP_NOTIFY_PX4_TONE_LEAK_DETECTED);
} else {
stop_cont_tone();
}
}
if (AP_Notify::events.tune_started) {
play_tone(AP_NOTIFY_PX4_TONE_TUNING_START);
AP_Notify::events.tune_started = 0;

View File

@ -51,14 +51,15 @@ private:
/// tonealarm_type - bitmask of states we track
struct tonealarm_type {
uint8_t armed : 1; // 0 = disarmed, 1 = armed
uint8_t failsafe_battery : 1; // 1 if battery failsafe
uint8_t parachute_release : 1; // 1 if parachute is being released
uint8_t pre_arm_check : 1; // 0 = failing checks, 1 = passed
uint8_t failsafe_radio : 1; // 1 if radio failsafe
uint8_t vehicle_lost : 1; // 1 if lost copter tone requested
uint8_t compass_cal_running : 1; // 1 if compass calibration is running
uint8_t waiting_for_throw : 1; // 1 if waiting for copter throw launch
uint16_t armed : 1; // 0 = disarmed, 1 = armed
uint16_t failsafe_battery : 1; // 1 if battery failsafe
uint16_t parachute_release : 1; // 1 if parachute is being released
uint16_t pre_arm_check : 1; // 0 = failing checks, 1 = passed
uint16_t failsafe_radio : 1; // 1 if radio failsafe
uint16_t vehicle_lost : 1; // 1 if lost copter tone requested
uint16_t compass_cal_running : 1; // 1 if compass calibration is running
uint16_t waiting_for_throw : 1; // 1 if waiting for copter throw launch
uint16_t leak_detected : 1; // 1 if leak detected
} flags;
int8_t _cont_tone_playing;