Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions src/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,47 @@ def home(ctx_home):
break


preimport_ticks = time.ticks_ms()
draw_splash()
check_for_updates()
gc.collect()

from krux.context import ctx
from krux.auto_shutdown import auto_shutdown

ctx.power_manager = power_manager
auto_shutdown.add_ctx(ctx)

# Biometric Login Check
biometric_attempted = False
try:
from krux.krux_settings import Settings
if Settings().security.biometric_unlock:
from krux.pages.biometric_pages import QR_DATA_FILE
# Only initialize LCD if we actually have data to check
try:
os.stat(QR_DATA_FILE)
from krux.pages.biometric_pages import BiometricUnlock
from krux.display import display
display.initialize_lcd()

unlocker = BiometricUnlock(ctx)
if unlocker.qr_data:
unlocker.run()
biometric_attempted = True
except:
pass
except Exception as e:
print("Biometric boot error:", e)

preimport_ticks = time.ticks_ms()

if not biometric_attempted:
draw_splash()

check_for_updates()
gc.collect()

# If importing happened too fast, sleep the difference so the logo
# will be shown
# will be shown (only if we showed it)
postimport_ticks = time.ticks_ms()
if preimport_ticks + MIN_SPLASH_WAIT_TIME > postimport_ticks:
if not biometric_attempted and preimport_ticks + MIN_SPLASH_WAIT_TIME > postimport_ticks:
time.sleep_ms(preimport_ticks + MIN_SPLASH_WAIT_TIME - postimport_ticks)

if not tc_code_verification(ctx):
Expand Down
30 changes: 14 additions & 16 deletions src/krux/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,25 +232,23 @@ def qr_data_width(self):

def to_landscape(self):
"""Changes the rotation of the display to landscape"""
if self.portrait:
lcd.rotation(
(LANDSCAPE + 2) % 4
if hasattr(Settings().hardware, "display")
and getattr(Settings().hardware.display, "flipped_orientation", False)
else LANDSCAPE
)
self.portrait = False
lcd.rotation(
(LANDSCAPE + 2) % 4
if hasattr(Settings().hardware, "display")
and getattr(Settings().hardware.display, "flipped_orientation", False)
else LANDSCAPE
)
self.portrait = False

def to_portrait(self):
"""Changes the rotation of the display to portrait"""
if not self.portrait:
lcd.rotation(
(PORTRAIT + 2) % 4
if hasattr(Settings().hardware, "display")
and getattr(Settings().hardware.display, "flipped_orientation", False)
else PORTRAIT
)
self.portrait = True
lcd.rotation(
(PORTRAIT + 2) % 4
if hasattr(Settings().hardware, "display")
and getattr(Settings().hardware.display, "flipped_orientation", False)
else PORTRAIT
)
self.portrait = True

def _usable_pixels_in_line(self):
"""Returns qtd of usable pixels in a line"""
Expand Down
Loading