11
11
"""
12
12
13
13
import time
14
+ from os import getenv
14
15
15
16
import adafruit_tmp117
16
17
import adafruit_touchscreen
@@ -275,7 +276,7 @@ def list(self):
275
276
)
276
277
else :
277
278
print ("\n TabLayout test with I2C Temperature sensor and I2C Realtime clock" )
278
- print ("Add your WiFi SSID, WiFi password and Timezone in file: secrets.h \n " )
279
+ print ("Add your WiFi SSID, WiFi password and Timezone in file: settings.toml \n " )
279
280
280
281
if myVars .read ("my_debug" ):
281
282
while not i2c .try_lock ():
@@ -303,13 +304,9 @@ def list(self):
303
304
# NOTE: there is also the board.SD_CARD_DETECT pin (33)(but I don't know yet how to interface it)
304
305
####
305
306
306
- # you'll need to pass in an io username and key
307
- # Get wifi details and more from a secrets.py file
308
- try :
309
- from secrets import secrets
310
- except ImportError :
311
- print ("WiFi secrets are kept in secrets.py, please add them there!" )
312
- raise
307
+ # Get WiFi details, ensure these are setup in settings.toml
308
+ ssid = getenv ("CIRCUITPY_WIFI_SSID" )
309
+ password = getenv ("CIRCUITPY_WIFI_PASSWORD" )
313
310
314
311
if myVars .read ("my_debug" ):
315
312
if esp .status == adafruit_esp32spi .WL_IDLE_STATUS :
@@ -320,13 +317,13 @@ def list(self):
320
317
for ap in esp .scan_networks ():
321
318
print ("\t %s\t \t RSSI: %d" % (str (ap ["ssid" ], "utf-8" ), ap ["rssi" ]))
322
319
323
- # Get our username, key and desired timezone
324
- location = secrets . get ("timezone" , None )
320
+ # Get our desired timezone
321
+ location = getenv ("timezone" , None )
325
322
326
323
print ("\n Connecting to AP..." )
327
324
while not esp .is_connected :
328
325
try :
329
- esp .connect_AP (secrets [ " ssid" ], secrets [ " password" ] )
326
+ esp .connect_AP (ssid , password )
330
327
except RuntimeError as e :
331
328
print ("could not connect to AP, retrying: " , e )
332
329
continue
@@ -359,7 +356,7 @@ def refresh_from_NTP():
359
356
myVars .write ("online_time_present" , True )
360
357
myVars .write ("ntp_refresh" , False )
361
358
# Get the current time in seconds since Jan 1, 1970 and correct it for local timezone
362
- # (defined in secrets.h )
359
+ # (defined in settings.toml )
363
360
ntp_current_time = time .time ()
364
361
if myVars .read ("my_debug" ):
365
362
print (f"Seconds since Jan 1, 1970: { ntp_current_time } seconds" )
@@ -377,9 +374,9 @@ def refresh_from_NTP():
377
374
# Initialize the NTP object
378
375
ntp = NTP (esp )
379
376
380
- location = secrets . get ("timezone" , location )
377
+ location = getenv ("timezone" , location )
381
378
if myVars .read ("my_debug" ):
382
- print ("location (from secrets.h ) = " , location )
379
+ print (f "location (from settings.toml ) = { location } " )
383
380
if location == "Europe/Lisbon" :
384
381
if myVars .read ("my_debug" ):
385
382
print ("Using timezone Europe/Lisbon" )
0 commit comments