27
27
28
28
# CONFIGURATION
29
29
PLAY_SOUND_ON_CHANGE = False
30
- NEOPIXELS_ON_CHANGE = False
30
+ NEOPIXELS_ON_CHANGE = True
31
+ DISPLAY_ATTACHED = False
31
32
TIME_BETWEEN_QUERY = 60 # in seconds
32
33
33
34
# Some data sources and JSON locations to try out
63
64
# "screen_names=adafruit"
64
65
# DATA_LOCATION = [0, "followers_count"]
65
66
66
-
67
- # With a Particle Argon
68
- RX = board .ESP_TX
69
- TX = board .ESP_RX
70
- resetpin = DigitalInOut (board .ESP_WIFI_EN )
71
- rtspin = DigitalInOut (board .ESP_CTS )
72
- uart = busio .UART (TX , RX , timeout = 0.1 )
73
- esp_boot = DigitalInOut (board .ESP_BOOT_MODE )
74
- esp_boot .direction = Direction .OUTPUT
75
- esp_boot .value = True
76
-
67
+ # Debug Level
68
+ # Change the Debug Flag if you have issues with AT commands
69
+ debugflag = False
70
+
71
+ if board .board_id == "challenger_rp2040_wifi" :
72
+ RX = board .ESP_RX
73
+ TX = board .ESP_TX
74
+ resetpin = DigitalInOut (board .WIFI_RESET )
75
+ rtspin = False
76
+ uart = busio .UART (TX , RX , baudrate = 11520 , receiver_buffer_size = 2048 )
77
+ esp_boot = DigitalInOut (board .WIFI_MODE )
78
+ esp_boot .direction = Direction .OUTPUT
79
+ esp_boot .value = True
80
+ status_light = None
81
+ pixel_pin = board .NEOPIXEL
82
+ num_pixels = 1
83
+ pixel_type = "RGBW/GRBW"
84
+ else :
85
+ RX = board .ESP_TX
86
+ TX = board .ESP_RX
87
+ resetpin = DigitalInOut (board .ESP_WIFI_EN )
88
+ rtspin = DigitalInOut (board .ESP_CTS )
89
+ uart = busio .UART (TX , RX , timeout = 0.1 )
90
+ esp_boot = DigitalInOut (board .ESP_BOOT_MODE )
91
+ esp_boot .direction = Direction .OUTPUT
92
+ esp_boot .value = True
93
+ status_light = None
94
+ pixel_pin = board .A1
95
+ num_pixels = 16
96
+ pixel_type = "RGB/GRB"
77
97
78
98
# Create the connection to the co-processor and reset
79
99
esp = adafruit_espatcontrol .ESP_ATcontrol (
82
102
esp .hard_reset ()
83
103
84
104
requests .set_socket (socket , esp )
85
-
86
- # Create the I2C interface.
87
- i2c = busio .I2C (board .SCL , board .SDA )
88
- # Attach a 7 segment display and display -'s so we know its not live yet
89
- display = segments .Seg7x4 (i2c )
90
- display .print ("----" )
105
+ # display
106
+ if DISPLAY_ATTACHED :
107
+ # Create the I2C interface.
108
+ i2c = busio .I2C (board .SCL , board .SDA )
109
+ # Attach a 7 segment display and display -'s so we know its not live yet
110
+ display = segments .Seg7x4 (i2c )
111
+ display .print ("----" )
91
112
92
113
# neopixels
93
114
if NEOPIXELS_ON_CHANGE :
94
- pixels = neopixel .NeoPixel (board .A1 , 16 , brightness = 0.4 , pixel_order = (1 , 0 , 2 , 3 ))
95
- pixels .fill (0 )
115
+ pixels = neopixel .NeoPixel (
116
+ pixel_pin , num_pixels , brightness = 0.4 , pixel_order = (1 , 0 , 2 , 3 )
117
+ )
118
+ pixels .fill (20 )
96
119
97
120
# music!
98
121
if PLAY_SOUND_ON_CHANGE :
@@ -111,15 +134,26 @@ def chime_light():
111
134
"""Light up LEDs and play a tune"""
112
135
if NEOPIXELS_ON_CHANGE :
113
136
for i in range (0 , 100 , 10 ):
114
- pixels .fill ((i , i , i ))
137
+ if pixel_type == "RGB/GRB" :
138
+ pixels .fill ((i , i , i ))
139
+ elif pixel_type == "RGBW/GRBW" :
140
+ pixels .fill ((i , i , i , i ))
141
+ pixels .show ()
142
+ time .sleep (1 )
115
143
if PLAY_SOUND_ON_CHANGE :
116
144
with audioio .AudioOut (board .A0 ) as audio :
117
145
audio .play (wave )
118
146
while audio .playing :
119
147
pass
120
148
if NEOPIXELS_ON_CHANGE :
121
149
for i in range (100 , 0 , - 10 ):
122
- pixels .fill ((i , i , i ))
150
+ for i in range (0 , 100 , 10 ):
151
+ if pixel_type == "RGB/GRB" :
152
+ pixels .fill ((i , i , i ))
153
+ elif pixel_type == "RGBW/GRBW" :
154
+ pixels .fill ((i , i , i , i ))
155
+ pixels .show ()
156
+ time .sleep (1 )
123
157
pixels .fill (0 )
124
158
125
159
@@ -148,8 +182,11 @@ def chime_light():
148
182
value = value [x ]
149
183
if not value :
150
184
continue
151
- print (times , the_time , "value:" , value )
152
- display .print (int (value ))
185
+ print ("Times:{0}. The Time:{1}. Value: {2}" .format (times , the_time , value ))
186
+ if DISPLAY_ATTACHED :
187
+ display .print (int (value ))
188
+ else :
189
+ print ("INT Value:{0}" .format (int (value )))
153
190
154
191
if last_value != value :
155
192
chime_light () # animate the neopixels
@@ -159,5 +196,7 @@ def chime_light():
159
196
# normally we wouldn't have to do this, but we get bad fragments
160
197
r = value = None
161
198
gc .collect ()
162
- print (gc .mem_free ()) # pylint: disable=no-member
199
+ print ("GC MEM:{0}" .format (gc .mem_free ())) # pylint: disable=no-member
200
+ print ("Sleeping for: {0} Seconds" .format (TIME_BETWEEN_QUERY ))
163
201
time .sleep (TIME_BETWEEN_QUERY )
202
+
0 commit comments