Black Lives Matter - Action and Equality.
0

Unexplained CircuitPython/NeoPixel error
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Unexplained CircuitPython/NeoPixel error

by flounder on Tue May 19, 2020 1:24 am

This could have been posted in glowy things, or FeatherWing, but it seemed that this was the best forum.
OK, I have the following CircuitPython code. This code is embedded in a double loop that is in the range(0, 32), where start is the outer loop and pixel is the inner loop. The goal is a "lamp test" drawing a spectrum from red to violet on the 32 pixels of a NeoPixel FeatherWing, then repeating it starting one pixel further over. The effect is supposed to be a spectrum that crawls across the display. But I get a runtime error
Code: Select all | TOGGLE FULL SIZE
12. while(True):
14.    for start in range(0, 32):
15.        for pixel in range(0, 32):
18.            print('H = ', H)
19.            HSVcolor = fancy.CHSV(H, 1.0, 1.0)
20.            print('HSVcolor = ', HSVcolor)
21.            RGBcolor = fancy.CRGB(HSVcolor)
22.            print('RGBcolor = ', RGBcolor)
23.            pixels[(start + pixel) % 32] = RGBcolor
24.            pixels.show()

And it produces the following output (I have put the line numbers on the left to show what lines produced the output)
Code: Select all | TOGGLE FULL SIZE
18.     H =  0.0
20.     HSVcolor =  (0.0, 1.0, 1.0)
22.     RGBcolor =  (1.0, 0.0, 0.0)
23.     Traceback (most recent call last):
           File "code.py", line 23, in <module>
           TypeError: object 'CRGB' is not a tuple or list

I'm perplexed. The value returned from HSVcolor is (0.0, 1.0, 1.0), which looks to me like a tuple. This tuple is passed to fancy.CRGB is the tuple returned from HSVcolor. The value returned in RGBcolor is the triple (1.0, 0.0, 0.0), which is pure red (corresponding to H=0.0). So I don't understand the error message.

flounder
 
Posts: 389
Joined: Wed Sep 18, 2013 9:10 pm
Location: Pittsburgh PA

Re: Unexplained CircuitPython/NeoPixel error

by dastels on Tue May 19, 2020 11:05 am

RGBcolor is an instance of CRGB, so you'll need to extract the color values from it to set the pixel color, probable RGBcolor.pack().

Dave

dastels
 
Posts: 2473
Joined: Tue Oct 20, 2015 3:22 pm

Re: Unexplained CircuitPython/NeoPixel error

by flounder on Sun May 24, 2020 12:45 am

thanks, that worked

flounder
 
Posts: 389
Joined: Wed Sep 18, 2013 9:10 pm
Location: Pittsburgh PA

Please be positive and constructive with your questions and comments.