本文整理汇总了Python中unicornhat.show函数的典型用法代码示例。如果您正苦于以下问题:Python show函数的具体用法?Python show怎么用?Python show使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了show函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: option_1
def option_1():###User enters a sentance to create the light show###
phrase = raw_input("Please enter your phrase ").lower()
###Checks the letters in the phrase, then works out the co- ordinates###
for letter in phrase:
index = ord(letter)-65
#print index ### remove when complete###
if index > 0:
x = int(index/8.0)
#print x ### remove when complete###
x = x - 4
y = int(index%8)
#print (x, y)
UH.clear
UH.brightness(0.20)
UH.set_pixel(y, x, 255, 255, 255)
#UH.set_pixel(x, y, 0, 255, 0)
UH.show()
time.sleep(0.5)
UH.clear()
elif index <= 0:
random_sparkle()
示例2: draw_dot
def draw_dot( x1, y1, r1, g1, b1, str1):
"This draws the dot and outputs some text"
UH.set_pixel(x1,y1,r1,g1,b1)
UH.show()
# print (str1 + str(x1) + ' ' + str(y1))
time.sleep(0.1)
return
示例3: drawTile
def drawTile(y, x, value):
rgb=colour[(index[value])]
unicorn.set_pixel((x*2),(y*2),rgb[0],rgb[1],rgb[2])
unicorn.set_pixel((x*2)+1,(y*2),rgb[0],rgb[1],rgb[2])
unicorn.set_pixel((x*2),(y*2)+1,rgb[0],rgb[1],rgb[2])
unicorn.set_pixel((x*2)+1,(y*2)+1,rgb[0],rgb[1],rgb[2])
unicorn.show()
示例4: clearsystem
def clearsystem():
led.clear()
led.rotation(0)
os.system("arp -d *")
os.system("ip neigh flush all")
led.show()
return;
示例5: main
def main():
while True:
led.clear()
led.show()
timestamp = datetime.datetime.now().time()
if (os.system("ping -c " + p + " 192.168.111.25")) == 0:
if starttime <= timestamp <= endtime:
clearsystem()
if (os.system("ping -c " + p + " " + hosts[1])) == 0:
led_reset()
led_piping()
else:
led_reset()
led_router()
else:
if (os.system("ping -c " + p + " " + hosts[8])) == 0:
led.clear()
sshconnect(hosts[8], "base64-password", "poweroff")
led_poweroff(hosts[8])
led_reset()
if (os.system("ping -c " + p + " " + hosts[10])) == 0:
led.clear()
sshconnect(hosts[10], "base64-password", "poweroff")
led_poweroff(hosts[10])
led_reset()
continue
else:
led_arrow()
continue
示例6: paint
def paint():
global last_members
index = 0
members = r.find_members()
if(len(last_members) != len(members)):
UH.clear()
UH.show()
last_members = members
for member in members:
temp = r.get_key(member + ".temp")
baseline = r.get_key(member + ".temp.baseline")
motion = r.get_key(member + ".motion")
if safeFloat(motion) > 0:
if(quiet == False):
print("moved")
on(index, 0, 0, 255)
elif is_hot(temp, baseline):
on(index, 255, 0, 0)
if(quiet == False):
print("HOT")
else:
on(index, 0, 255, 0)
index = index +1
示例7: draw_heart
def draw_heart(hue, brightness):
for x, y in pixels_to_light:
color = colorsys.hsv_to_rgb(hue, 1, brightness)
color = [int(c * 255) for c in color]
r, g, b = color
unicorn.set_pixel(x, y, r, g, b)
unicorn.show()
示例8: fill
def fill(r=0,g=255,b=0):
for x in range(8):
for y in range(8):
unicorn.set_pixel(8-x-1, 8-y-1, r, g, b)
unicorn.show()
time.sleep(0.05)
time.sleep(2)
示例9: display_matrix
def display_matrix(max_x, max_y, text=False, r=255, g=255, b=255):
"""
Display the matrix, either on the unicorn or on the stdout
:param max_x:
:param max_y:
:param text: If True, display on stdout instead of unicornhat. For debugging
"""
if text:
for x in range(max_x):
for y in range(max_y):
coordinate_tuple = (x, y)
if LifeCell.matrix[coordinate_tuple].current_state == 'alive':
print '*',
else:
print '.',
print
print
else:
for x in range(max_x):
for y in range(max_y):
coordinate_tuple = (x, y)
if LifeCell.matrix[coordinate_tuple].current_state == 'alive':
unicorn.set_pixel(x, y, r, g, b)
else:
unicorn.set_pixel(x, y, 0, 0, 0)
unicorn.show()
示例10: drawpet
def drawpet(pet):
for y in range(8):
for x in range(8):
#set pixel with color
r, g, b = pet[y][x]
unicorn.set_pixel(x,y,r,g,b)
unicorn.show()
示例11: __init__
def __init__(self):
self._logger = logging.getLogger(self.__class__.__name__)
self._current_value = self.BLUE
UH.brightness(1.0)
pixels = self._set_whole_grid(self._current_value)
UH.set_pixels(pixels)
UH.show()
示例12: writePixel
def writePixel(pixel):
#try:
#GPIO.setup(int(pin), GPIO.IN)
#if GPIO.input(int(pin)) == True:
# response = "Pin number " + pin + " is high!"
#else:
# response = "Pin number " + pin + " is low!"
#except:
#response = "There was an error reading pin " + pin + "."
color = int(pixel)
for i in range(0,8):
UH.set_pixel(0,i,color,color,color)
UH.show()
response="All correct"
now = datetime.datetime.now()
timeString = now.strftime("%Y-%m-%d %H:%M")
templateData = {
'title' : 'Status of Pixel' + str(pixel),
'time': timeString,
'response' : response
}
return render_template('main.html', **templateData)
示例13: go
def go():
unicorn.brightness(1)
unicorn.rotation(90)
wrd_rgb = [[154, 173, 154], [0, 255, 0], [0, 200, 0], [0, 162, 0], [0, 145, 0], [0, 96, 0], [0, 74, 0], [0, 0, 0,]]
clock = 0
blue_pilled_population = [[randint(0,7), 7]]
t_end = time.time() + 10
while time.time() < t_end:
for person in blue_pilled_population:
y = person[1]
for rgb in wrd_rgb:
if (y <= 7) and (y >= 0):
unicorn.set_pixel(person[0], y, rgb[0], rgb[1], rgb[2])
y += 1
person[1] -= 1
unicorn.show()
time.sleep(0.1)
clock += 1
if clock % 5 == 0:
blue_pilled_population.append([randint(0,7), 7])
if clock % 7 == 0:
blue_pilled_population.append([randint(0,7), 7])
while len(blue_pilled_population) > 100:
blue_pilled_population.pop(0)
示例14: option_2
def option_2():###Select a website to create the light show
your_webiste_choice = raw_input("Please enter the web address")
final_address = "http://%s" %(your_webiste_choice)
print "finding", final_address
website = urllib2.urlopen(final_address )
##print website.read()
sentence = website.read()
print sentence
###Checks the letters in the website, then works out the co- ordinates###
for letter in sentence:
index = ord(letter)-65
#print index ### remove when complete###
if index > 0:
x = int(index/8.0)
#print x ### remove when complete###
#x = x - 4
y = int(index%8)
#print (x, y)
UH.clear
UH.brightness(0.2)
UH.set_pixel(y, x, 0, 255, 0)
UH.set_pixel(x, y, 0, 255, 0)
UH.show()
time.sleep(0.02)
UH.clear()
elif index <= 0:
random_sparkle()
示例15: load_rainbow
def load_rainbow(update_rate=5):
""" A lightly modified version of Pimeroni's "rainbow" example.
Displays a moving rainbow of colors that increases with load.
Args:
update_rate (float): How often to update the load value (seconds).
"""
i = 0.0
offset = 30
function_values[load_fetcher] = 1
threading.Thread(target=load_fetcher).start()
while True:
load_function = function_values[load_fetcher]/10 if function_values[load_fetcher] <= 10 else 10
for w in range(int(update_rate/0.01)):
i = i + load_function
for y in range(height):
for x in range(function_pos[load_rainbow] + 1):
r = 0#x * 32
g = 0#y * 32
xy = x + y / 4
r = (math.cos((x+i)/2.0) + math.cos((y+i)/2.0)) * 64.0 + 128.0
g = (math.sin((x+i)/1.5) + math.sin((y+i)/2.0)) * 64.0 + 128.0
b = (math.sin((x+i)/2.0) + math.cos((y+i)/1.5)) * 64.0 + 128.0
r = max(0, min(255, r + offset))
g = max(0, min(255, g + offset))
b = max(0, min(255, b + offset))
unicorn.set_pixel(x,y,int(r),int(g),int(b))
unicorn.show()
time.sleep(0.01)