aboutsummaryrefslogtreecommitdiff
path: root/include/pattern.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/pattern.h')
-rw-r--r--include/pattern.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/pattern.h b/include/pattern.h
new file mode 100644
index 0000000..f5d0a1b
--- /dev/null
+++ b/include/pattern.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include <stdint.h>
+
+#include "ws2812b.h"
+
+#define DEFINE_PATTERN \
+ __attribute__((__section__( \
+ ".patterns"))) volatile static pattern_t __FILE__ =
+
+typedef struct {
+ /* Name of the pattern. */
+ const char* name;
+
+ /* Return the rgb for the pixel at the given offset 'x' and time 't' */
+ rgb_t (*get_rgb)(uint32_t t, size_t x);
+
+ /* Resets the pattern to the beginning. */
+ void (*reset)(void);
+} pattern_t;
+
+extern pattern_t PATTERNS_START;
+extern pattern_t PATTERNS_END;
+
+#define patterns (&PATTERNS_START)
+#define n_patterns (&PATTERNS_END - &PATTERNS_START)