本文整理汇总了Python中unicornhat.rotation函数的典型用法代码示例。如果您正苦于以下问题:Python rotation函数的具体用法?Python rotation怎么用?Python rotation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rotation函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_letter
def show_letter(letter,colour,brightness): #displays a single letter on th UH
UH.rotation(_scrollrotation)
for i in range(8):
for j in range(8):
if letter[j][i]:
if colour == 'red':
UH.set_pixel(j,flip[i],brightness,0,0)
elif colour == 'green':
UH.set_pixel(j,flip[i],0,brightness,0)
elif colour == 'blue':
UH.set_pixel(j,flip[i],0,0,brightness)
elif colour == 'white':
UH.set_pixel(j,flip[i],brightness,brightness,brightness)
elif colour == 'pink':
UH.set_pixel(j,flip[i],brightness,52,179)
elif colour == 'cyan':
UH.set_pixel(j,flip[i],0,brightness,brightness)
elif colour == 'yellow':
UH.set_pixel(j,flip[i],brightness,brightness,0)
elif colour == 'orange':
UH.set_pixel(j,flip[i],brightness,128,0)
else:
UH.set_pixel(j,flip[i],0,0,0)
UH.show()
示例2: 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)
示例3: message
def message(message):
unicorn.rotation(270)
for _ in range(2):
unicorn_scroll(message,'white',255,0.1)
unicorn.clear()
unicorn.show()
return "ok"
示例4: clearsystem
def clearsystem():
led.clear()
led.rotation(0)
os.system("arp -d *")
os.system("ip neigh flush all")
led.show()
return;
示例5: icon
def icon(icon):
unicorn.rotation(270)
for _ in range(5):
playIcon(icon)
unicorn.clear()
unicorn.show()
return "ok"
示例6: rotate
def rotate(): #Rotates image on AstroPi LED matrix
global rotation
if rotation == 270:
rotation = 0
else:
rotation = rotation + 90
#ap.set_rotation(rotation)
uh.rotation(rotation)
示例7: show_letter_rgb
def show_letter_rgb(letter,r,g,b): #displays a single letter on th UH
UH.rotation(270)
for i in range(8):
for j in range(8):
if letter[j][i]:
UH.set_pixel(j,flip[i],r,g,b)
else:
UH.set_pixel(j,flip[i],0,0,0)
UH.show()
示例8: range
import unicornhat as UH
import time
import random
if __name__=='__main__':
UH.brightness(0.01)
UH.rotation(90)
r = range(0,8)
while True:
for x in r:
y = random.choice(r)
for fill in range(0, y):
UH.set_pixel(x,fill,255,0,255)
UH.show()
time.sleep(0.05)
UH.clear()
UH.show()
time.sleep(0.05)
示例9: row
's': [0x00, 0x00, 0x38, 0x40, 0x38, 0x04, 0x78, 0x00],
't': [0x00, 0x10, 0x38, 0x10, 0x10, 0x10, 0x0c, 0x00],
'u': [0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00],
'v': [0x00, 0x00, 0x44, 0x44, 0x28, 0x28, 0x10, 0x00],
'w': [0x00, 0x00, 0x44, 0x54, 0x54, 0x54, 0x28, 0x00],
'x': [0x00, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00],
'y': [0x00, 0x00, 0x44, 0x44, 0x44, 0x3c, 0x04, 0x38],
'z': [0x00, 0x00, 0x7c, 0x08, 0x10, 0x20, 0x7c, 0x00],
'{': [0x00, 0x0e, 0x08, 0x30, 0x08, 0x08, 0x0e, 0x00],
'|': [0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00],
'}': [0x00, 0x70, 0x10, 0x0c, 0x10, 0x10, 0x70, 0x00],
'~': [0x00, 0x14, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00],
'©': [0x3c, 0x42, 0x99, 0xa1, 0xa1, 0x99, 0x42, 0x3c]
}
unihat.rotation(180);
# a virtual framebuffer, which we'll copy to the unicorn hat.
# we're using a framebuffer of 24x8 pixels, which equates to eight rows of three bytes.
# we will only draw byte 1 of each row (row is byte 0, 1, 2) so that we use byte 0 and 2
# as "offscreen" drawing area. this gives us left/right shiftable screen area.
vfb = [
[0x00, 0x00, 0x00],
[0x00, 0x00, 0x00],
[0x00, 0x00, 0x00],
[0x00, 0x00, 0x00],
[0x00, 0x00, 0x00],
[0x00, 0x00, 0x00],
[0x00, 0x00, 0x00],
[0x00, 0x00, 0x00]
];
示例10: Buffer
import itertools
from twitterpibot.hardware.myhardware import is_linux
from twitterpibot.hardware.unicorn.canvas import Buffer
from twitterpibot.hardware.unicorn.myunicornhatmodes import *
if is_linux:
import unicornhat
unicornhat.rotation(270)
else:
from twitterpibot.hardware.unicorn import unicornhat_viz as unicornhat
_buffer = Buffer(8, 8)
# TODO unicorn hat patterns
# Sin Wave
# Swipes
# graphic equalizer
# starfield
# bouncing ball/line
# snake
# game of life
# battleships
# chess/draughts
# strobe
# lifts?
示例11: set_rotation
def set_rotation(self,rotation):
unicornhat.rotation(rotation)
示例12:
print 'The market is up', numfloat, 'percent.'
print ""
#optional delay
#time.sleep(2)
#unicorn hat matrix color change based on market direction
import unicornhat as unicorn
from random import randint
import time
#tie LED brightness to change magnitude here
unicorn.brightness(0.30)
unicorn.rotation(90)
#colors if market is up, down,or zero change
if numfloat > 0:
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,]]
elif numfloat == 0:
wrd_rgb = [[255, 20, 20], [245, 10, 10], [200, 0, 10], [162, 0, 0], [145, 0, 0], [96, 0, 0], [74, 0, 0], [0, 0, 0,]]
else: #maybe change this to rainbow sparkles
wrd_rgb = [[255, 255, 154], [255, 255, 0], [255, 255, 0], [255, 255, 0], [255, 255, 0], [255, 255, 0], [255, 255, 0], [255, 255, 0,]]
clock = 0
blue_pilled_population = [[randint(0,7), 7]]
#while True:
timeout_start = time.time()
示例13: randrange
#!/usr/bin/env python3
import unicornhat as uh
import time
from random import randrange
uh.brightness(0.1)
uh.rotation(270)
while True:
r = randrange(200, 255, 1)
b = randrange(0, 200, 1)
x = (r, 0, b)
o = (0, 0, 0)
heart = [
[o, o, o, o, o, o, o, o],
[o, x, x, o, o, x, x, o],
[x, x, x, x, x, x, x, x],
[x, x, x, x, x, x, x, x],
[o, x, x, x, x, x, x, o],
[o, o, x, x, x, x, o, o],
[o, o, o, x, x, o, o, o],
[o, o, o, o, o, o, o, o],
]
uh.set_pixels(heart)
uh.show()
time.sleep(0.5)
示例14: line
#!/usr/bin/python3
# my own attempt at displaying a clock. WIP
import unicornhat as u
import time, math
u.rotation(180)
u.brightness(0.5)
def line(x1, y1, x2, y2, color=(255, 255, 255)):
x1 = int(x1)
y1 = int(y1)
x2 = int(x2)
y2 = int(y2)
dx = abs(x2 - x1)
dy = abs(y2 - y1)
sx = 1 if x1 < x2 else -1
sy = 1 if y1 < y2 else -1
err = dx - dy
u.set_pixel(x1, y1, *color)
while x1 != x2 or y1 != y2:
e = 2 * err
if e > -dy:
err -= dy
x1 += sx
if e < dx:
err += dx
y1 += sy
u.set_pixel(x1, y1, *color)
示例15: make_gaussian
#!/usr/bin/env python
import unicornhat as unicorn
import time, colorsys
import numpy as np
unicorn.set_layout(unicorn.AUTO)
unicorn.rotation(0) # tested on pHAT/HAT with rotation 0, 90, 180 & 270
unicorn.brightness(0.4)
width,height=unicorn.get_shape()
if height==width:
delta=0
else:
delta=2
def make_gaussian(fwhm):
x = np.arange(0, 8, 1, float)
y = x[:, np.newaxis]
x0, y0 = 3.5, 3.5
fwhm = fwhm
gauss = np.exp(-4 * np.log(2) * ((x - x0) ** 2 + (y - y0) ** 2) / fwhm ** 2)
return gauss
while True:
for z in list(range(1, 10)[::-1]) + list(range(1, 10)):
fwhm = 5.0/z
gauss = make_gaussian(fwhm)
start = time.time()
for y in range(height):