Closed BlockThor closed 1 year ago
Yes, you are right, it should be
fill(color_wheel(random8()), i, size);
We should slow down speed as a led sub-segments increased size. If we have normal speed 1/16 sec for 60 leds it normal, but in case SIZE_LARGE there are only 15 sub-segments and in this case it looks too fast, so it should be slow down accordingly by 4 time - multiply by size.
May I ask you? If I have more corrections or improvements, should I add it here, or better make new patch?
Unfortunately, there's still an issue with how the LED index is being calculated. If I run this test sketch with your PR:
#include <WS2812FX.h>
#define LED_PIN 22 // digital pin used to drive the LED strip
#define LED_COUNT 64 // number of LEDs on the strip
WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(115200);
ws2812fx.init();
ws2812fx.setBrightness(32);
// parameters: index, start, stop, mode, color, speed, reverse
ws2812fx.setSegment(0, 0, 31, FX_MODE_SINGLE_DYNAMIC, GREEN, 5000, SIZE_LARGE);
ws2812fx.setSegment(1, 32, 63, FX_MODE_MULTI_DYNAMIC, BLUE, 5000, SIZE_LARGE);
ws2812fx.start();
}
void loop() {
ws2812fx.service();
}
I see the last 4 LEDs in the strip are off. The line
for(uint16_t i=_seg->start; i <= _seg->stop-size; i+=size) {
does not calculate the LED index properly for the last iteration of the for loop.
Can you double check?
Yes, you are right.
It should be for(uint16_t i=_seg->start; i <= _seg->stop; i+=size) {
But there is another problem: function fill
did not check the limit for end of segment.
And when I tested with two segments by 30 LEDs and SIZE_LARGE
when i=28 + size = 32
first segment lit up leds from begining of second segment.
Looks like the function fill should be overridden with another with an additional check for end of segment.
It would be better to start over and tackle each task individually.
Update 'mode_single_dynamic' and 'mode_multi_dynamic' to apply SIZE_OPTION. Harmonize speed.