@@ -40,7 +40,9 @@ def draw_home(do_BPP):
40
40
vBatt = badge .battery_volt_sense ()
41
41
vBatt += vDrop
42
42
43
- width = (vBatt - vMin ) / (vMax - vMin ) * 38
43
+ ugfx .clear (ugfx .WHITE )
44
+
45
+ width = round ((vBatt - vMin ) / (vMax - vMin ) * 38 )
44
46
if width < 0 :
45
47
width = 0
46
48
elif width < 38 :
@@ -62,22 +64,26 @@ def draw_home(do_BPP):
62
64
ugfx .string (47 , 2 , bat_status ,'Roboto_Regular18' ,ugfx .BLACK )
63
65
64
66
65
-
66
67
if do_BPP :
67
- info = " [ ANY: Wake up ]"
68
+ info = ' [ ANY: Wake up ]'
68
69
elif OTA_available :
69
- info = " [ B: OTA ] [ START: LAUNCHER ]"
70
- ugfx .string (0 , 108 , 'OTA ready!' , " Roboto_Regular18" , ugfx .BLACK )
70
+ info = ' [ B: OTA ] [ START: LAUNCHER ]'
71
+ ugfx .string (0 , 108 , 'OTA ready!' , ' Roboto_Regular18' , ugfx .BLACK )
71
72
else :
72
- info = " [ START: LAUNCHER ]"
73
+ info = ' [ START: LAUNCHER ]'
73
74
74
75
l = ugfx .get_string_width (info ,"Roboto_Regular12" )
75
76
ugfx .string (296 - l , 115 , info , "Roboto_Regular12" ,ugfx .BLACK )
76
77
77
78
ugfx .string (0 , 40 , nick , "PermanentMarker36" , ugfx .BLACK )
78
79
services .draw ()
79
80
80
- ugfx .flush ()
81
+ ugfx .flush (ugfx .LUT_FULL )
82
+
83
+ if do_BPP :
84
+ badge .eink_busy_wait ()
85
+ # appglue.start_bpp() ## SHOULD BE THIS!!
86
+ deepsleep .start_sleeping ()
81
87
82
88
# START LAUNCHER
83
89
def press_start (pushed ):
@@ -91,11 +97,14 @@ def start_ota(pushed):
91
97
# NOTHING
92
98
def press_nothing (pushed ):
93
99
if pushed :
94
- loopCnt = badge .nvs_get_u8 ('splash' , 'timer.amount' , 25 )
100
+ global loopCount
101
+ loopCount = badge .nvs_get_u8 ('splash' , 'timer.amount' , 50 )
95
102
96
103
def press_a (pushed ):
97
104
if pushed :
98
- loopCnt = badge .nvs_get_u8 ('splash' , 'timer.amount' , 25 )
105
+ global loopCount
106
+ global magic
107
+ loopCount = badge .nvs_get_u8 ('splash' , 'timer.amount' , 50 )
99
108
magic += 1
100
109
if magic > 9 :
101
110
appglue .start_app ('magic' , False )
@@ -115,17 +124,18 @@ def sleepIfEmpty(vbatt):
115
124
116
125
# TIMER
117
126
def splashTimer_callback (tmr ):
127
+ global loopCount
118
128
try :
119
129
loopCount
120
- except NameError :
121
- loopCount = badge .nvs_get_u8 ('splash' , 'timer.amount' , 25 )
130
+ except :
131
+ loopCount = badge .nvs_get_u8 ('splash' , 'timer.amount' , 50 )
122
132
draw_home (False )
123
133
else :
124
- if loopCnt < 1 :
134
+ if loopCount < 1 :
125
135
draw_home (True )
126
136
else :
127
- if not services .loop (loopCnt ):
128
- loopCnt -= 1
137
+ if not services .loop (loopCount ):
138
+ loopCount -= 1
129
139
130
140
# WIFI
131
141
def disableWiFi ():
@@ -182,7 +192,10 @@ def check_ota_available():
182
192
import version
183
193
if (json ["build" ] > version .build ):
184
194
ugfx .input_attach (ugfx .BTN_B , start_ota )
195
+ badge .nvs_set_u8 ('badge' ,'OTA.ready' ,1 )
185
196
return True
197
+ else :
198
+ badge .nvs_set_u8 ('badge' ,'OTA.ready' ,0 )
186
199
return False
187
200
188
201
def inputInit ():
@@ -198,21 +211,24 @@ def inputInit():
198
211
199
212
def checkFirstBoot ():
200
213
setupcompleted = int (badge .nvs_get_str ('badge' , 'setup.state' , '0' ))
201
- if ( setupcompleted == 0 ) : # First boot (open setup)
214
+ if setupcompleted == 0 : # First boot (open setup)
202
215
print ("[SPLASH] Setup not completed. Running setup!" )
203
216
appglue .start_app ("setup" )
204
- elif ( setupcompleted == 1 ) : # Second boot (after setup)
217
+ elif setupcompleted == 1 : # Second boot (after setup)
205
218
print ("[SPLASH] Showing sponsors once..." )
206
219
badge .nvs_set_str ('badge' , 'setup.state' , '2' ) # Only force show sponsors once
207
220
appglue .start_app ("sponsors" )
221
+ elif setupcompleted == 2 :
222
+ badge .nvs_set_str ('badge' , 'setup.state' , '3' )
223
+ check_ota_available ()
208
224
else : # Setup completed
209
225
print ("[SPLASH] Normal boot." )
210
226
211
227
header_inv = badge .nvs_get_u8 ('splash' , 'header.invert' , 0 )
212
228
nick = badge .nvs_get_str ("owner" , "name" , 'John Doe' )
213
229
vMin = badge .nvs_get_u16 ('splash' , 'bat.volt.min' , 3600 ) # mV
214
230
vMax = badge .nvs_get_u16 ('splash' , 'bat.volt.max' , 4200 ) # mV
215
- vDrop = badge .nvs_get_u16 ('splash' , 'bat.volt.drop' , 100 ) # mV
231
+ vDrop = badge .nvs_get_u16 ('splash' , 'bat.volt.drop' , 80 ) # mV
216
232
217
233
inputInit ()
218
234
magic = 0
@@ -225,9 +241,11 @@ def checkFirstBoot():
225
241
if (machine .reset_cause () != machine .DEEPSLEEP_RESET ) and doOTA :
226
242
OTA_available = check_ota_available ()
227
243
else :
228
- OTA_available = False
244
+ OTA_available = badge . nvs_get_u8 ( 'badge' , 'OTA.ready' , 0 )
229
245
230
246
disableWiFi ()
247
+ ugfx .clear (ugfx .WHITE )
248
+ ugfx .flush (ugfx .LUT_FASTER )
231
249
232
250
foundService = services .setup ()
233
251
0 commit comments