本文整理匯總了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