-
Notifications
You must be signed in to change notification settings - Fork 626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed strandtest.py #258
Fixed strandtest.py #258
Changes from 3 commits
0a87807
18832d7
4164dcd
09cc2a1
88bd3b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/usr/bin/env python3 | ||
# NeoPixel library strandtest example | ||
# Author: Tony DiCola ([email protected]) | ||
# | ||
|
@@ -11,15 +12,15 @@ | |
import signal | ||
import sys | ||
def signal_handler(signal, frame): | ||
colorWipe(strip, Color(0,0,0)) | ||
sys.exit(0) | ||
colorWipe(strip, Color(0,0,0)) | ||
sys.exit(0) | ||
|
||
def opt_parse(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-c', action='store_true', help='clear the display on exit') | ||
args = parser.parse_args() | ||
if args.c: | ||
signal.signal(signal.SIGINT, signal_handler) | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-c', action='store_true', help='clear the display on exit') | ||
args = parser.parse_args() | ||
if args.c: | ||
signal.signal(signal.SIGINT, signal_handler) | ||
|
||
# LED strip configuration: | ||
LED_COUNT = 16 # Number of LED pixels. | ||
|
@@ -30,7 +31,6 @@ def opt_parse(): | |
LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest | ||
LED_INVERT = False # True to invert the signal (when using NPN transistor level shift) | ||
LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53 | ||
LED_STRIP = ws.WS2811_STRIP_GRB # Strip type and colour ordering | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be imported and preserved to ensure the difference between WS2811 and SK6812 pixels is clear to anyone hacking on this code. |
||
|
||
|
||
|
||
|
@@ -93,25 +93,34 @@ def theaterChaseRainbow(strip, wait_ms=50): | |
|
||
# Main program logic follows: | ||
if __name__ == '__main__': | ||
# Process arguments | ||
opt_parse() | ||
# Process arguments | ||
opt_parse() | ||
|
||
# Create NeoPixel object with appropriate configuration. | ||
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL, LED_STRIP) | ||
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL) | ||
# Intialize the library (must be called once before other functions). | ||
strip.begin() | ||
|
||
print ('Press Ctrl-C to quit.') | ||
while True: | ||
print ('Color wipe animations.') | ||
colorWipe(strip, Color(255, 0, 0)) # Red wipe | ||
colorWipe(strip, Color(0, 255, 0)) # Blue wipe | ||
colorWipe(strip, Color(0, 0, 255)) # Green wipe | ||
print ('Theater chase animations.') | ||
theaterChase(strip, Color(127, 127, 127)) # White theater chase | ||
theaterChase(strip, Color(127, 0, 0)) # Red theater chase | ||
theaterChase(strip, Color( 0, 0, 127)) # Blue theater chase | ||
print ('Rainbow animations.') | ||
rainbow(strip) | ||
rainbowCycle(strip) | ||
theaterChaseRainbow(strip) | ||
|
||
try: | ||
|
||
while True: | ||
print ('Color wipe animations.') | ||
colorWipe(strip, Color(255, 0, 0)) # Red wipe | ||
colorWipe(strip, Color(0, 255, 0)) # Blue wipe | ||
colorWipe(strip, Color(0, 0, 255)) # Green wipe | ||
print ('Theater chase animations.') | ||
theaterChase(strip, Color(127, 127, 127)) # White theater chase | ||
theaterChase(strip, Color(127, 0, 0)) # Red theater chase | ||
theaterChase(strip, Color( 0, 0, 127)) # Blue theater chase | ||
print ('Rainbow animations.') | ||
rainbow(strip) | ||
rainbowCycle(strip) | ||
theaterChaseRainbow(strip) | ||
|
||
except KeyboardInterrupt: | ||
for j in range(strip.numPixels()): | ||
strip.setPixelColor(j, Color(0,0,0)) | ||
strip.show() | ||
exit(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation should be intervals of 4 spaces, not tabs. See: https://www.python.org/dev/peps/pep-0008/#indentation