diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-12-05 22:50:53 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-12-05 22:50:53 -0700 |
commit | 9182b65ae2045c5087257751d30409deecf9520a (patch) | |
tree | a9fd9807536f2d25d070725914fffdde8090da41 /include | |
parent | 05db4276d42471d78f2a00a90c8567e3c1c2e002 (diff) | |
download | ch573-9182b65ae2045c5087257751d30409deecf9520a.tar.gz ch573-9182b65ae2045c5087257751d30409deecf9520a.tar.bz2 ch573-9182b65ae2045c5087257751d30409deecf9520a.zip |
Add system for having multiple "patterns" and add a couple.
Diffstat (limited to 'include')
-rw-r--r-- | include/pattern.h | 26 |
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) |