From 0c34259109229bd179c8e7812921149976e8a8cc Mon Sep 17 00:00:00 2001 From: Jens Nolte <jens@nightmarestudio.de> Date: Mon, 27 Jan 2020 00:50:57 +0100 Subject: [PATCH] Revert to old led render loop --- main/peripherals/led_strip.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/main/peripherals/led_strip.cpp b/main/peripherals/led_strip.cpp index 9587607..77e7d51 100644 --- a/main/peripherals/led_strip.cpp +++ b/main/peripherals/led_strip.cpp @@ -18,34 +18,21 @@ qthing::led_color_t dummy_handler(uint8_t strip, uint16_t led, qthing::led_color static qthing::led_color_handler_t led_handler = dummy_handler; void render_loop(void *ignored) { - // latch time or at least one tick, whatever is longer - const TickType_t latchTime = std::max(6 / portTICK_PERIOD_MS, (TickType_t)1); - digitalLeds_initStrands(leds, strips_cfged); - TickType_t lastEndOfUpdate = xTaskGetTickCount(); TickType_t lastWakeTime = xTaskGetTickCount(); while (true) { - // generate led data for (uint8_t strip = 0; strip < strips_cfged; strip++) { for (uint16_t led = 0; led < leds[strip].numPixels; led++) { pixelColor_t last = leds[strip].pixels[led]; - qthing::led_color_t last_led = qthing::led_color_t(last.r, last.g, last.b, last.w); + qthing::led_color_t last_led = {last.r, last.g, last.b, last.w}; qthing::led_color_t pixel = led_handler(strip, led, last_led); leds[strip].pixels[led] = pixelFromRGBW(pixel.r, pixel.g, pixel.b, pixel.w); } } - // before sending data: wait until led latch time has expired - // this returns immediately when the minimum time has expired already - vTaskDelayUntil(&lastEndOfUpdate, latchTime); - - for (uint8_t i = 0; i < strips_cfged; i++) { - digitalLeds_updatePixels(&leds[i]); - } - - // store time after sending data so we know later when the led latch time has expired - lastEndOfUpdate = xTaskGetTickCount(); + for (uint8_t i = 0; i < strips_cfged; i++) digitalLeds_updatePixels(&leds[i]); + vTaskDelayUntil(&lastWakeTime, 1000 / render_frequency / portTICK_PERIOD_MS); } } -- GitLab