aboutsummaryrefslogtreecommitdiff
path: root/src/patterns/hearth.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-12-05 22:50:53 -0700
committerJosh Rahm <joshuarahm@gmail.com>2024-12-05 22:50:53 -0700
commit9182b65ae2045c5087257751d30409deecf9520a (patch)
treea9fd9807536f2d25d070725914fffdde8090da41 /src/patterns/hearth.c
parent05db4276d42471d78f2a00a90c8567e3c1c2e002 (diff)
downloadch573-9182b65ae2045c5087257751d30409deecf9520a.tar.gz
ch573-9182b65ae2045c5087257751d30409deecf9520a.tar.bz2
ch573-9182b65ae2045c5087257751d30409deecf9520a.zip
Add system for having multiple "patterns" and add a couple.
Diffstat (limited to 'src/patterns/hearth.c')
-rw-r--r--src/patterns/hearth.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/patterns/hearth.c b/src/patterns/hearth.c
new file mode 100644
index 0000000..373562a
--- /dev/null
+++ b/src/patterns/hearth.c
@@ -0,0 +1,28 @@
+#include "byte_math.h"
+#include "pattern.h"
+
+static rgb_t get_rgb(uint32_t time, size_t x)
+{
+ int r = 0, g = 0, b = 0;
+
+ uint8_t time8 = time & 0xff;
+ int w = 0 ; // calc_w(time8 + x * 10);
+
+ r = 0xff;
+ g = byte_scale(byte_sin(time8 + x * 2), 0x60);
+ b = 0;
+
+ rgb_t color;
+ color.color = 0;
+ color.r = clip(r + w);
+ color.g = clip(byte_scale(g, AS_BYTE(0.75)) + w);
+ color.b = clip(byte_scale(b, AS_BYTE(0.75)) + w);
+ return color;
+}
+
+static void reset(void)
+{
+}
+
+__attribute__((__section__(".patterns"))) volatile static pattern_t pat =
+ ((pattern_t){.get_rgb = get_rgb, .name = "Hearth", .reset = reset});