本文整理汇总了Python中board.D18属性的典型用法代码示例。如果您正苦于以下问题:Python board.D18属性的具体用法?Python board.D18怎么用?Python board.D18使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类board
的用法示例。
在下文中一共展示了board.D18属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sin_cos_graph
# 需要导入模块: import board [as 别名]
# 或者: from board import D18 [as 别名]
def sin_cos_graph(pixels, pin, func, back_color, front_color):
if pin != board.D18:
print('Eyes do not support talk command!')
return
if func != math.sin and func != math.cos:
print('Only sin() and cos() are supported!')
return
pixels.fill(back_color)
t = 0
for x in range(0, 6):
y = func(t)
j = x
if y >= -1 and y < -0.33:
i = 0
elif y >= -0.33 and y < 0.33:
i = 1
j = revert_row1[x]
else:
i = 2
c = i * 6 + j
pixels[c] = front_color
t += 1.57
pixels.show()
示例2: __init__
# 需要导入模块: import board [as 别名]
# 或者: from board import D18 [as 别名]
def __init__(self):
self.PORT = board.D18
self.NUM = 15
self.NUMBASE = 5
self.pixels = neopixel.NeoPixel(self.PORT, self.NUM)
self.cols = [
(255, 0, 0),
(255, 63, 0),
(255, 120, 0),
(0, 255, 0),
(0, 255, 255),
(0, 0, 255),
(255, 0, 255)
]
self.col_neutral = (80, 80, 30)
self.NUMCOLS = len(self.cols)
self.mode = 1
self.ORDER = neopixel.GRB
self.num_pixels = self.NUM
self.pixels.fill(self.col_neutral)
self.drinkcolor = (0,0,0)
self.thr = threading.Thread(target=self.mode3, args=())
self.thr.start()
示例3: __init__
# 需要导入模块: import board [as 别名]
# 或者: from board import D18 [as 别名]
def __init__(self):
self.PORT = board.D18
self.NUM = 15
self.NUMBASE = 5
self.pixels = neopixel.NeoPixel(self.PORT, self.NUM)
self.cols = [
(255, 0, 0),
(255, 63, 0),
(255, 120, 0),
(0, 255, 0),
(0, 255, 255),
(0, 0, 255),
(255, 0, 255)
]
self.col_neutral = (80, 80, 30)
self.NUMCOLS = len(self.cols)
self.mode = 1
self.ORDER = neopixel.GRB
self.num_pixels = self.NUM
self.pixels.fill(self.col_neutral)
self.drinkcolor = (0,0,0)
示例4: led_on
# 需要导入模块: import board [as 别名]
# 或者: from board import D18 [as 别名]
def led_on(pin):
if pin == 1:
pixels = neopixel.NeoPixel(board.D12, 20)
elif pin == 2:
pixels = neopixel.NeoPixel(board.D18, 20)
else:
print("wrong id")
return False
pixels.fill((255, 255, 255))
return True
示例5: led_off
# 需要导入模块: import board [as 别名]
# 或者: from board import D18 [as 别名]
def led_off(pin):
if pin == 1:
pixels = neopixel.NeoPixel(board.D12, 20)
elif pin == 2:
pixels = neopixel.NeoPixel(board.D18, 20)
else:
return False
pixels.fill((0, 0, 0))
return True
示例6: led_color
# 需要导入模块: import board [as 别名]
# 或者: from board import D18 [as 别名]
def led_color(pin, R=255,G=255,B=255):
if pin == 1:
pixels = neopixel.NeoPixel(board.D12, 20)
elif pin == 2:
pixels = neopixel.NeoPixel(board.D18, 20)
else:
return False
pixels.fill((R, G, B))
return True
示例7: talk
# 需要导入模块: import board [as 别名]
# 或者: from board import D18 [as 别名]
def talk(pixels, pin, mode):
if pin != board.D18:
print('Eyes do not support talk command!')
return
if mode == 'plugged_in':
back_color = darkorange
front_color = blue
period = 0.1
else:
back_color = no_color
front_color = default_color
period = 0.25
t = 0
while t < 30: # maximum answer length to prevent infinite loop
pixels.fill(back_color)
for i in range(6, 12):
pixels[i] = front_color
pixels.show()
time.sleep(period)
sin_cos_graph(pixels, pin, math.cos, back_color, front_color)
time.sleep(period)
pixels.fill(back_color)
for i in range(6, 12):
pixels[i] = front_color
pixels.show()
time.sleep(period)
sin_cos_graph(pixels, pin, math.sin, back_color, front_color)
time.sleep(period)
t += period * 4