mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +00:00
core: dim lockscreen (fixes #974)
This commit is contained in:
parent
dab41fd680
commit
7ff1251ee1
@ -1,4 +1,4 @@
|
||||
from trezor import res, ui
|
||||
from trezor import loop, res, ui
|
||||
|
||||
from . import HomescreenBase
|
||||
|
||||
@ -33,6 +33,26 @@ class Lockscreen(HomescreenBase):
|
||||
)
|
||||
ui.display.icon(45, 202, res.load(ui.ICON_CLICK), ui.TITLE_GREY, ui.BG)
|
||||
|
||||
def handle_rendering(self) -> loop.Task: # type: ignore
|
||||
"""Task that is rendering the layout in a busy loop.
|
||||
|
||||
Copy-pasted from ui.Layout.handle_rendering with modification to set the
|
||||
backlight to a lower level while lockscreen is on, and a longer sleep because
|
||||
we never do any redrawing."""
|
||||
# Before the first render, we dim the display.
|
||||
ui.backlight_fade(ui.BACKLIGHT_DIM)
|
||||
# Clear the screen of any leftovers, make sure everything is marked for
|
||||
# repaint (we can be running the same layout instance multiple times)
|
||||
# and paint it.
|
||||
ui.display.clear()
|
||||
self.on_render()
|
||||
ui.refresh()
|
||||
ui.backlight_fade(ui.BACKLIGHT_LOW)
|
||||
# long sleep
|
||||
sleep = loop.sleep(1000 * 1000 * 1000)
|
||||
while True:
|
||||
yield sleep
|
||||
|
||||
def on_render(self) -> None:
|
||||
self.render_homescreen()
|
||||
self.render_lock()
|
||||
|
@ -7,6 +7,7 @@ RADIUS = const(2)
|
||||
|
||||
# backlight brightness
|
||||
BACKLIGHT_NORMAL = const(150)
|
||||
BACKLIGHT_LOW = const(70)
|
||||
BACKLIGHT_DIM = const(5)
|
||||
BACKLIGHT_NONE = const(2)
|
||||
BACKLIGHT_MAX = const(255)
|
||||
|
Loading…
Reference in New Issue
Block a user