aboutsummaryrefslogtreecommitdiff
path: root/main/ws2812b_writer.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2021-12-02 17:19:00 -0700
committerJosh Rahm <joshuarahm@gmail.com>2021-12-02 17:19:00 -0700
commit8d379bf60e50960f6c855cd6b9c83956a082f73d (patch)
treeabc799411d565f7e0330ceb6d2db5818ea987d6a /main/ws2812b_writer.c
parent62715093e446d952bbc3fa82fdb65deacd576be2 (diff)
downloadesp32-ws2812b-8d379bf60e50960f6c855cd6b9c83956a082f73d.tar.gz
esp32-ws2812b-8d379bf60e50960f6c855cd6b9c83956a082f73d.tar.bz2
esp32-ws2812b-8d379bf60e50960f6c855cd6b9c83956a082f73d.zip
Break out the state parmaters into their own include file.
This helps by creating one location to add state parameters.
Diffstat (limited to 'main/ws2812b_writer.c')
-rw-r--r--main/ws2812b_writer.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/main/ws2812b_writer.c b/main/ws2812b_writer.c
index 7d0e30f..f7176f1 100644
--- a/main/ws2812b_writer.c
+++ b/main/ws2812b_writer.c
@@ -85,17 +85,19 @@ void calculate_colors(
portTASK_FUNCTION(ws2812b_write_task, params)
{
ws_params_t* ws_params = (ws_params_t*) params;
-
reset_parameters(ws_params);
ws2812b_buffer_t* buffer = ws2812b_new_buffer(SIZE);
+
for (;;) {
- calculate_colors(ws_params, buffer);
- ws2812b_write(ws_params->drv, buffer);
- vTaskDelay(1);
- // TODO make this happen as a separate, timer task.
- ws_params->state.time += ws_params->state.timetick;
+ // Copy the parameters to avoid a change occuring during the calculation.
+ ws_params_t copy_params;
+ memcpy(&copy_params, ws_params, sizeof(ws_params_t));
+
+ calculate_colors(&copy_params, buffer);
+ ws2812b_write(copy_params.drv, buffer);
+ vTaskDelay(1);
}
}