]> git.zerfleddert.de Git - fnordlicht-mini/blobdiff - firmware/fnordlicht-firmware/static_programs.c
fix config.mk file header comment
[fnordlicht-mini] / firmware / fnordlicht-firmware / static_programs.c
index c437fe7ad2ceda58e4cf58e560d8aa902d850093..19edb2f8262a1e06a58a925985af1b293f2334c7 100644 (file)
@@ -29,6 +29,7 @@
 #include "remote.h"
 #include "../common/common.h"
 #include "storage.h"
+#include "script.h"
 
 #if CONFIG_SCRIPT
 
@@ -37,8 +38,59 @@ PROGMEM program_handler static_programs[] = {
     program_colorwheel,
     program_random,
     program_replay,
+    program_showcfg,
 };
 
+#define DEBUG_COLORLEVEL 32u
+
+PT_THREAD(program_showcfg(struct process_t *process))
+{
+    static uint16_t sleep;
+    static struct rgb_color_t c, d;
+    static uint8_t i;
+
+    PT_BEGIN(&process->pt);
+
+    c.red = (remote_address() & 0x01u) ? DEBUG_COLORLEVEL : 0;
+    c.green = (remote_address() & 0x02u) ? DEBUG_COLORLEVEL : 0;
+    c.blue = (remote_address() & 0x04u) ? DEBUG_COLORLEVEL : 0;
+
+    d.red = d.green = d.blue = 0;
+
+    global_pwm.target.rgb = c;
+
+    for (i = 0; i < 3u; i++)
+    {
+        /* sleep 1s (remember: we are called every 100ms) */
+        sleep = 10;
+        while (sleep--)
+            PT_YIELD(&process->pt);
+
+        global_pwm.target.rgb = c;
+
+        sleep = 5;
+        while (sleep--)
+            PT_YIELD(&process->pt);
+
+        global_pwm.target.rgb = d;
+    }
+
+    script_stop();
+
+    /* now start default script */
+    if (storage_valid_config() && (startup_config.params.mode == STARTUP_PROGRAM)) {
+        script_start(0, startup_config.params.program, (union program_params_t *)startup_config.params.program_parameters);
+    } else {
+        script_start_default();
+    }
+
+    /* hack: script_start() stuff above will reinitialize PT structures, so we
+       can't call any PT stuff any more and quit directly */
+    return 0;
+
+    PT_END(&process->pt);
+}
+
 PT_THREAD(program_colorwheel(struct process_t *process))
 {
     static uint16_t sleep;
Impressum, Datenschutz