Skip to content
This repository was archived by the owner on Oct 28, 2023. It is now read-only.

Commit edeac1f

Browse files
committed
Bigfixes
1 parent 31858f8 commit edeac1f

File tree

1 file changed

+36
-18
lines changed

1 file changed

+36
-18
lines changed

esp32/modules/splash.py

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def draw_home(do_BPP):
4040
vBatt = badge.battery_volt_sense()
4141
vBatt += vDrop
4242

43-
width = (vBatt-vMin) / (vMax-vMin) * 38
43+
ugfx.clear(ugfx.WHITE)
44+
45+
width = round((vBatt-vMin) / (vMax-vMin) * 38)
4446
if width < 0:
4547
width = 0
4648
elif width < 38:
@@ -62,22 +64,26 @@ def draw_home(do_BPP):
6264
ugfx.string(47, 2, bat_status,'Roboto_Regular18',ugfx.BLACK)
6365

6466

65-
6667
if do_BPP:
67-
info = "[ ANY: Wake up ]"
68+
info = '[ ANY: Wake up ]'
6869
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)
7172
else:
72-
info = "[ START: LAUNCHER ]"
73+
info = '[ START: LAUNCHER ]'
7374

7475
l = ugfx.get_string_width(info,"Roboto_Regular12")
7576
ugfx.string(296-l, 115, info, "Roboto_Regular12",ugfx.BLACK)
7677

7778
ugfx.string(0, 40, nick, "PermanentMarker36", ugfx.BLACK)
7879
services.draw()
7980

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()
8187

8288
# START LAUNCHER
8389
def press_start(pushed):
@@ -91,11 +97,14 @@ def start_ota(pushed):
9197
# NOTHING
9298
def press_nothing(pushed):
9399
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)
95102

96103
def press_a(pushed):
97104
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)
99108
magic += 1
100109
if magic > 9:
101110
appglue.start_app('magic', False)
@@ -115,17 +124,18 @@ def sleepIfEmpty(vbatt):
115124

116125
# TIMER
117126
def splashTimer_callback(tmr):
127+
global loopCount
118128
try:
119129
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)
122132
draw_home(False)
123133
else:
124-
if loopCnt<1:
134+
if loopCount < 1:
125135
draw_home(True)
126136
else:
127-
if not services.loop(loopCnt):
128-
loopCnt -= 1
137+
if not services.loop(loopCount):
138+
loopCount -= 1
129139

130140
# WIFI
131141
def disableWiFi():
@@ -182,7 +192,10 @@ def check_ota_available():
182192
import version
183193
if (json["build"] > version.build):
184194
ugfx.input_attach(ugfx.BTN_B, start_ota)
195+
badge.nvs_set_u8('badge','OTA.ready',1)
185196
return True
197+
else:
198+
badge.nvs_set_u8('badge','OTA.ready',0)
186199
return False
187200

188201
def inputInit():
@@ -198,21 +211,24 @@ def inputInit():
198211

199212
def checkFirstBoot():
200213
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)
202215
print("[SPLASH] Setup not completed. Running setup!")
203216
appglue.start_app("setup")
204-
elif (setupcompleted==1): # Second boot (after setup)
217+
elif setupcompleted == 1: # Second boot (after setup)
205218
print("[SPLASH] Showing sponsors once...")
206219
badge.nvs_set_str('badge', 'setup.state', '2') # Only force show sponsors once
207220
appglue.start_app("sponsors")
221+
elif setupcompleted == 2:
222+
badge.nvs_set_str('badge', 'setup.state', '3')
223+
check_ota_available()
208224
else: # Setup completed
209225
print("[SPLASH] Normal boot.")
210226

211227
header_inv = badge.nvs_get_u8('splash', 'header.invert', 0)
212228
nick = badge.nvs_get_str("owner", "name", 'John Doe')
213229
vMin = badge.nvs_get_u16('splash', 'bat.volt.min', 3600) # mV
214230
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
216232

217233
inputInit()
218234
magic = 0
@@ -225,9 +241,11 @@ def checkFirstBoot():
225241
if (machine.reset_cause() != machine.DEEPSLEEP_RESET) and doOTA:
226242
OTA_available = check_ota_available()
227243
else:
228-
OTA_available = False
244+
OTA_available = badge.nvs_get_u8('badge','OTA.ready',0)
229245

230246
disableWiFi()
247+
ugfx.clear(ugfx.WHITE)
248+
ugfx.flush(ugfx.LUT_FASTER)
231249

232250
foundService = services.setup()
233251

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy