Explorar el Código

Update 'CARDPUTER CircuitPython/wifi_switcher/code.py'

added "connecting..." message so it doesnt look like fail hang to user
cube hace 1 mes
padre
commit
3d5d7ea51b
Se han modificado 1 ficheros con 14 adiciones y 9 borrados
  1. 14
    9
      CARDPUTER CircuitPython/wifi_switcher/code.py

+ 14
- 9
CARDPUTER CircuitPython/wifi_switcher/code.py Ver fichero

78
         break
78
         break
79
 
79
 
80
 try:
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
     wifi.radio.connect(ssid=WIFI_SSID,
90
     wifi.radio.connect(ssid=WIFI_SSID,
82
                     password=WIFI_PASS)
91
                     password=WIFI_PASS)
83
     my_ip = str(wifi.radio.ipv4_address).strip()
92
     my_ip = str(wifi.radio.ipv4_address).strip()
93
+
84
     display.root_group.remove(h1)
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
 except ConnectionError as e:
96
 except ConnectionError as e:
88
     h1.text = "Aw..."
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
     txt.text = "Could not connect to " + WIFI_SSID
99
     txt.text = "Could not connect to " + WIFI_SSID
100
+    txt.color = 0xff0000
95
     txt.x = 10
101
     txt.x = 10
96
     txt.y = 35
102
     txt.y = 35
97
 
103
 
99
     txt2.text = "Press CTRL + C followed by CTRL + D\nto soft-reboot"
105
     txt2.text = "Press CTRL + C followed by CTRL + D\nto soft-reboot"
100
     txt2.x = 10
106
     txt2.x = 10
101
     txt2.y = 100
107
     txt2.y = 100
102
-
103
-    display.root_group.append(txt)
108
+    
104
     display.root_group.append(txt2)
109
     display.root_group.append(txt2)
105
     
110
     
106
     while True:
111
     while True: