mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-27 01:48:17 +00:00
482b4569f5
Squashed commit of the following: commit 84d3486f59bda063f06521c8b695ea4b07781ec6 Author: matejcik <ja@matejcik.cz> Date: Fri May 17 14:17:15 2019 +0200 mocks: complete commit d538133a6d0fb4af06c7c81f80b8675869fb5908 Author: matejcik <ja@matejcik.cz> Date: Fri May 17 14:12:26 2019 +0200 mocks part 3 commit 9f0b868d41dafaf487df6fc844db7f3368eabe1b Author: matejcik <ja@matejcik.cz> Date: Fri May 17 14:09:20 2019 +0200 mocks: update generated mocks commit 5d80c18a7824ed16fc11cde4cdb8ebca7ed33400 Author: matejcik <ja@matejcik.cz> Date: Thu May 16 15:49:40 2019 +0200 mocks wip 2 commit 4b576eb796136a61eb88cb0d281fa4e21eadada8 Author: matejcik <ja@matejcik.cz> Date: Tue May 7 17:02:51 2019 +0200 WIP mocks part 1 commit cf3f0d4471ab74b478d2970b0bb178feae7c86a3 Author: matejcik <ja@matejcik.cz> Date: Fri May 3 17:07:53 2019 +0200 core: add package to secp256k1_zkp for mocking commit 8a12f26c8c0d99363c8df96012426abbbb3ff6cb Author: matejcik <ja@matejcik.cz> Date: Fri May 3 17:04:05 2019 +0200 core: blackify extmod docstring quotes commit b6f239676dde8b60b001fcae4e5de80a71dbacf2 Author: matejcik <ja@matejcik.cz> Date: Fri May 3 16:52:27 2019 +0200 core: make build_mocks directory agnostic mocks: detect bad packages mocks: revert noqa in favor of setup.cfg mocks: fix broken comment formatting
183 lines
5.4 KiB
Python
183 lines
5.4 KiB
Python
from typing import *
|
|
|
|
|
|
# extmod/modtrezorui/modtrezorui-display.h
|
|
class Display:
|
|
"""
|
|
Provide access to device display.
|
|
"""
|
|
|
|
def __init__(self) -> None:
|
|
"""
|
|
Initialize the display.
|
|
"""
|
|
|
|
def clear(self) -> None:
|
|
"""
|
|
Clear display with black color.
|
|
"""
|
|
|
|
def refresh(self) -> None:
|
|
"""
|
|
Refresh display (update screen).
|
|
"""
|
|
|
|
def bar(self, x: int, y: int, w: int, h: int, color: int) -> None:
|
|
"""
|
|
Renders a bar at position (x,y = upper left corner) with width w and
|
|
height h of color color.
|
|
"""
|
|
|
|
def bar_radius(
|
|
self,
|
|
x: int,
|
|
y: int,
|
|
w: int,
|
|
h: int,
|
|
fgcolor: int,
|
|
bgcolor: int = None,
|
|
radius: int = None,
|
|
) -> None:
|
|
"""
|
|
Renders a rounded bar at position (x,y = upper left corner) with width w
|
|
and height h of color fgcolor. Background is set to bgcolor and corners
|
|
are drawn with radius radius.
|
|
"""
|
|
|
|
def image(self, x: int, y: int, image: bytes) -> None:
|
|
"""
|
|
Renders an image at position (x,y).
|
|
The image needs to be in TREZOR Optimized Image Format (TOIF) -
|
|
full-color mode.
|
|
"""
|
|
|
|
def avatar(
|
|
self, x: int, y: int, image: bytes, fgcolor: int, bgcolor: int
|
|
) -> None:
|
|
"""
|
|
Renders an avatar at position (x,y).
|
|
The image needs to be in TREZOR Optimized Image Format (TOIF) -
|
|
full-color mode. Image needs to be of exactly AVATAR_IMAGE_SIZE x
|
|
AVATAR_IMAGE_SIZE pixels size.
|
|
"""
|
|
|
|
def icon(
|
|
self, x: int, y: int, icon: bytes, fgcolor: int, bgcolor: int
|
|
) -> None:
|
|
"""
|
|
Renders an icon at position (x,y), fgcolor is used as foreground color,
|
|
bgcolor as background. The icon needs to be in TREZOR Optimized Image
|
|
Format (TOIF) - gray-scale mode.
|
|
"""
|
|
|
|
def loader(
|
|
self,
|
|
progress: int,
|
|
indeterminate: bool,
|
|
yoffset: int,
|
|
fgcolor: int,
|
|
bgcolor: int,
|
|
icon: bytes = None,
|
|
iconfgcolor: int = None,
|
|
) -> None:
|
|
"""
|
|
Renders a rotating loader graphic.
|
|
Progress determines its position (0-1000), fgcolor is used as foreground
|
|
color, bgcolor as background. When icon and iconfgcolor are provided, an
|
|
icon is drawn in the middle using the color specified in iconfgcolor.
|
|
Icon needs to be of exactly LOADER_ICON_SIZE x LOADER_ICON_SIZE pixels
|
|
size.
|
|
"""
|
|
|
|
def print(self, text: str) -> None:
|
|
"""
|
|
Renders text using 5x8 bitmap font (using special text mode).
|
|
"""
|
|
|
|
def text(
|
|
self,
|
|
x: int,
|
|
y: int,
|
|
text: str,
|
|
font: int,
|
|
fgcolor: int,
|
|
bgcolor: int,
|
|
minwidth: int = None,
|
|
) -> int:
|
|
"""
|
|
Renders left-aligned text at position (x,y) where x is left position and
|
|
y is baseline. Font font is used for rendering, fgcolor is used as
|
|
foreground color, bgcolor as background. Fills at least minwidth pixels
|
|
with bgcolor. Returns width of rendered text in pixels.
|
|
"""
|
|
|
|
def text_center(
|
|
self,
|
|
x: int,
|
|
y: int,
|
|
text: str,
|
|
font: int,
|
|
fgcolor: int,
|
|
bgcolor: int,
|
|
minwidth: int = None,
|
|
) -> int:
|
|
"""
|
|
Renders text centered at position (x,y) where x is text center and y is
|
|
baseline. Font font is used for rendering, fgcolor is used as foreground
|
|
color, bgcolor as background. Fills at least minwidth pixels with
|
|
bgcolor. Returns width of rendered text in pixels.
|
|
"""
|
|
|
|
def text_right(
|
|
self,
|
|
x: int,
|
|
y: int,
|
|
text: str,
|
|
font: int,
|
|
fgcolor: int,
|
|
bgcolor: int,
|
|
minwidth: int = None,
|
|
) -> int:
|
|
"""
|
|
Renders right-aligned text at position (x,y) where x is right position
|
|
and y is baseline. Font font is used for rendering, fgcolor is used as
|
|
foreground color, bgcolor as background. Fills at least minwidth pixels
|
|
with bgcolor. Returns width of rendered text in pixels.
|
|
"""
|
|
|
|
def text_width(self, text: str, font: int) -> int:
|
|
"""
|
|
Returns a width of text in pixels. Font font is used for rendering.
|
|
"""
|
|
|
|
def qrcode(self, x: int, y: int, data: bytes, scale: int) -> None:
|
|
"""
|
|
Renders data encoded as a QR code centered at position (x,y).
|
|
Scale determines a zoom factor.
|
|
"""
|
|
|
|
def orientation(self, degrees: int = None) -> int:
|
|
"""
|
|
Sets display orientation to 0, 90, 180 or 270 degrees.
|
|
Everything needs to be redrawn again when this function is used.
|
|
Call without the degrees parameter to just perform the read of the
|
|
value.
|
|
"""
|
|
|
|
def backlight(self, val: int = None) -> int:
|
|
"""
|
|
Sets backlight intensity to the value specified in val.
|
|
Call without the val parameter to just perform the read of the value.
|
|
"""
|
|
|
|
def offset(self, xy: Tuple[int, int] = None) -> Tuple[int, int]:
|
|
"""
|
|
Sets offset (x, y) for all subsequent drawing calls.
|
|
Call without the xy parameter to just perform the read of the value.
|
|
"""
|
|
|
|
def save(self, prefix: str) -> None:
|
|
"""
|
|
Saves current display contents to PNG file with given prefix.
|
|
"""
|