From 9182b65ae2045c5087257751d30409deecf9520a Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Thu, 5 Dec 2024 22:50:53 -0700 Subject: Add system for having multiple "patterns" and add a couple. --- include/pattern.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 include/pattern.h (limited to 'include/pattern.h') 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 + +#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) -- cgit