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


Python Adafruit_DotStar.numPixels方法代码示例

本文整理汇总了Python中dotstar.Adafruit_DotStar.numPixels方法的典型用法代码示例。如果您正苦于以下问题:Python Adafruit_DotStar.numPixels方法的具体用法?Python Adafruit_DotStar.numPixels怎么用?Python Adafruit_DotStar.numPixels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dotstar.Adafruit_DotStar的用法示例。


在下文中一共展示了Adafruit_DotStar.numPixels方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Adafruit_DotStar

# 需要导入模块: from dotstar import Adafruit_DotStar [as 别名]
# 或者: from dotstar.Adafruit_DotStar import numPixels [as 别名]
# Here's how to control the strip from any two GPIO pins:
datapin = 23
clockpin = 24
strip = Adafruit_DotStar(numpixels, datapin, clockpin)

strip.begin()  # Initialize pins for output

# Load image in RGB format and get dimensions:
print "Loading..."
img = Image.open(filename).convert("RGB")
pixels = img.load()
width = img.size[0]
height = img.size[1]
print "%dx%d pixels" % img.size

if height > strip.numPixels():
    height = strip.numPixels()

# Calculate gamma correction table, makes mid-range colors look 'right':
gamma = bytearray(256)
for i in range(256):
    gamma[i] = int(pow(float(i) / 255.0, 2.7) * 255.0 + 0.5)

print "Displaying..."
while True:  # Loop forever

    for x in range(width):  # For each column of image...
        for y in range(height):  # For each pixel in column...
            value = pixels[x, y]  # Read pixel in image
            strip.setPixelColor(
                y,  # Set pixel in strip
开发者ID:matthiasplappert,项目名称:lego-elevator,代码行数:33,代码来源:image-paint.py

示例2: Adafruit_DotStar

# 需要导入模块: from dotstar import Adafruit_DotStar [as 别名]
# 或者: from dotstar.Adafruit_DotStar import numPixels [as 别名]
# Here's how to control the strip from any two GPIO pins:
datapin   = 3
clockpin  = 4
strip     = Adafruit_DotStar(numpixels, datapin, clockpin)

strip.begin()           # Initialize pins for output

# Load image in RGB format and get dimensions:
print "Loading..."
img       = Image.open(filename).convert("RGB")
pixels    = img.load()
width     = img.size[0]
height    = img.size[1]
print "%dx%d pixels" % img.size

if(height > strip.numPixels()): height = strip.numPixels()

# Calculate gamma correction table, makes mid-range colors look 'right':
gamma = bytearray(256)
for i in range(256):
	gamma[i] = int(pow(float(i) / 255.0, 2.7) * 255.0 + 0.5)

print "Displaying..."
while True:                              # Loop forever

	for x in range(width):           # For each column of image...
		for y in range(height):  # For each pixel in column...
			value = pixels[x, y]   # Read pixel in image
			strip.setPixelColor(y, # Set pixel in strip
			  gamma[value[0]],     # Gamma-corrected red
			  gamma[value[1]],     # Gamma-corrected green
开发者ID:docprofsky,项目名称:Adafruit_DotStar_Pi,代码行数:33,代码来源:image-paint.py


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