6
6
# TIME
7
7
8
8
def set_time_ntp ():
9
- draw_msg ("Configuring clock..." , "Connecting to WiFi..." )
9
+ draw_msg ("Configuring clock..." )
10
10
if connectWiFi ():
11
- draw_msg ("Configuring clock..." , " Setting time over NTP..." )
11
+ draw_msg ("Setting time over NTP..." )
12
12
ntp .set_NTP_time ()
13
- draw_msg ("Configuring clock..." , "Done !" )
13
+ draw_msg ("Time set !" )
14
14
return True
15
15
else :
16
16
return False
17
17
18
18
# GRAPHICS
19
- def draw_msg (title , desc ):
20
- ugfx .clear (ugfx .WHITE )
21
- ugfx .string (0 , 0 , title , "PermanentMarker22" , ugfx .BLACK )
22
- ugfx .string (0 , 25 , desc , "Roboto_Regular12" , ugfx .BLACK )
23
- ugfx .set_lut (ugfx .LUT_FASTEST )
24
- ugfx .flush ()
19
+ def draw_msg (msg ):
20
+ global line_number
21
+ try :
22
+ line_number
23
+ except :
24
+ line_number = 0
25
+ ugfx .clear (ugfx .WHITE )
26
+ ugfx .string (0 , 0 , 'Still Loading Anyway...' , "PermanentMarker22" , ugfx .BLACK )
27
+ ugfx .set_lut (ugfx .LUT_FASTER )
28
+ draw_msg (msg )
29
+ else :
30
+ ugfx .string (0 , 30 + (line_number * 15 ), msg , "Roboto_Regular12" , ugfx .BLACK )
31
+ ugfx .flush ()
32
+ line_number += 1
25
33
26
34
27
35
def draw_home (do_BPP ):
@@ -139,14 +147,14 @@ def connectWiFi():
139
147
password = badge .nvs_get_str ('badge' , 'wifi.password' )
140
148
nw .connect (ssid , password ) if password else nw .connect (ssid )
141
149
142
- draw_msg ("Wi-Fi actived" , " Connecting to '"+ ssid + "'..." )
150
+ draw_msg ("Connecting to '" + ssid + "'..." )
143
151
144
152
timeout = badge .nvs_get_u8 ('splash' , 'wifi.timeout' , 40 )
145
153
while not nw .isconnected ():
146
154
time .sleep (0.1 )
147
155
timeout = timeout - 1
148
156
if (timeout < 1 ):
149
- draw_msg ("Error" , " Timeout while connecting!" )
157
+ draw_msg ("Timeout while connecting!" )
150
158
disableWiFi ()
151
159
time .sleep (1 )
152
160
return False
@@ -156,19 +164,19 @@ def connectWiFi():
156
164
157
165
def download_ota_info ():
158
166
import urequests as requests
159
- draw_msg ("Loading..." , " Downloading JSON ..." )
167
+ draw_msg ("Downloading OTA status ..." )
160
168
result = False
161
169
try :
162
170
data = requests .get ("https://badge.sha2017.org/version" )
163
171
except :
164
- draw_msg ("Error" , " Could not download JSON!" )
172
+ draw_msg ("Could not download JSON!" )
165
173
time .sleep (5 )
166
174
return False
167
175
try :
168
176
result = data .json ()
169
177
except :
170
178
data .close ()
171
- draw_msg ("Error" , " Could not decode JSON!" )
179
+ draw_msg ("Could not decode JSON!" )
172
180
time .sleep (5 )
173
181
return False
174
182
data .close ()
0 commit comments