diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-11-16 00:57:44 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-11-16 00:57:44 +0100 |
commit | 4f898b27ebe9d79c6900cf1cd6dfcd08b4f6f8fa (patch) | |
tree | 74273a2f9d84d26e93e766944c43127fb4bd1a41 | |
parent | 18dc5e342905f6171b54adba6de8a27d65d62ab2 (diff) | |
parent | 63707ef058f01e324d8d74cf6bc48635e09ab507 (diff) | |
download | px4-firmware-4f898b27ebe9d79c6900cf1cd6dfcd08b4f6f8fa.tar.gz px4-firmware-4f898b27ebe9d79c6900cf1cd6dfcd08b4f6f8fa.tar.bz2 px4-firmware-4f898b27ebe9d79c6900cf1cd6dfcd08b4f6f8fa.zip |
Merge branch 'lights'
-rw-r--r-- | src/modules/px4iofirmware/px4io.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/modules/px4iofirmware/px4io.c b/src/modules/px4iofirmware/px4io.c index 30f32b38e..8abfb0d2e 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,54 @@ heartbeat_blink(void) { static bool heartbeat = false; LED_BLUE(heartbeat = !heartbeat); +} + +static void +ring_blink(void) +{ #ifdef GPIO_LED4 - LED_RING(heartbeat); + + // 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); + + 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) / 9; + brightness_counter = 0; + on_counter = 0; + counter++; + } + #endif } @@ -300,6 +349,8 @@ user_start(int argc, char *argv[]) heartbeat_blink(); } + ring_blink(); + check_reboot(); /* check for debug activity (default: none) */ |