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

Commit 0e89e70

Browse files
authored
Merge pull request SHA2017-badge#101 from SHA2017-badge/setup.state_as_u8
Setup.state as u8 and shorter keys
2 parents f1a54b1 + 1efe853 commit 0e89e70

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

esp32/modules/launcher.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ def expandhome(s):
7373
s = s.replace("~/", h + "/")
7474
return s
7575

76+
def gohome(pressed):
77+
if(pressed):
78+
appglue.home()
79+
7680
def get_install_path():
7781
global install_path
7882
if install_path is None:

esp32/modules/setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def store_settings(nickname):
1111

1212
def is_developer(nickname):
1313
if (nickname==""):
14-
badge.nvs_set_str('badge', 'setup.state', '2') # Skip the sponsors
14+
badge.nvs_set_u8('badge', 'setup.state', 2) # Skip the sponsors
1515
return True
1616
return False
1717

@@ -20,11 +20,11 @@ def action_home(pressed):
2020
appglue.start_app("")
2121

2222
def set_setup_state():
23-
s_old = int(badge.nvs_get_str('badge', 'setup.state', '0'))
23+
s_old = badge.nvs_get_u8('badge', 'setup.state', 0)
2424
s_new = 2
2525
if (s_old==0):
2626
s_new = 1
27-
badge.nvs_set_str('badge', 'setup.state', str(s_new))
27+
badge.nvs_set_u8('badge', 'setup.state', s_new)
2828

2929
def draw_setup_completed():
3030
ugfx.clear(ugfx.WHITE)

esp32/modules/splash.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ def splashTimer_callback(tmr):
319319
global loopCnt
320320
global timer_loop_amount
321321
#print("[TIMER] "+str(loopCnt))
322+
#print("[BATTERY] "+str(badge.battery_volt_sense())+" ["+str(badge.battery_charge_status())+"]")
323+
322324
if loopCnt<1:
323325
loopCnt = timer_loop_amount
324326
cstate = badge.battery_charge_status()
@@ -384,7 +386,6 @@ def wifi_connect():
384386
return True
385387

386388
# CHECK OTA VERSION
387-
388389
def download_ota_info():
389390
import gc
390391
import urequests as requests
@@ -433,13 +434,13 @@ def check_ota_available():
433434

434435
# WELCOME (SETUP, SPONSORS OR CLOCK)
435436
def welcome():
436-
setupcompleted = int(badge.nvs_get_str('badge', 'setup.state', '0'))
437+
setupcompleted = badge.nvs_get_u8('badge', 'setup.state', 0)
437438
if (setupcompleted==0): # First boot (open setup)
438439
print("[SPLASH] Setup not completed. Running setup!")
439440
appglue.start_app("setup")
440441
elif (setupcompleted==1): # Second boot (after setup)
441442
print("[SPLASH] Showing sponsors once...")
442-
badge.nvs_set_str('badge', 'setup.state', '2') # Only force show sponsors once
443+
badge.nvs_set_u8('badge', 'setup.state', 2) # Only force show sponsors once
443444
appglue.start_app("sponsors")
444445
else: # Setup completed
445446
print("[SPLASH] Normal boot.")
@@ -474,19 +475,19 @@ def load_settings():
474475
#if (sleep_duration>120):
475476
# print("[SPLASH] Sleep duration set to more than 120 seconds. Forcing 120 seconds.")
476477
global battery_volt_min
477-
battery_volt_min = badge.nvs_get_u16('splash', 'bat.volt.min', 3700) # mV
478+
battery_volt_min = badge.nvs_get_u16('splash', 'batt.vmin', 3700) # mV
478479
global battery_volt_max
479-
battery_volt_max = badge.nvs_get_u16('splash', 'bat.volt.max', 4200) # mV
480+
battery_volt_max = badge.nvs_get_u16('splash', 'batt.vmax', 4200) # mV
480481
global battery_percent_empty
481-
battery_percent_empty = badge.nvs_get_u8('splash', 'bat.perc.empty', 1) # %
482+
battery_percent_empty = badge.nvs_get_u8('splash', 'batt.pempty', 1) # %
482483
global ntp_timeout
483484
ntp_timeout = badge.nvs_get_u8('splash', 'ntp.timeout', 40) #amount of tries
484485
global bpp_after_count
485486
bpp_after_count = badge.nvs_get_u8('splash', 'bpp.count', 5)
486487
global splash_timer_interval
487-
splash_timer_interval = badge.nvs_get_u16('splash', 'timer.interval', 200)
488+
splash_timer_interval = badge.nvs_get_u16('splash', 'tmr.interval', 200)
488489
global timer_loop_amount
489-
timer_loop_amount = badge.nvs_get_u8('splash', 'timer.amount', 25)
490+
timer_loop_amount = badge.nvs_get_u8('splash', 'tmr.amount', 25)
490491
global loopCnt
491492
loopCnt = timer_loop_amount
492493

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