]> git.zerfleddert.de Git - fnordlicht-mini/commitdiff
add showcfg program
authorgitknilch <gitknilch@cwde.de>
Sat, 19 Mar 2011 20:17:43 +0000 (21:17 +0100)
committergitknilch <gitknilch@cwde.de>
Sat, 19 Mar 2011 20:17:43 +0000 (21:17 +0100)
firmware/fnordlicht-firmware/fnordlicht.c
firmware/fnordlicht-firmware/static_programs.c
firmware/fnordlicht-firmware/static_programs.h

index f0b011b3f6fe8b4ff30013c66ab8494870a99634..62c4e4056193a9cad894d7f7c201b210f4ce8674 100644 (file)
@@ -44,19 +44,14 @@ static void startup(void)
     if (storage_valid_config()) {
        /* set global address to stored value */
        global_remote.address = startup_config.startup_addr;
     if (storage_valid_config()) {
        /* set global address to stored value */
        global_remote.address = startup_config.startup_addr;
+    }
 
 
-        /* read default mode from storage (do nothing if mode is invalid) */
-        if (startup_config.params.mode == STARTUP_PROGRAM) {
-            /* start program */
-            script_start(0, startup_config.params.program, (union program_params_t *)startup_config.params.program_parameters);
-        }
-    } else {
-        /* start default program */
-        script_start_default();
-
-#if !CONFIG_SCRIPT
-        /* or set some default color */
-        global_pwm.target.red = 50;
+#if CONFIG_SCRIPT
+    /* start default program: showcfg FIXME cleanup magic values */
+    script_start(0u, 4u, (union program_params_t *)startup_config.params.program_parameters);
+#else
+    /* or set some default color */
+    global_pwm.target.red = 50u;
 #endif
     }
 }
 #endif
     }
 }
index c437fe7ad2ceda58e4cf58e560d8aa902d850093..d5a79e086090f829b151c74fa3d8981d9760c4f6 100644 (file)
@@ -37,8 +37,67 @@ PROGMEM program_handler static_programs[] = {
     program_colorwheel,
     program_random,
     program_replay,
     program_colorwheel,
     program_random,
     program_replay,
+    program_showcfg,
 };
 
 };
 
+PT_THREAD(program_showcfg(struct process_t *process))
+{
+    static uint16_t sleep;
+    struct rgb_color_t c, d;
+
+    PT_BEGIN(&process->pt);
+
+    c.red = (remote_address() & 0x01u) * 128u;
+    c.green = (remote_address() & 0x02u) * 128u;
+    c.blue = (remote_address() & 0x04u) * 128u;
+
+    d.red = d.green = d.blue = 128u;
+
+    pwm_fade_rgb(&d, 0xffu, 0);
+
+    PT_WAIT_UNTIL(&process->pt, pwm_target_reached());
+
+    /* sleep .5s (remember: we are called every 100ms) */
+    sleep = 5;
+    while (sleep--)
+           PT_YIELD(&process->pt);
+
+    pwm_fade_rgb(&c, 0xffu, 0);
+
+    PT_WAIT_UNTIL(&process->pt, pwm_target_reached());
+
+    /* sleep 1s (remember: we are called every 100ms) */
+    sleep = 10;
+    while (sleep--)
+           PT_YIELD(&process->pt);
+    pwm_fade_rgb(&d, 0xffu, 0);
+
+    PT_WAIT_UNTIL(&process->pt, pwm_target_reached());
+
+    /* sleep .5s (remember: we are called every 100ms) */
+    sleep = 5;
+    while (sleep--)
+           PT_YIELD(&process->pt);
+
+    pwm_fade_rgb(&c, 0xffu, 0);
+
+    PT_WAIT_UNTIL(&process->pt, pwm_target_reached());
+
+    /* sleep 1s (remember: we are called every 100ms) */
+    sleep = 10;
+    while (sleep--)
+           PT_YIELD(&process->pt);
+
+    /* 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();
+    }
+
+    PT_END(&process->pt);
+}
+
 PT_THREAD(program_colorwheel(struct process_t *process))
 {
     static uint16_t sleep;
 PT_THREAD(program_colorwheel(struct process_t *process))
 {
     static uint16_t sleep;
index b544db51404b4beddcc73a485e9534f5242bd22d..7b3cc3fda14744ecc61da5860ce58c4d85d792f2 100644 (file)
@@ -90,12 +90,13 @@ struct process_t {
 #if CONFIG_SCRIPT
 
 /* global list of programs */
 #if CONFIG_SCRIPT
 
 /* global list of programs */
-#define STATIC_PROGRAMS_LEN 3
+#define STATIC_PROGRAMS_LEN 4
 extern program_handler static_programs[];
 
 PT_THREAD(program_colorwheel(struct process_t *process));
 PT_THREAD(program_random(struct process_t *process));
 PT_THREAD(program_replay(struct process_t *process));
 extern program_handler static_programs[];
 
 PT_THREAD(program_colorwheel(struct process_t *process));
 PT_THREAD(program_random(struct process_t *process));
 PT_THREAD(program_replay(struct process_t *process));
+PT_THREAD(program_showcfg(struct process_t *process));
 
 #endif
 #endif
 
 #endif
 #endif
Impressum, Datenschutz