本文整理汇总了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
示例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