summaryrefslogtreecommitdiffstats
path: root/fade.c
diff options
context:
space:
mode:
Diffstat (limited to 'fade.c')
-rw-r--r--fade.c41
1 files changed, 41 insertions, 0 deletions
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;
+ }
+}