Skip to content

Commit 0f78dfe

Browse files
committed
Make sure eink is done drawing before sleeping
1 parent 6ac0293 commit 0f78dfe

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

esp32/modules/splash.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ def draw_home(percent, cstate, status):
151151

152152
def draw_batterylow(percent):
153153
ugfx.clear(ugfx.WHITE)
154-
ugfx.string(0, 0, str(percent)+"% - BATTERY LOW, PLEASE CHARGE!","Roboto_Regular12",ugfx.BLACK)
155-
nick = badge.nvs_get_str("owner", "name", "Hacker1337")
154+
ugfx.string(0, 0, str(percent)+"% - Battery empty. Please charge me!","Roboto_Regular12",ugfx.BLACK)
155+
nick = badge.nvs_get_str("owner", "name", ":( Zzzz...")
156156
ugfx.string(0, 40, nick, "PermanentMarker36", ugfx.BLACK)
157157
ugfx.set_lut(ugfx.LUT_FASTER)
158158
ugfx.flush()
@@ -169,6 +169,8 @@ def start_launcher(pushed):
169169
# SLEEP
170170

171171
def badge_sleep():
172+
print("Going to sleep now...")
173+
badge.eink_busy_wait() #Always wait for e-ink
172174
deepsleep.start_sleeping(30000) #Sleep for 30 seconds
173175

174176
# TIMER
@@ -180,11 +182,14 @@ def splashTimer_callback(tmr):
180182
cstate = badge.battery_charge_status()
181183
vbatt = badge.battery_volt_sense()
182184
percent = battery_percent(3800, 4300, vbatt)
183-
if (cstate) or (percent>95):
184-
draw_home(percent, cstate, "Press start to open launcher!")
185+
if (cstate) or (percent>95) or (percent<1):
186+
if (percent==0):
187+
draw_home(percent, cstate, "Huh?! You removed the battery?")
188+
else:
189+
draw_home(percent, cstate, "Press start to open the launcher!")
185190
else:
186191
if (percent<10):
187-
draw_batterylow(percent)
192+
draw_batterylow(percent)
188193
ugfx.flush()
189194
else:
190195
draw_home(percent, cstate, "Zzz...")
@@ -234,6 +239,13 @@ def splash_main():
234239
global splashTimer
235240
setup_services()
236241
start_sleep_counter()
242+
elif(percent==0):
243+
ugfx.clear(ugfx.WHITE)
244+
ugfx.string(0, 0, "Recovery mode", "PermanentMarker22", ugfx.BLACK)
245+
ugfx.string(0, 25, "No battery. Dropping to shell...", "Roboto_Regular12", ugfx.BLACK)
246+
ugfx.set_lut(ugfx.LUT_FASTER)
247+
ugfx.flush()
248+
237249
else:
238250
draw_batterylow(percent)
239251
badge_sleep()

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