diff --git a/ArduPlane/config.h b/ArduPlane/config.h index c0045b88bf..fd308b2ef1 100644 --- a/ArduPlane/config.h +++ b/ArduPlane/config.h @@ -809,3 +809,9 @@ #ifndef FENCE_ENABLE_PWM # define FENCE_ENABLE_PWM 1750 #endif + +// a digital pin to set high when the geo-fence triggers. Defaults +// to -1, which means don't activate a pin +#ifndef FENCE_TRIGGERED_PIN +# define FENCE_TRIGGERED_PIN -1 +#endif diff --git a/ArduPlane/geofence.pde b/ArduPlane/geofence.pde index c623ce05d9..bc72a4fa89 100644 --- a/ArduPlane/geofence.pde +++ b/ArduPlane/geofence.pde @@ -209,6 +209,9 @@ static void geofence_check(bool altitude_check_only) // we have moved back inside the fence geofence_state->fence_triggered = false; gcs_send_text_P(SEVERITY_LOW,PSTR("geo-fence OK")); +#if FENCE_TRIGGERED_PIN > 0 + digitalWrite(FENCE_TRIGGERED_PIN, LOW); +#endif } // we're inside, all is good with the world return; @@ -227,6 +230,11 @@ static void geofence_check(bool altitude_check_only) geofence_state->breach_count++; geofence_state->breach_time = millis(); geofence_state->breach_type = breach_type; + +#if FENCE_TRIGGERED_PIN > 0 + digitalWrite(FENCE_TRIGGERED_PIN, HIGH); +#endif + gcs_send_text_P(SEVERITY_LOW,PSTR("geo-fence triggered")); // see what action the user wants diff --git a/ArduPlane/system.pde b/ArduPlane/system.pde index e11f895074..249952a68b 100644 --- a/ArduPlane/system.pde +++ b/ArduPlane/system.pde @@ -224,6 +224,13 @@ static void init_ardupilot() #if CONFIG_RELAY == ENABLED DDRL |= B00000100; // Set Port L, pin 2 to output for the relay #endif + +#if FENCE_TRIGGERED_PIN > 0 + pinMode(FENCE_TRIGGERED_PIN, OUTPUT); + digitalWrite(FENCE_TRIGGERED_PIN, LOW); +#endif + + // If the switch is in 'menu' mode, run the main menu. // // Since we can't be sure that the setup or test mode won't leave