diff options
Diffstat (limited to 'main/main.c')
-rw-r--r-- | main/main.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/main/main.c b/main/main.c index 691043d..9cd4f0f 100644 --- a/main/main.c +++ b/main/main.c @@ -46,6 +46,26 @@ static ws_params_t ws_params; +/* Ticks the clock at a constant rate independent of the time it takes to write + * to the led strip. */ +portTASK_FUNCTION(time_keeper, params_) +{ + ws_params_t* params = (ws_params_t*) params_; + + TickType_t last_wake; + const TickType_t freq = 1; + + // Initialise the xLastWakeTime variable with the current time. + last_wake = xTaskGetTickCount(); + + for( ;; ) + { + // Wait for the next cycle. + vTaskDelayUntil( &last_wake, freq ); + params->state.time += params->state.timetick; + } +} + void app_main(void) { esp_err_t error; @@ -71,6 +91,7 @@ void app_main(void) printf("miso: %d\n", PIN_NUM_MISO); printf("mosi: %d\n", PIN_NUM_MOSI); printf("sclk: %d\n", PIN_NUM_CLK); + printf("Tick period ms: %d\n", portTICK_PERIOD_MS); error = spi_bus_initialize(HSPI_HOST, &cfg, SPI_DMA_CH_AUTO); printf("Bus Init\n"); @@ -84,6 +105,7 @@ void app_main(void) printf("Configuration complete!!\n"); + xTaskCreate(time_keeper, "time_keeper", 1024, &ws_params, 1, NULL); xTaskCreate(ws2812b_write_task, "ws2812b_writer", 4096, &ws_params, 1, NULL); xTaskCreate(tcp_server, "tcp_server", 4096, &ws_params, 2, NULL); } |