From 68b5f182af145fdd9e62c9dde3eedcb9108f5ba4 Mon Sep 17 00:00:00 2001 From: Tobias Wiese Date: Mon, 3 May 2021 23:58:30 +0200 Subject: Initial commit Signed-off-by: Tobias Wiese --- fade.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 fade.c (limited to 'fade.c') diff --git a/fade.c b/fade.c new file mode 100644 index 0000000..09d6233 --- /dev/null +++ b/fade.c @@ -0,0 +1,41 @@ +#include "libleds.h" + +static struct led_obj const PANEL = {0, 1<<7, 32, 8}; + +void write_all(struct led_color const color) +{ + led_write_rgb_all(PANEL, color); + led_latch(); +} + +void led_main() +{ + static int const STEP = 0x04; + static int const MIN = 0x10; + static int const MAX = 0xF0; + + struct led_color color = {MAX, MIN, MIN}; + while (1) { + for (int i = MIN; i < MAX; i += STEP) { + color.red -= STEP; + color.green += STEP; + write_all(color); + } + color.red = MIN; + color.green = MAX; + for (int i = MIN; i < MAX; i += STEP) { + color.green -= STEP; + color.blue += STEP; + write_all(color); + } + color.green = MIN; + color.blue = MAX; + for (int i = MIN; i < MAX; i += STEP) { + color.blue -= STEP; + color.red += STEP; + write_all(color); + } + color.blue = MIN; + color.red = MAX; + } +} -- cgit v1.2.3