1111"""
1212
1313import time
14+ from os import getenv
1415
1516import adafruit_tmp117
1617import adafruit_touchscreen
@@ -275,7 +276,7 @@ def list(self):
275276 )
276277else :
277278 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 " )
279280
280281if myVars .read ("my_debug" ):
281282 while not i2c .try_lock ():
@@ -303,13 +304,9 @@ def list(self):
303304# NOTE: there is also the board.SD_CARD_DETECT pin (33)(but I don't know yet how to interface it)
304305####
305306
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" )
313310
314311if myVars .read ("my_debug" ):
315312 if esp .status == adafruit_esp32spi .WL_IDLE_STATUS :
@@ -320,13 +317,13 @@ def list(self):
320317 for ap in esp .scan_networks ():
321318 print ("\t %s\t \t RSSI: %d" % (str (ap ["ssid" ], "utf-8" ), ap ["rssi" ]))
322319
323- # Get our username, key and desired timezone
324- location = secrets . get ("timezone" , None )
320+ # Get our desired timezone
321+ location = getenv ("timezone" , None )
325322
326323print ("\n Connecting to AP..." )
327324while not esp .is_connected :
328325 try :
329- esp .connect_AP (secrets [ " ssid" ], secrets [ " password" ] )
326+ esp .connect_AP (ssid , password )
330327 except RuntimeError as e :
331328 print ("could not connect to AP, retrying: " , e )
332329 continue
@@ -359,7 +356,7 @@ def refresh_from_NTP():
359356 myVars .write ("online_time_present" , True )
360357 myVars .write ("ntp_refresh" , False )
361358 # 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 )
363360 ntp_current_time = time .time ()
364361 if myVars .read ("my_debug" ):
365362 print (f"Seconds since Jan 1, 1970: { ntp_current_time } seconds" )
@@ -377,9 +374,9 @@ def refresh_from_NTP():
377374 # Initialize the NTP object
378375 ntp = NTP (esp )
379376
380- location = secrets . get ("timezone" , location )
377+ location = getenv ("timezone" , location )
381378 if myVars .read ("my_debug" ):
382- print ("location (from secrets.h ) = " , location )
379+ print (f "location (from settings.toml ) = { location } " )
383380 if location == "Europe/Lisbon" :
384381 if myVars .read ("my_debug" ):
385382 print ("Using timezone Europe/Lisbon" )
0 commit comments