From 44c5fdffdf44f9da045485e922a5cd2e0c73f3f0 Mon Sep 17 00:00:00 2001
From: Randy Mackay <rmackay9@yahoo.com>
Date: Wed, 24 Dec 2014 22:23:00 +0900
Subject: [PATCH] Notify: add pre_arm_gps_check flag

RGB LED will remain flashing blue when vehicle is disarmed and this
check has failed (i.e. false).
---
 libraries/AP_Notify/AP_Notify.h    |  1 +
 libraries/AP_Notify/ToshibaLED.cpp | 24 +++++++++++++-----------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/libraries/AP_Notify/AP_Notify.h b/libraries/AP_Notify/AP_Notify.h
index 8e4924ff2..594094e6f 100644
--- a/libraries/AP_Notify/AP_Notify.h
+++ b/libraries/AP_Notify/AP_Notify.h
@@ -38,6 +38,7 @@ public:
         uint16_t baro_glitching     : 1;    // 1 if baro altitude is not good
         uint16_t armed              : 1;    // 0 = disarmed, 1 = armed
         uint16_t pre_arm_check      : 1;    // 0 = failing checks, 1 = passed
+        uint16_t pre_arm_gps_check  : 1;    // 0 = failing pre-arm GPS 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
diff --git a/libraries/AP_Notify/ToshibaLED.cpp b/libraries/AP_Notify/ToshibaLED.cpp
index 1460c0538..72341c1d8 100644
--- a/libraries/AP_Notify/ToshibaLED.cpp
+++ b/libraries/AP_Notify/ToshibaLED.cpp
@@ -223,32 +223,34 @@ void ToshibaLED::update_colours(void)
                     break;
             }
         }else{
-            // flashing green if disarmed with GPS 3d lock
-            // flashing blue if disarmed with no gps lock
+            // fast flashing green if disarmed with GPS 3D lock and DGPS
+            // slow flashing green if disarmed with GPS 3d lock (and no DGPS)
+            // flashing blue if disarmed with no gps lock or gps pre_arm checks have failed
+            bool fast_green = AP_Notify::flags.gps_status >= AP_GPS::GPS_OK_FIX_3D_DGPS && AP_Notify::flags.pre_arm_gps_check;
             switch(step) {
                 case 0:
-                    if (AP_Notify::flags.gps_status >= AP_GPS::GPS_OK_FIX_3D_DGPS) {
+                    if (fast_green) {
                         _green_des = brightness;
                     }
                     break;
                 case 1:
-                    if (AP_Notify::flags.gps_status >= AP_GPS::GPS_OK_FIX_3D_DGPS) {
+                    if (fast_green) {
                         _green_des = TOSHIBA_LED_OFF;
                     }
                     break;
                 case 2:
-                    if (AP_Notify::flags.gps_status >= AP_GPS::GPS_OK_FIX_3D_DGPS) {
+                    if (fast_green) {
                         _green_des = brightness;
                     }
                     break;
                 case 3:
-                    if (AP_Notify::flags.gps_status >= AP_GPS::GPS_OK_FIX_3D_DGPS) {
+                    if (fast_green) {
                         _green_des = TOSHIBA_LED_OFF;
                     }
                     break;
                 case 4:
                     _red_des = TOSHIBA_LED_OFF;
-                    if (AP_Notify::flags.gps_status >= AP_GPS::GPS_OK_FIX_3D) {
+                    if (AP_Notify::flags.gps_status >= AP_GPS::GPS_OK_FIX_3D && AP_Notify::flags.pre_arm_gps_check) {
                         // flashing green if disarmed with GPS 3d lock
                         _blue_des = TOSHIBA_LED_OFF;
                         _green_des = brightness;
@@ -259,24 +261,24 @@ void ToshibaLED::update_colours(void)
                     }
                     break;
                 case 5:
-                    if (AP_Notify::flags.gps_status >= AP_GPS::GPS_OK_FIX_3D_DGPS) {
+                    if (fast_green) {
                         _green_des = TOSHIBA_LED_OFF;
                     }
                     break;
 
                 case 6:
-                    if (AP_Notify::flags.gps_status >= AP_GPS::GPS_OK_FIX_3D_DGPS) {
+                    if (fast_green) {
                         _green_des = brightness;
                     }
                     break;
 
                 case 7:
-                    if (AP_Notify::flags.gps_status >= AP_GPS::GPS_OK_FIX_3D_DGPS) {
+                    if (fast_green) {
                         _green_des = TOSHIBA_LED_OFF;
                     }
                     break;
                 case 8:
-                    if (AP_Notify::flags.gps_status >= AP_GPS::GPS_OK_FIX_3D_DGPS) {
+                    if (fast_green) {
                         _green_des = brightness;
                     }
                     break;
-- 
GitLab