@@ -30,41 +30,37 @@ def splash_draw_actions(sleeping):
30
30
l = ugfx .get_string_width (info2 ,"Roboto_Regular12" )
31
31
ugfx .string (296 - l , 12 , info2 , "Roboto_Regular12" ,ugfx .BLACK )
32
32
33
- def splash_draw (full = False ,sleeping = False ):
34
- if easydraw .msgShown :
35
- easydraw .msgShown = False
36
- easydraw .msgLineNumber = 0
37
- full = True
38
-
33
+ def splash_draw (full = False ,sleeping = False ):
34
+
39
35
vUsb = badge .usb_volt_sense ()
40
36
vBatt = badge .battery_volt_sense ()
41
37
vBatt += vDrop
42
38
charging = badge .battery_charge_status ()
43
-
39
+
44
40
if splash_power_countdown_get ()< 1 :
45
41
full = True
46
-
42
+
47
43
if full :
48
44
ugfx .clear (ugfx .WHITE )
49
45
easydraw .nickname ()
50
46
else :
51
47
ugfx .area (0 ,0 ,ugfx .width (),24 ,ugfx .WHITE )
52
48
ugfx .area (0 ,ugfx .height ()- 64 ,ugfx .width (),64 ,ugfx .WHITE )
53
-
54
- easydraw .battery (vUsb , vBatt , charging )
55
-
49
+
50
+ easydraw .battery (vUsb , vBatt , charging )
51
+
56
52
global splashPowerCountdown
57
-
53
+
58
54
if splashPowerCountdown > 0 :
59
55
if vBatt > 500 :
60
56
ugfx .string (52 , 0 , str (round (vBatt / 1000 , 1 )) + 'v' ,'Roboto_Regular12' ,ugfx .BLACK )
61
57
if splashPowerCountdown > 0 and splashPowerCountdown < badge .nvs_get_u8 ('splash' , 'timer.amount' , 30 ):
62
58
ugfx .string (52 , 13 , "Sleeping in " + str (splashPowerCountdown )+ "..." ,'Roboto_Regular12' ,ugfx .BLACK )
63
-
59
+
64
60
splash_draw_actions (sleeping )
65
-
61
+
66
62
services .draw ()
67
-
63
+
68
64
if full :
69
65
ugfx .flush (ugfx .LUT_FULL )
70
66
else :
@@ -74,21 +70,19 @@ def splash_draw(full=False,sleeping=False):
74
70
75
71
def splash_ota_download_info ():
76
72
import urequests as requests
77
- easydraw .msg ("Checking for updates..." , True )
73
+ easydraw .msg ("Checking for updates..." )
78
74
result = False
79
75
try :
80
76
data = requests .get ("https://badge.sha2017.org/version" )
81
77
except :
82
- easydraw .msg ("Error:" )
83
- easydraw .msg ("Could not download JSON!" )
78
+ easydraw .msg ("Error: could not download JSON!" )
84
79
time .sleep (5 )
85
80
return False
86
81
try :
87
82
result = data .json ()
88
83
except :
89
84
data .close ()
90
- easydraw .msg ("Error:" )
91
- easydraw .msg ("Could not decode JSON!" )
85
+ easydraw .msg ("Error: could not decode JSON!" )
92
86
time .sleep (5 )
93
87
return False
94
88
data .close ()
@@ -98,7 +92,7 @@ def splash_ota_check():
98
92
if not easywifi .status ():
99
93
if not easywifi .enable ():
100
94
return False
101
-
95
+
102
96
info = splash_ota_download_info ()
103
97
if info :
104
98
import version
@@ -111,10 +105,10 @@ def splash_ota_check():
111
105
112
106
def splash_ota_start ():
113
107
appglue .start_ota ()
114
-
108
+
115
109
# Resources
116
110
def splash_resources_install ():
117
- easydraw .msg ("Installing resources..." , True )
111
+ easydraw .msg ("Installing resources..." )
118
112
if not easywifi .status ():
119
113
if not easywifi .enable ():
120
114
return False
@@ -145,10 +139,10 @@ def splash_sponsors_install():
145
139
if not easywifi .enable ():
146
140
return False
147
141
print ("[SPLASH] Installing sponsors..." )
148
- easydraw .msg ("Installing sponsors..." , True )
142
+ easydraw .msg ("Installing sponsors..." )
149
143
import woezel
150
144
woezel .install ("sponsors" )
151
- easydraw .msg ("Done. " )
145
+ easydraw .msg ("Done! " )
152
146
153
147
def splash_sponsors_show ():
154
148
needToInstall = True
@@ -160,7 +154,7 @@ def splash_sponsors_show():
160
154
except :
161
155
print ("[SPLASH] Sponsors not installed." )
162
156
if version >= 14 :
163
- needToInstall = False
157
+ needToInstall = False
164
158
if needToInstall :
165
159
splash_sponsors_install ()
166
160
try :
@@ -171,14 +165,14 @@ def splash_sponsors_show():
171
165
appglue .start_app ("sponsors" )
172
166
except :
173
167
pass
174
-
168
+
175
169
176
170
# About
177
171
178
172
def splash_about_countdown_reset ():
179
173
global splashAboutCountdown
180
174
splashAboutCountdown = badge .nvs_get_u8 ('splash' , 'about.amount' , 10 )
181
-
175
+
182
176
def splash_about_countdown_trigger ():
183
177
global splashAboutCountdown
184
178
try :
@@ -191,7 +185,7 @@ def splash_about_countdown_trigger():
191
185
appglue .start_app ('magic' , False )
192
186
else :
193
187
print ("[SPLASH] Magic in " + str (splashAboutCountdown )+ "..." )
194
-
188
+
195
189
196
190
# Power management
197
191
@@ -206,14 +200,14 @@ def splash_power_countdown_get():
206
200
except :
207
201
splash_power_countdown_reset ()
208
202
return splashPowerCountdown
209
-
203
+
210
204
def splash_power_countdown_trigger ():
211
205
global splashPowerCountdown
212
206
try :
213
207
splashPowerCountdown
214
208
except :
215
209
splash_power_countdown_reset ()
216
-
210
+
217
211
splashPowerCountdown -= 1
218
212
if badge .usb_volt_sense () > 4000 :
219
213
splash_power_countdown_reset ()
@@ -253,7 +247,7 @@ def splash_input_select(pressed):
253
247
if otaAvailable :
254
248
splash_ota_start ()
255
249
splash_power_countdown_reset ()
256
-
250
+
257
251
#def splash_input_left(pressed):
258
252
# if pressed:
259
253
# appglue.start_bpp()
@@ -285,7 +279,7 @@ def splash_timer_init():
285
279
splashTimer = machine .Timer (- 1 )
286
280
splashTimer .init (period = badge .nvs_get_u16 ('splash' , 'timer.period' , 100 ), mode = machine .Timer .ONE_SHOT , callback = splash_timer_callback )
287
281
print ("[SPLASH] Timer created" )
288
-
282
+
289
283
def splash_timer_callback (tmr ):
290
284
try :
291
285
if services .loop (splash_power_countdown_get ()):
@@ -295,8 +289,8 @@ def splash_timer_callback(tmr):
295
289
if not splash_power_countdown_trigger ():
296
290
splash_draw (False , False )
297
291
tmr .init (period = badge .nvs_get_u16 ('splash' , 'timer.period' , 100 ), mode = machine .Timer .ONE_SHOT , callback = splash_timer_callback )
298
-
299
-
292
+
293
+
300
294
### PROGRAM
301
295
302
296
# Load settings from NVS
@@ -316,7 +310,7 @@ def splash_timer_callback(tmr):
316
310
317
311
# Initialize about subsystem
318
312
splash_about_countdown_reset ()
319
-
313
+
320
314
# Setup / Sponsors / OTA check / NTP clock sync
321
315
setupState = badge .nvs_get_u8 ('badge' , 'setup.state' , 0 )
322
316
if setupState == 0 : #First boot
@@ -338,7 +332,7 @@ def splash_timer_callback(tmr):
338
332
otaAvailable = splash_ota_check ()
339
333
else :
340
334
otaAvailable = badge .nvs_get_u8 ('badge' ,'OTA.ready' ,0 )
341
-
335
+
342
336
# Download resources to fatfs
343
337
splash_resources_check ()
344
338
@@ -348,7 +342,7 @@ def splash_timer_callback(tmr):
348
342
349
343
# Initialize services
350
344
services .setup ()
351
-
345
+
352
346
# Disable WiFi if active
353
347
easywifi .disable ()
354
348
0 commit comments