From b3c636dfa3bf26878b248d7ef8213aaf25dd7c4b Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Wed, 11 Sep 2013 14:36:05 +0900 Subject: [PATCH] AP_Notify: add radio and battery failsafe radio and battery failsafe are slow flashing yellow pre-arm check failure changed to double flashing yellow --- libraries/AP_Notify/AP_Notify.h | 14 +++++---- libraries/AP_Notify/ToshibaLED.cpp | 49 +++++++++++++++++++++++++----- 2 files changed, 49 insertions(+), 14 deletions(-) diff --git a/libraries/AP_Notify/AP_Notify.h b/libraries/AP_Notify/AP_Notify.h index a0f0ba34b4..9ad17d096c 100644 --- a/libraries/AP_Notify/AP_Notify.h +++ b/libraries/AP_Notify/AP_Notify.h @@ -29,12 +29,14 @@ class AP_Notify public: /// notify_type - bitmask of notification types struct notify_type { - uint16_t initialising : 1; // 1 if initialising and copter should not be moved - uint16_t gps_status : 2; // 0 = no gps, 1 = no lock, 2 = 2d lock, 3 = 3d lock - uint16_t armed : 1; // 0 = disarmed, 1 = armed - uint16_t pre_arm_check : 1; // 0 = failing checks, 1 = passed - uint16_t save_trim : 1; // 1 if gathering trim data - uint16_t esc_calibration: 1; // 1 if calibrating escs + uint16_t initialising : 1; // 1 if initialising and copter should not be moved + uint16_t gps_status : 2; // 0 = no gps, 1 = no lock, 2 = 2d lock, 3 = 3d lock + uint16_t armed : 1; // 0 = disarmed, 1 = armed + uint16_t pre_arm_check : 1; // 0 = failing checks, 1 = passed + uint16_t save_trim : 1; // 1 if gathering trim data + uint16_t esc_calibration : 1; // 1 if calibrating escs + uint16_t failsafe_radio : 1; // 1 if radio failsafe + uint16_t failsafe_battery : 1; // 1 if battery failsafe }; // the notify flags are static to allow direct class access diff --git a/libraries/AP_Notify/ToshibaLED.cpp b/libraries/AP_Notify/ToshibaLED.cpp index 35a5ac639f..4d3fc998b5 100644 --- a/libraries/AP_Notify/ToshibaLED.cpp +++ b/libraries/AP_Notify/ToshibaLED.cpp @@ -90,6 +90,7 @@ void ToshibaLED::update_colours(void) case 0: case 3: case 6: + // red on _red_des = TOSHIBA_LED_DIM; _blue_des = TOSHIBA_LED_OFF; _green_des = TOSHIBA_LED_OFF; @@ -98,6 +99,7 @@ void ToshibaLED::update_colours(void) case 1: case 4: case 7: + // blue on _red_des = TOSHIBA_LED_OFF; _blue_des = TOSHIBA_LED_DIM; _green_des = TOSHIBA_LED_OFF; @@ -106,12 +108,42 @@ void ToshibaLED::update_colours(void) case 2: case 5: case 8: + // green on _red_des = TOSHIBA_LED_OFF; _blue_des = TOSHIBA_LED_OFF; _green_des = TOSHIBA_LED_DIM; break; case 9: + // all off + _red_des = TOSHIBA_LED_OFF; + _blue_des = TOSHIBA_LED_OFF; + _green_des = TOSHIBA_LED_OFF; + break; + } + // exit so no other status modify this pattern + return; + } + + // failsafe patterns for radio and battery - single flash yellow + if (AP_Notify::flags.failsafe_radio || AP_Notify::flags.failsafe_battery) { + switch(step) { + case 0: + case 1: + case 2: + case 3: + case 4: + // yellow on + _red_des = TOSHIBA_LED_DIM; + _blue_des = TOSHIBA_LED_OFF; + _green_des = TOSHIBA_LED_DIM; + break; + case 5: + case 6: + case 7: + case 8: + case 9: + // all off _red_des = TOSHIBA_LED_OFF; _blue_des = TOSHIBA_LED_OFF; _green_des = TOSHIBA_LED_OFF; @@ -145,7 +177,7 @@ void ToshibaLED::update_colours(void) case 7: case 8: case 9: - // even display blue light + // all off _red_des = TOSHIBA_LED_OFF; _blue_des = TOSHIBA_LED_OFF; _green_des = TOSHIBA_LED_OFF; @@ -154,25 +186,25 @@ void ToshibaLED::update_colours(void) } return; }else{ - // flash yellow if failing pre-arm checks + // double flash yellow if failing pre-arm checks if (!AP_Notify::flags.pre_arm_check) { - // flashing blue if no gps lock switch(step) { case 0: case 1: - case 2: - case 3: case 4: + case 5: + // yellow on _red_des = TOSHIBA_LED_DIM; _blue_des = TOSHIBA_LED_OFF; _green_des = TOSHIBA_LED_DIM; break; - case 5: + case 2: + case 3: case 6: case 7: case 8: case 9: - // even display blue light + // all off _red_des = TOSHIBA_LED_OFF; _blue_des = TOSHIBA_LED_OFF; _green_des = TOSHIBA_LED_OFF; @@ -192,6 +224,7 @@ void ToshibaLED::update_colours(void) case 2: case 3: case 4: + // blue on _red_des = TOSHIBA_LED_OFF; _blue_des = TOSHIBA_LED_DIM; _green_des = TOSHIBA_LED_OFF; @@ -201,7 +234,7 @@ void ToshibaLED::update_colours(void) case 7: case 8: case 9: - // even display blue light + // all off _red_des = TOSHIBA_LED_OFF; _blue_des = TOSHIBA_LED_OFF; _green_des = TOSHIBA_LED_OFF;