-
Notifications
You must be signed in to change notification settings - Fork 1
/
neopixels.py
77 lines (57 loc) · 1.97 KB
/
neopixels.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""
Copyright (c) 2021 Alan Yorinks All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
Version 3 as published by the Free Software Foundation; either
or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""
import time
import sys
from telemetrix_rpi_pico_w import telemetrix_rpi_pico_w
"""
Demo using an 8 LED NeoPixel strip
"""
def neopixel_demo(my_board):
"""
Run
:param my_board: Pico board instance
"""
# enable neopixel support on the Pico pin 0
my_board.set_pin_mode_neopixel(pin_number=0)
# set some values and the show them
my_board.neo_pixel_set_value(5, 255, 0, 0)
my_board.neo_pixel_set_value(1, 0, 64, 0)
my_board.neo_pixel_set_value(7, 0, 0, 64)
my_board.neopixel_show()
time.sleep(1)
# clear the NeoPixels
my_board.neopixel_clear()
time.sleep(1)
# fill the NeoPixels
my_board.neopixel_fill(50, 0, 120)
time.sleep(1)
# set pixel value and update immediately
my_board.neo_pixel_set_value(3, 0, 65, 64, True)
time.sleep(1)
my_board.neopixel_clear()
# pixel sequence
while True:
for pixel in range(8):
my_board.neo_pixel_set_value(pixel, 0, 0, 64, True)
time.sleep(.1)
my_board.neopixel_clear()
board = telemetrix_rpi_pico_w.TelemetrixRpiPicoW(ip_address='192.168.2.102')
try:
neopixel_demo(board)
board.shutdown()
except KeyboardInterrupt:
board.neopixel_clear()
board.shutdown()
sys.exit(0)