1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 06:18:07 +00:00
trezor-firmware/mocks/trezor/ui/display.py

117 lines
4.3 KiB
Python
Raw Normal View History

2016-09-27 14:48:21 +00:00
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
2016-10-03 13:47:54 +00:00
def clear() -> None
'''
Clear display (with black color)
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
2016-10-03 13:47:54 +00:00
def refresh() -> None
'''
Refresh display (update screen)
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
2016-10-07 11:27:43 +00:00
def bar(x: int, y: int, w: int, h: int, color: int) -> None:
2016-09-27 14:48:21 +00:00
'''
2016-10-07 11:27:43 +00:00
Renders a bar at position (x,y = upper left corner) with width w and height h of color color.
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
2016-10-07 11:27:43 +00:00
def bar_radius(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.
2016-09-27 14:48:21 +00:00
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
2016-09-27 14:48:21 +00:00
def image(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.
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
2016-09-27 14:48:21 +00:00
def icon(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 image needs to be in TREZOR Optimized Image Format (TOIF) - gray-scale mode.
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
2017-06-12 16:02:32 +00:00
def print(text: str) -> None:
2017-04-08 16:43:26 +00:00
'''
Renders text using 5x8 bitmap font (using special text mode)
'''
# extmod/modtrezorui/modtrezorui-display.h
def text(x: int, y: int, text: str, font: int, fgcolor: int, bgcolor: int) -> None:
2016-09-27 14:48:21 +00:00
'''
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.
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
def text_center(x: int, y: int, text: str, font: int, fgcolor: int, bgcolor: int) -> None:
2016-09-27 14:48:21 +00:00
'''
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.
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
def text_right(x: int, y: int, text: str, font: int, fgcolor: int, bgcolor: int) -> None:
2016-09-27 14:48:21 +00:00
'''
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.
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
def text_width(text: str, font: int) -> int:
2016-09-27 14:48:21 +00:00
'''
Returns a width of text in pixels. Font font is used for rendering.
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
2016-09-27 14:48:21 +00:00
def qrcode(x: int, y: int, data: bytes, scale: int) -> None:
'''
2017-04-08 16:43:26 +00:00
Renders data encoded as a QR code centered at position (x,y).
2016-09-27 14:48:21 +00:00
Scale determines a zoom factor.
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
def loader(progress: int, yoffset: int, fgcolor: int, bgcolor: int, icon: bytes=None, iconfgcolor: int=None) -> None:
2016-09-27 14:48:21 +00:00
'''
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.
2016-09-27 14:48:21 +00:00
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
2016-09-27 14:48:21 +00:00
def orientation(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.
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
2016-09-27 14:48:21 +00:00
def backlight(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.
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
def offset(xy: tuple=None) -> tuple:
'''
Sets offset (x, y) for all subsequent drawing calls.
Call without the xy parameter to just perform the read of the value.
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorui/modtrezorui-display.h
2016-10-07 11:27:43 +00:00
def save(filename: string) -> None:
'''
Saves current display contents to file filename.
'''