本文整理汇总了Python中sense_hat.SenseHat.get_pixels方法的典型用法代码示例。如果您正苦于以下问题:Python SenseHat.get_pixels方法的具体用法?Python SenseHat.get_pixels怎么用?Python SenseHat.get_pixels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sense_hat.SenseHat
的用法示例。
在下文中一共展示了SenseHat.get_pixels方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pixels [as 别名]
def main():
sense = SenseHat()
sense.low_light = True
print( "<---- SinusGraph ---->\n" )
pixelStatuses = [ [ 0, 0, 0 ] for i in range( 64 ) ]
for i in range( 150 ):
assert len( pixelStatuses ) == 64
del pixelStatuses[ : 8 ]
pixelStatuses.extend( [ [ 0, 0, 0 ] for i in range( 8 ) ] )
pixelStatuses[ 60 + round( cos( i / 1.5 ) * 3 ) ] = [ 0, 255, 0 ]
pixelStatuses[ 60 + round( sin( i / 2 ) * 3 ) ] = [ 255, 255, 255 ]
sense.set_pixels( pixelStatuses )
pixelStatuses = sense.get_pixels()
print( pixelStatuses )
sleep( 0.096 )
sense.clear()
示例2: main
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pixels [as 别名]
def main():
sense = SenseHat()
"""
sense.show_message("Hello World!!");
sense.set_rotation(180)
sense.show_message("Hello World!!");
"""
sense.flip_v()
list = sense.get_pixels()
#print list
sense.set_pixel(0,0,255,0,0)
sense.clear()
for i in range(0, 5):
sense.show_letter(str(i))
time.sleep(1)
sense.clear()
示例3: fade
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pixels [as 别名]
def fade( pixel ):
new_pixel=[]
for comp in pixel:
if comp>0:
new_pixel.append( comp-1)
else:
new_pixel.append( 0 )
return new_pixel
while True:
rx=random.randint(0,3)
ry=random.randint(0,3)
if random.randint(0,100) < 25:
col=[ random.randint(0,255),
random.randint(0,255),
random.randint(0,255)
]
if sense.get_pixel(rx,ry)==[0,0,0]:
sense.set_pixel(rx, ry, col)
sense.set_pixel(7-rx, ry, col)
sense.set_pixel(7-rx, 7-ry, col)
sense.set_pixel(rx, 7-ry, col)
pixels=sense.get_pixels()
new_pixels=[]
for p in pixels:
new_pixels.append( fade( p ) )
sense.set_pixels( new_pixels )
#sleep(0.1)
示例4: SenseHat
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pixels [as 别名]
import time
import sys
import os
import base64
import StringIO
from PIL import Image # pillow
from sense_hat import SenseHat
sense = SenseHat()
sense.low_light = True
try:
data = sys.argv[1]
except IndexError:
display_pixels = sense.get_pixels()
img = Image.new("RGB", (8, 8), "black")
pixels = img.load()
## Set pixels ...
idx = 0
for i in range(8):
for j in range(8):
pixels[i, j] = tuple(display_pixels[idx])
idx += 1
img = img.rotate(-90)
output = StringIO.StringIO()
img.save(output, format="PNG")
print base64.b64encode(output.getvalue())
sys.exit(0)
if os.path.exists(sys.argv[1]):