BLE_Colorific/flux.py, BLE_Colorific/colorific.py
Kinetic_POV/convert/convert.py, Raspberry_Pi_On_Air_Sign/onair.py Changed all the 2.x print statememts and try except to use the 3.9 standard in the files mentiond.
This commit is contained in:
parent
a15271cc9e
commit
3042f1ba1d
4 changed files with 40 additions and 40 deletions
|
|
@ -29,9 +29,9 @@ SLEEP_SEC = 0.05 # Amount of time to sleep between loop iterations.
|
|||
|
||||
# Get bulb address from command parameters.
|
||||
if len(sys.argv) != 2:
|
||||
print 'Error must specify bulb address as parameter!'
|
||||
print 'Usage: sudo python colorific.py <bulb address>'
|
||||
print 'Example: sudo python colorific.py 5C:31:3E:F2:16:13'
|
||||
print ('Error must specify bulb address as parameter!')
|
||||
print ('Usage: sudo python colorific.py <bulb address>')
|
||||
print ('Example: sudo python colorific.py 5C:31:3E:F2:16:13')
|
||||
sys.exit(1)
|
||||
bulb = sys.argv[1]
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ hue_min, hue_max = HUE_RANGE
|
|||
hue = hue_min
|
||||
|
||||
# Enter main loop.
|
||||
print 'Press Ctrl-C to quit.'
|
||||
print ('Press Ctrl-C to quit.')
|
||||
last = time.time()
|
||||
while True:
|
||||
# Get amount of time elapsed since last update, then compute hue delta.
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ SLEEP_SEC = 0.01 # Amount of time to sleep between loop iterations.
|
|||
|
||||
# Get bulb address from command parameters.
|
||||
if len(sys.argv) != 2:
|
||||
print 'Error must specify bulb address as parameter!'
|
||||
print 'Usage: sudo python colorific.py <bulb address>'
|
||||
print 'Example: sudo python colorific.py 5C:31:3E:F2:16:13'
|
||||
print ('Error must specify bulb address as parameter!')
|
||||
print ('Usage: sudo python colorific.py <bulb address>')
|
||||
print ('Example: sudo python colorific.py 5C:31:3E:F2:16:13')
|
||||
sys.exit(1)
|
||||
bulb = sys.argv[1]
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ hue_min, hue_max = HUE_RANGE
|
|||
hue = hue_min
|
||||
|
||||
# Enter main loop.
|
||||
print 'Press Ctrl-C to quit.'
|
||||
print ('Press Ctrl-C to quit.')
|
||||
last = time.time()
|
||||
while True:
|
||||
# Get amount of time elapsed since last update, then compute hue delta.
|
||||
|
|
@ -64,7 +64,7 @@ while True:
|
|||
# Set light color by sending color change packet over BLE.
|
||||
# 56RRGGBB00f0aa
|
||||
line = 'char-write-cmd 0x002e 56{0:02X}{1:02X}{2:02X}00f0aa'.format(r, g, b)
|
||||
print line
|
||||
print (line)
|
||||
gatt.sendline(line)
|
||||
# Wait a short period of time and setup for the next loop iteration.
|
||||
time.sleep(SLEEP_SEC)
|
||||
|
|
|
|||
|
|
@ -138,16 +138,16 @@ for name in sys.argv[1:]: # For each image passed to script...
|
|||
|
||||
if image.bph > numLEDs: numLEDs = image.bph
|
||||
|
||||
print "// Don't edit this file! It's software-generated."
|
||||
print "// See convert.py script instead."
|
||||
print
|
||||
print "#define PALETTE1 0"
|
||||
print "#define PALETTE4 1"
|
||||
print "#define PALETTE8 2"
|
||||
print "#define TRUECOLOR 3"
|
||||
print
|
||||
print "#define NUM_LEDS %d" % numLEDs
|
||||
print
|
||||
print ("// Don't edit this file! It's software-generated.")
|
||||
print ("// See convert.py script instead.")
|
||||
print()
|
||||
print ("#define PALETTE1 0")
|
||||
print ("#define PALETTE4 1")
|
||||
print ("#define PALETTE8 2")
|
||||
print ("#define TRUECOLOR 3")
|
||||
print()
|
||||
print ("#define NUM_LEDS %d" % numLEDs)
|
||||
print()
|
||||
|
||||
# Second pass estimates current of each column, then peak & overall average
|
||||
|
||||
|
|
@ -221,9 +221,9 @@ for imgNum, image in enumerate(images): # For each image in list...
|
|||
int(pow((lut[i][0]/255.0),gamma)*bR1+0.5),
|
||||
int(pow((lut[i][1]/255.0),gamma)*bG1+0.5),
|
||||
int(pow((lut[i][2]/255.0),gamma)*bB1+0.5)))
|
||||
if i < (image.numColors - 1): print ","
|
||||
print " };"
|
||||
print
|
||||
if i < (image.numColors - 1): print (",")
|
||||
print (" };")
|
||||
print()
|
||||
|
||||
sys.stdout.write(
|
||||
"const uint8_t PROGMEM pixels%02d[] = {" % imgNum)
|
||||
|
|
@ -299,19 +299,19 @@ for imgNum, image in enumerate(images): # For each image in list...
|
|||
writeByte(0)
|
||||
writeByte(0)
|
||||
|
||||
print " };" # end pixels[] array
|
||||
print
|
||||
print (" };") # end pixels[] array
|
||||
print()
|
||||
|
||||
# Last pass, print table of images...
|
||||
|
||||
print "typedef struct {"
|
||||
print " uint8_t type; // PALETTE[1,4,8] or TRUECOLOR"
|
||||
print " line_t lines; // Length of image (in scanlines)"
|
||||
print " const uint8_t *palette; // -> PROGMEM color table (NULL if truecolor)"
|
||||
print " const uint8_t *pixels; // -> Pixel data in PROGMEM"
|
||||
print "} image;"
|
||||
print
|
||||
print "const image PROGMEM images[] = {"
|
||||
print ("typedef struct {")
|
||||
print (" uint8_t type; // PALETTE[1,4,8] or TRUECOLOR")
|
||||
print (" line_t lines; // Length of image (in scanlines")
|
||||
print (" const uint8_t *palette; // -> PROGMEM color table (NULL if truecolor")
|
||||
print (" const uint8_t *pixels; // -> Pixel data in PROGMEM")
|
||||
print ("} image;")
|
||||
print()
|
||||
print ("const image PROGMEM images[] = {")
|
||||
|
||||
for imgNum, image in enumerate(images): # For each image in list...
|
||||
sys.stdout.write(" { ")
|
||||
|
|
@ -338,6 +338,6 @@ for imgNum, image in enumerate(images): # For each image in list...
|
|||
else:
|
||||
print
|
||||
|
||||
print "};"
|
||||
print
|
||||
print "#define NUM_IMAGES (sizeof(images) / sizeof(images[0]))"
|
||||
print ("};")
|
||||
print()
|
||||
print ("#define NUM_IMAGES (sizeof(images) / sizeof(images[0]))")
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ while 1: # Main loop ---------------------------------------------------------
|
|||
|
||||
# Ustream broadcast query
|
||||
try: uOnline = req(uUrl)['results'] == 'live'
|
||||
except Exception, e: print "Error: {0} : {1}".format(type(e), e.args)
|
||||
except Exception as e: print ("Error: {0} : {1}").format(type(e), e.args)
|
||||
|
||||
# G+ hangout query
|
||||
try:
|
||||
|
|
@ -142,10 +142,10 @@ while 1: # Main loop ---------------------------------------------------------
|
|||
while 1:
|
||||
pageToken = paginate(pageToken)
|
||||
if pageToken is None: break
|
||||
except Exception, e: print "Error: {0} : {1}".format(type(e), e.args)
|
||||
except Exception as e: print ("Error: {0} : {1}").format(type(e), e.args)
|
||||
|
||||
print 'G+ hangout: ' + ('online' if gOnline else 'offline')
|
||||
print 'Ustream : ' + ('online' if uOnline else 'offline')
|
||||
print ('G+ hangout: ') + ('online' if gOnline else 'offline')
|
||||
print ('Ustream : ') + ('online' if uOnline else 'offline')
|
||||
GPIO.output(pin, GPIO.HIGH if uOnline or gOnline else GPIO.LOW)
|
||||
|
||||
# Delay before next query
|
||||
|
|
@ -156,7 +156,7 @@ while 1: # Main loop ---------------------------------------------------------
|
|||
i = bisect.bisect(mins, [m, 60]) - 1 # mins[] list index
|
||||
d = mins[i][1] - (n - startTime) # Time to next poll
|
||||
if d > 0:
|
||||
print 'Waiting ' + str(d) + ' seconds'
|
||||
print ('Waiting ') + str(d) + ' seconds'
|
||||
time.sleep(d)
|
||||
except:
|
||||
time.sleep(60)
|
||||
|
|
|
|||
Loading…
Reference in a new issue