Преглед на файлове

Update 'CARDPUTER CircuitPython/wifi_switcher/code.py'

added "connecting..." message so it doesnt look like fail hang to user
cube преди 1 месец
родител
ревизия
3d5d7ea51b
променени са 1 файла, в които са добавени 14 реда и са изтрити 9 реда
  1. 14
    9
      CARDPUTER CircuitPython/wifi_switcher/code.py

+ 14
- 9
CARDPUTER CircuitPython/wifi_switcher/code.py Целия файл

@@ -78,20 +78,26 @@ while True:
78 78
         break
79 79
 
80 80
 try:
81
+    for lab in menu_labs:
82
+        display.root_group.remove(lab)
83
+
84
+    txt = label.Label(terminalio.FONT, text = "", color=0x00ff00, scale=1)
85
+    txt.text = "Connecting to " + WIFI_SSID + "..."
86
+    txt.x = 10
87
+    txt.y = 35
88
+    display.root_group.append(txt)
89
+
81 90
     wifi.radio.connect(ssid=WIFI_SSID,
82 91
                     password=WIFI_PASS)
83 92
     my_ip = str(wifi.radio.ipv4_address).strip()
93
+
84 94
     display.root_group.remove(h1)
85
-    for lab in menu_labs:
86
-        display.root_group.remove(lab)
95
+    display.root_group.remove(txt)
87 96
 except ConnectionError as e:
88 97
     h1.text = "Aw..."
89
-
90
-    for lab in menu_labs:
91
-        display.root_group.remove(lab)
92
-
93
-    txt = label.Label(terminalio.FONT, text = "", color=0xff0000, scale=1)
98
+    
94 99
     txt.text = "Could not connect to " + WIFI_SSID
100
+    txt.color = 0xff0000
95 101
     txt.x = 10
96 102
     txt.y = 35
97 103
 
@@ -99,8 +105,7 @@ except ConnectionError as e:
99 105
     txt2.text = "Press CTRL + C followed by CTRL + D\nto soft-reboot"
100 106
     txt2.x = 10
101 107
     txt2.y = 100
102
-
103
-    display.root_group.append(txt)
108
+    
104 109
     display.root_group.append(txt2)
105 110
     
106 111
     while True: