当前位置: 首页>>代码示例>>Python>>正文


Python SenseHat.get_pixels方法代码示例

本文整理汇总了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()
开发者ID:markuspg,项目名称:SenseHatStuff,代码行数:18,代码来源:sinusGraph.py

示例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()	
开发者ID:MagorokuYohei,项目名称:hoby,代码行数:19,代码来源:led.py

示例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)
开发者ID:midijohnny,项目名称:sensehat,代码行数:31,代码来源:kaleidoscope.py

示例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]):
开发者ID:planet-work,项目名称:robotsapin,代码行数:32,代码来源:display_image.py


注:本文中的sense_hat.SenseHat.get_pixels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。