2727
2828# CONFIGURATION
2929PLAY_SOUND_ON_CHANGE = False
30- NEOPIXELS_ON_CHANGE = False
30+ NEOPIXELS_ON_CHANGE = True
31+ DISPLAY_ATTACHED = False
3132TIME_BETWEEN_QUERY = 60 # in seconds
3233
3334# Some data sources and JSON locations to try out
6364# "screen_names=adafruit"
6465# DATA_LOCATION = [0, "followers_count"]
6566
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"
7797
7898# Create the connection to the co-processor and reset
7999esp = adafruit_espatcontrol .ESP_ATcontrol (
82102esp .hard_reset ()
83103
84104requests .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 ("----" )
91112
92113# neopixels
93114if 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 )
96119
97120# music!
98121if PLAY_SOUND_ON_CHANGE :
@@ -111,15 +134,25 @@ def chime_light():
111134 """Light up LEDs and play a tune"""
112135 if NEOPIXELS_ON_CHANGE :
113136 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 )
115143 if PLAY_SOUND_ON_CHANGE :
116144 with audioio .AudioOut (board .A0 ) as audio :
117145 audio .play (wave )
118146 while audio .playing :
119147 pass
120148 if NEOPIXELS_ON_CHANGE :
121149 for i in range (100 , 0 , - 10 ):
122- pixels .fill ((i , i , i ))
150+ if pixel_type == "RGB/GRB" :
151+ pixels .fill ((i , i , i ))
152+ elif pixel_type == "RGBW/GRBW" :
153+ pixels .fill ((i , i , i , i ))
154+ pixels .show ()
155+ time .sleep (1 )
123156 pixels .fill (0 )
124157
125158
@@ -148,8 +181,11 @@ def chime_light():
148181 value = value [x ]
149182 if not value :
150183 continue
151- print (times , the_time , "value:" , value )
152- display .print (int (value ))
184+ print ("Times:{0}. The Time:{1}. Value: {2}" .format (times , the_time , value ))
185+ if DISPLAY_ATTACHED :
186+ display .print (int (value ))
187+ else :
188+ print ("INT Value:{0}" .format (int (value )))
153189
154190 if last_value != value :
155191 chime_light () # animate the neopixels
@@ -159,5 +195,6 @@ def chime_light():
159195 # normally we wouldn't have to do this, but we get bad fragments
160196 r = value = None
161197 gc .collect ()
162- print (gc .mem_free ()) # pylint: disable=no-member
198+ print ("GC MEM:{0}" .format (gc .mem_free ())) # pylint: disable=no-member
199+ print ("Sleeping for: {0} Seconds" .format (TIME_BETWEEN_QUERY ))
163200 time .sleep (TIME_BETWEEN_QUERY )
0 commit comments