aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2014-11-16 00:15:40 +0100
committerLorenz Meier <lm@inf.ethz.ch>2014-11-16 00:15:40 +0100
commitc0f32d44a2acd0f840b4246f90816a95dc6a7527 (patch)
tree22af900a2628078f5cfee15febdeb0214e923df1
parented0f28ed4191c296aa3592088dc7875a8246cabb (diff)
downloadpx4-firmware-c0f32d44a2acd0f840b4246f90816a95dc6a7527.tar.gz
px4-firmware-c0f32d44a2acd0f840b4246f90816a95dc6a7527.tar.bz2
px4-firmware-c0f32d44a2acd0f840b4246f90816a95dc6a7527.zip
First stab at animation
-rw-r--r--src/modules/px4iofirmware/px4io.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/modules/px4iofirmware/px4io.c b/src/modules/px4iofirmware/px4io.c
index 30f32b38e..51281f660 100644
--- a/src/modules/px4iofirmware/px4io.c
+++ b/src/modules/px4iofirmware/px4io.c
@@ -125,7 +125,45 @@ heartbeat_blink(void)
static bool heartbeat = false;
LED_BLUE(heartbeat = !heartbeat);
#ifdef GPIO_LED4
- LED_RING(heartbeat);
+
+ const unsigned max_brightness = 1000;
+
+ 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) <= ((brightness * 100) / max_brightness);
+
+ 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;// designed to be ~1000 / (31.0f * 31.0f);
+ brightness_counter = 0;
+ on_counter = 0;
+ }
+
#endif
}