本文整理汇总了Python中piglow.PiGlow.colour方法的典型用法代码示例。如果您正苦于以下问题:Python PiGlow.colour方法的具体用法?Python PiGlow.colour怎么用?Python PiGlow.colour使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类piglow.PiGlow
的用法示例。
在下文中一共展示了PiGlow.colour方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: light_piglow
# 需要导入模块: from piglow import PiGlow [as 别名]
# 或者: from piglow.PiGlow import colour [as 别名]
def light_piglow(colour,rotations):
colourmap = {14 : "red", 13 : "green", 11 : "blue", 1: "orange", 4 : "yellow", 15 : "white" }
from piglow import PiGlow
piglow = PiGlow()
# piglow.all(0)
if ( colour != "all" ):
ledcolour = colourmap[colour]
for j in range(rotations):
piglow.colour(ledcolour,j)
sleep(0.001*j) # As the intensity increases, sleep for longer periods
else:
# print ("Trying to run all ")
for j in range(rotations):
for colour in (colourmap.values()):
piglow.colour(("%s" % colour), 255)
sleep(0.2)
piglow.colour(colour, 0)
sleep(0.01)
piglow.all(0)
示例2: PiGlow
# 需要导入模块: from piglow import PiGlow [as 别名]
# 或者: from piglow.PiGlow import colour [as 别名]
from piglow import PiGlow
from time import sleep
import psutil
piglow = PiGlow()
# start at white
colour = 1
while True:
# returns a value from 0 - 1 representing current CPU load
cpu = psutil.cpu_percent()
# now we need to scale that CPU level to the range 0 - 255 for PiGlow brightness
brightness = max( (int)(cpu * 255), 1)
# pick a speed that gets faster as the CPU usage increases
speed = max ( 1.2 - cpu, 0.1 )
# turn everything off, let's get ready to rumble
piglow.all(0)
# turn on the next "ring" of colour
piglow.colour(colour, brightness)
# sleep for a bit, i'm weary...
sleep(speed)
# increment to the next colour (reset to white if we're already on red)
colour = colour + 1 if colour < 6 else 1
示例3: PiGlow
# 需要导入模块: from piglow import PiGlow [as 别名]
# 或者: from piglow.PiGlow import colour [as 别名]
#!/usr/bin/env python
from piglow import PiGlow
import time
import random
i = 0
j = 1
k = 2
piglow = PiGlow()
piglow.all(0)
goingUp = 1
while True:
time.sleep(.03)
if goingUp == 1:
piglow.colour(j, i)
i+=5
else:
piglow.colour(j, i)
i-=5
if i == 255:
goingUp = 0
if i == 0:
piglow.colour(j, i)
goingUp = 1
j = random.randint(1,6)
示例4: len
# 需要导入模块: from piglow import PiGlow [as 别名]
# 或者: from piglow.PiGlow import colour [as 别名]
ltcbuypad = len(str(ltcjson["ticker"]["buy"]))
ltcsellpad = len(str(ltcjson["ticker"]["sell"]))
stdscr.addstr(8,16+buypad," ")
stdscr.addstr(8,35+sellpad," ")
stdscr.addstr(10,16+ltcbuypad," ")
stdscr.addstr(10,35+ltcsellpad," ")
stdscr.addstr(8,16,str(btcejson["ticker"]["buy"]))
stdscr.addstr(8,35,str(btcejson["ticker"]["sell"]))
stdscr.addstr(10,16,str(ltcjson["ticker"]["buy"]))
stdscr.addstr(10,35,str(ltcjson["ticker"]["sell"]))
stdscr.refresh()
if float(list["DEVS"][0]["MHS 5s"]) / 1000 >= 7.7 and float(list["DEVS"][0]["MHS 5s"]) / 1000 < 7.8:
piglow.colour(color[0],10)
piglow.colour(color[1],0)
piglow.colour(color[2],0)
piglow.colour(color[3],0)
piglow.colour(color[4],0)
piglow.colour(color[5],0)
elif float(list["DEVS"][0]["MHS 5s"]) / 1000 >= 7.8 and float(list["DEVS"][0]["MHS 5s"]) / 1000 < 7.9:
piglow.colour(color[0],10)
piglow.colour(color[1],10)
piglow.colour(color[2],0)
piglow.colour(color[3],0)
piglow.colour(color[4],0)
piglow.colour(color[5],0)
elif float(list["DEVS"][0]["MHS 5s"]) / 1000 >= 7.9 and float(list["DEVS"][0]["MHS 5s"]) / 1000 < 8.0:
piglow.colour(color[0],10)
piglow.colour(color[1],10)