]> git.zerfleddert.de Git - fnordlicht-mini/blob - firmware/fnordlicht-firmware/static_programs.h
7b3cc3fda14744ecc61da5860ce58c4d85d792f2
[fnordlicht-mini] / firmware / fnordlicht-firmware / static_programs.h
1 /* vim:ts=4 sts=4 et tw=80
2 *
3 * fnordlicht firmware
4 *
5 * for additional information please
6 * see http://lochraster.org/fnordlichtmini
7 *
8 * (c) by Alexander Neumann <alexander@bumpern.de>
9 *
10 * This program is free software: you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 3 as published by
12 * the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #ifndef __STATIC_PROGRAMS_H
24 #define __STATIC_PROGRAMS_H
25
26 #include <stdint.h>
27 #include <stdbool.h>
28 #include "globals.h"
29 #include "../common/pt/pt.h"
30
31 struct process_t;
32 /* return value is char, see definition of PT_THREAD() */
33 typedef char (*program_handler)(struct process_t *current);
34
35 /* parameter structures (max 10 bytes) */
36 struct colorwheel_params_t
37 {
38 uint8_t fade_step;
39 uint8_t fade_delay;
40 uint8_t fade_sleep;
41 uint16_t hue_start;
42 int16_t hue_step;
43 int8_t add_addr;
44 uint8_t saturation;
45 uint8_t value;
46 };
47
48 struct random_params_t
49 {
50 uint16_t seed;
51 uint8_t use_address:1;
52 uint8_t wait_for_fade:1;
53 uint8_t reserved:6;
54 uint8_t fade_step;
55 uint8_t fade_delay;
56 uint16_t fade_sleep;
57 uint8_t saturation;
58 uint8_t value;
59 uint8_t min_distance;
60 };
61
62 struct replay_params_t
63 {
64 uint8_t start;
65 uint8_t end;
66 enum {
67 REPEAT_NONE = 0,
68 REPEAT_START = 1,
69 REPEAT_REVERSE = 2,
70 } repeat;
71 };
72
73 union program_params_t
74 {
75 /* parameters for static programs */
76 uint8_t raw[PROGRAM_PARAMETER_SIZE];
77 struct colorwheel_params_t colorwheel;
78 struct random_params_t random;
79 struct replay_params_t replay;
80 };
81
82 /* global process struct */
83 struct process_t {
84 program_handler execute;
85 struct pt pt;
86 bool enable;
87 union program_params_t params;
88 };
89
90 #if CONFIG_SCRIPT
91
92 /* global list of programs */
93 #define STATIC_PROGRAMS_LEN 4
94 extern program_handler static_programs[];
95
96 PT_THREAD(program_colorwheel(struct process_t *process));
97 PT_THREAD(program_random(struct process_t *process));
98 PT_THREAD(program_replay(struct process_t *process));
99 PT_THREAD(program_showcfg(struct process_t *process));
100
101 #endif
102 #endif
Impressum, Datenschutz