geofence: added FENCE_TRIGGERED_PIN

this allows for a digital pin to be set high when the geofence
triggers. This pin can be connected to an external failsafe device
This commit is contained in:
Andrew Tridgell 2011-12-17 06:28:25 +11:00
parent eed0eea13b
commit ed17f64459
3 changed files with 21 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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