LED color cycling

Gast #6241873
Lesenswert?

Hello currently this is my phyton function for cycling through a led 
stripe with all colors:
1
def cycleLights(self):
2
                t = threading.currentThread()
3
                head  = 0               # Index of first 'on' pixel
4
                tail  = -10             # Index of last 'off' pixel
5
                color = 0xFF0000        # 'On' color (starts red)
6

7
                while getattr(t, "do_run", True):
8
                        self.strip.setPixelColor(head, color) # Turn on 'head' pixel
9
                        self.strip.setPixelColor(tail, 0)     # Turn off 'tail'
10
                        self.strip.show()                     # Refresh strip
11
                        time.sleep(1.0 / 80)             # Pause 20 milliseconds (~50 fps)
12

13
                        head += 1                        # Advance head position
14
                        if(head >= self.numpixels):           # Off end of strip?
15
                                head    = 0              # Reset to start
16
                                color >>= 1              # Red->green->blue->black
17
                                if(color == 0): color = 0xFF0000 # If black, reset to red
18

19
                        tail += 1                        # Advance tail position
20
                        if(tail >= self.numpixels): tail = 0  # Off end? Reset


But i didn't get all colors how can I achiev to circly through the whole 
spectrum???

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren