diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-11-23 12:06:46 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-11-23 12:06:46 +0100 |
commit | 461e9889b334865f1eec0c1d7a20067ff5a647ea (patch) | |
tree | 2ebcd3c57679153676a6674f60911c28f40c6031 /src/modules/px4iofirmware/px4io.c | |
parent | 4030b20de7921d5e9673ce18215f76f0820c1ec7 (diff) | |
parent | 138c25ec74f08db6f6759053d0200058a794c196 (diff) | |
download | px4-firmware-461e9889b334865f1eec0c1d7a20067ff5a647ea.tar.gz px4-firmware-461e9889b334865f1eec0c1d7a20067ff5a647ea.tar.bz2 px4-firmware-461e9889b334865f1eec0c1d7a20067ff5a647ea.zip |
Merged master
Diffstat (limited to 'src/modules/px4iofirmware/px4io.c')
-rw-r--r-- | src/modules/px4iofirmware/px4io.c | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/src/modules/px4iofirmware/px4io.c b/src/modules/px4iofirmware/px4io.c index 1e5c4ef80..c31342262 100644 --- a/src/modules/px4iofirmware/px4io.c +++ b/src/modules/px4iofirmware/px4io.c @@ -85,6 +85,9 @@ static volatile uint8_t msg_next_out, msg_next_in; #define NUM_MSG 2 static char msg[NUM_MSG][40]; +static void heartbeat_blink(void); +static void ring_blink(void); + /* * add a debug message to be printed on the console */ @@ -124,8 +127,64 @@ heartbeat_blink(void) { static bool heartbeat = false; LED_BLUE(heartbeat = !heartbeat); +} + +static void +ring_blink(void) +{ #ifdef GPIO_LED4 - LED_RING(heartbeat); + + if (/* IO armed */ (r_status_flags & PX4IO_P_STATUS_FLAGS_SAFETY_OFF) + /* and FMU is armed */ && (r_setup_arming & PX4IO_P_SETUP_ARMING_FMU_ARMED)) { + LED_RING(1); + return; + } + + // XXX this led code does have + // intentionally a few magic numbers. + const unsigned max_brightness = 118; + + static unsigned counter = 0; + static unsigned brightness = max_brightness; + static unsigned brightness_counter = 0; + static unsigned on_counter = 0; + + if (brightness_counter < max_brightness) { + + bool on = ((on_counter * 100) / brightness_counter+1) <= ((brightness * 100) / max_brightness+1); + + // XXX once led is PWM driven, + // remove the ! in the line below + // to return to the proper breathe + // animation / pattern (currently inverted) + LED_RING(!on); + brightness_counter++; + + if (on) { + on_counter++; + } + + } else { + + if (counter >= 62) { + counter = 0; + } + + int n; + + if (counter < 32) { + n = counter; + + } else { + n = 62 - counter; + } + + brightness = (n * n) / 8; + brightness_counter = 0; + on_counter = 0; + counter++; + } + #endif } @@ -300,6 +359,8 @@ user_start(int argc, char *argv[]) heartbeat_blink(); } + ring_blink(); + check_reboot(); /* check for debug activity (default: none) */ |