Skip to content
Snippets Groups Projects
Commit 0c342591 authored by Jens Nolte's avatar Jens Nolte
Browse files

Revert to old led render loop

parent 3de03782
No related branches found
No related tags found
No related merge requests found
...@@ -18,34 +18,21 @@ qthing::led_color_t dummy_handler(uint8_t strip, uint16_t led, qthing::led_color ...@@ -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; static qthing::led_color_handler_t led_handler = dummy_handler;
void render_loop(void *ignored) { 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); digitalLeds_initStrands(leds, strips_cfged);
TickType_t lastEndOfUpdate = xTaskGetTickCount();
TickType_t lastWakeTime = xTaskGetTickCount(); TickType_t lastWakeTime = xTaskGetTickCount();
while (true) { while (true) {
// generate led data
for (uint8_t strip = 0; strip < strips_cfged; strip++) { for (uint8_t strip = 0; strip < strips_cfged; strip++) {
for (uint16_t led = 0; led < leds[strip].numPixels; led++) { for (uint16_t led = 0; led < leds[strip].numPixels; led++) {
pixelColor_t last = leds[strip].pixels[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); qthing::led_color_t pixel = led_handler(strip, led, last_led);
leds[strip].pixels[led] = pixelFromRGBW(pixel.r, pixel.g, pixel.b, pixel.w); leds[strip].pixels[led] = pixelFromRGBW(pixel.r, pixel.g, pixel.b, pixel.w);
} }
} }
// before sending data: wait until led latch time has expired for (uint8_t i = 0; i < strips_cfged; i++) digitalLeds_updatePixels(&leds[i]);
// this returns immediately when the minimum time has expired already vTaskDelayUntil(&lastWakeTime, 1000 / render_frequency / portTICK_PERIOD_MS);
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();
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment