aboutsummaryrefslogtreecommitdiff
path: root/apps/px4io
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2012-12-19 22:24:00 -0800
committerpx4dev <px4@purgatory.org>2012-12-19 22:24:00 -0800
commit73763353d094e151dc95bc827a1bb4da84939ed0 (patch)
tree875e5a75195ebe1251f38f98c201b9f1cf6cbbbc /apps/px4io
parentfd771f67f2a2392d5ba2b7dd74100338859af6d7 (diff)
parentf40e4d13aa1c6cd854b848f1cd0c3a017e719138 (diff)
downloadpx4-firmware-73763353d094e151dc95bc827a1bb4da84939ed0.tar.gz
px4-firmware-73763353d094e151dc95bc827a1bb4da84939ed0.tar.bz2
px4-firmware-73763353d094e151dc95bc827a1bb4da84939ed0.zip
Merge branch 'master' into DSM-decoder-fix
Diffstat (limited to 'apps/px4io')
-rw-r--r--apps/px4io/safety.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/apps/px4io/safety.c b/apps/px4io/safety.c
index d5bd103c1..60d20905a 100644
--- a/apps/px4io/safety.c
+++ b/apps/px4io/safety.c
@@ -60,10 +60,19 @@ static struct hrt_call failsafe_call;
*/
static unsigned counter;
+/*
+ * Define the various LED flash sequences for each system state.
+ */
+#define LED_PATTERN_SAFE 0xffff // always on
+#define LED_PATTERN_FMU_ARMED 0x4444 // slow blinking
+#define LED_PATTERN_IO_ARMED 0x5555 // fast blinking
+#define LED_PATTERN_IO_FMU_ARMED 0x5050 // long off then double blink
+
+static unsigned blink_counter = 0;
+
#define ARM_COUNTER_THRESHOLD 10
#define DISARM_COUNTER_THRESHOLD 2
-static bool safety_led_state;
static bool safety_button_pressed;
static void safety_check_button(void *arg);
@@ -120,15 +129,25 @@ safety_check_button(void *arg)
counter = 0;
}
- /* when armed, toggle the LED; when safe, leave it on */
+ /* Select the appropriate LED flash pattern depending on the current IO/FMU arm state */
+ uint16_t pattern = LED_PATTERN_SAFE;
if (system_state.armed) {
- safety_led_state = !safety_led_state;
- } else {
- safety_led_state = true;
+ if (system_state.arm_ok) {
+ pattern = LED_PATTERN_IO_FMU_ARMED;
+ } else {
+ pattern = LED_PATTERN_IO_ARMED;
+ }
+ } else if (system_state.arm_ok) {
+ pattern = LED_PATTERN_FMU_ARMED;
}
- LED_SAFETY(safety_led_state);
-}
+ /* Turn the LED on if we have a 1 at the current bit position */
+ LED_SAFETY(pattern & (1 << blink_counter++));
+
+ if (blink_counter > 15) {
+ blink_counter = 0;
+ }
+}
static void
heartbeat_blink(void *arg)