Adafruit_CircuitPython_LED_Animation icon indicating copy to clipboard operation
Adafruit_CircuitPython_LED_Animation copied to clipboard

Bug in RainbowComet when tail_length > 256 when step=0

Open richsad opened this issue 3 years ago • 2 comments

The rainbow comet will be a single red color comet when tail_length is > 256 and step=0. I believe this may be caused by line 63 in the source:

if step == 0: self._colorwheel_step = int(256 / tail_length) consider tail_length = > 256 and that int() statement can yield 0. When that happens the RainbowComet will be all solid red

perhaps a simple fix is: if step == 0: self._colorwheel_step = max(int(256 / tail_length), 1)

richsad avatar Mar 31 '22 21:03 richsad

hmm, the code got reformatted a bit and failed to include the line feed after the if step == 0: statement

richsad avatar Mar 31 '22 21:03 richsad

Hi @richsad, good catch, want to submit a PR for that fix?

tekktrik avatar Apr 01 '22 04:04 tekktrik