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

Commit d3714c6

Browse files
committed
sexy loading screen
1 parent 5147507 commit d3714c6

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

esp32/modules/splash.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,30 @@
66
# TIME
77

88
def set_time_ntp():
9-
draw_msg("Configuring clock...", "Connecting to WiFi...")
9+
draw_msg("Configuring clock...")
1010
if connectWiFi():
11-
draw_msg("Configuring clock...", "Setting time over NTP...")
11+
draw_msg("Setting time over NTP...")
1212
ntp.set_NTP_time()
13-
draw_msg("Configuring clock...", "Done!")
13+
draw_msg("Time set!")
1414
return True
1515
else:
1616
return False
1717

1818
# 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
2533

2634

2735
def draw_home(do_BPP):
@@ -139,14 +147,14 @@ def connectWiFi():
139147
password = badge.nvs_get_str('badge', 'wifi.password')
140148
nw.connect(ssid, password) if password else nw.connect(ssid)
141149

142-
draw_msg("Wi-Fi actived", "Connecting to '"+ssid+"'...")
150+
draw_msg("Connecting to '"+ssid+"'...")
143151

144152
timeout = badge.nvs_get_u8('splash', 'wifi.timeout', 40)
145153
while not nw.isconnected():
146154
time.sleep(0.1)
147155
timeout = timeout - 1
148156
if (timeout<1):
149-
draw_msg("Error", "Timeout while connecting!")
157+
draw_msg("Timeout while connecting!")
150158
disableWiFi()
151159
time.sleep(1)
152160
return False
@@ -156,19 +164,19 @@ def connectWiFi():
156164

157165
def download_ota_info():
158166
import urequests as requests
159-
draw_msg("Loading...", "Downloading JSON...")
167+
draw_msg("Downloading OTA status...")
160168
result = False
161169
try:
162170
data = requests.get("https://badge.sha2017.org/version")
163171
except:
164-
draw_msg("Error", "Could not download JSON!")
172+
draw_msg("Could not download JSON!")
165173
time.sleep(5)
166174
return False
167175
try:
168176
result = data.json()
169177
except:
170178
data.close()
171-
draw_msg("Error", "Could not decode JSON!")
179+
draw_msg("Could not decode JSON!")
172180
time.sleep(5)
173181
return False
174182
data.close()

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