1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-14 03:30:02 +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
2016-10-03 13:47:54 +00:00
# ../extmod/modtrezorui/modtrezorui-display.h
def clear() -> None
'''
Clear display (with black color)
'''
# ../extmod/modtrezorui/modtrezorui-display.h
def refresh() -> None
'''
Refresh display (update screen)
'''
2016-09-27 14:48:21 +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.
'''
# ../extmod/modtrezorui/modtrezorui-display.h
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
'''
# ../extmod/modtrezorui/modtrezorui-display.h
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.
'''
# ../extmod/modtrezorui/modtrezorui-display.h
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.
'''
# ../extmod/modtrezorui/modtrezorui-display.h
def text(x: int, y: int, text: bytes, font: int, fgcolor: int, bgcolor: int) -> None:
'''
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.
'''
# ../extmod/modtrezorui/modtrezorui-display.h
def text_center(x: int, y: int, text: bytes, font: int, fgcolor: int, bgcolor: int) -> None:
'''
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.
'''
# ../extmod/modtrezorui/modtrezorui-display.h
def text_right(x: int, y: int, text: bytes, font: int, fgcolor: int, bgcolor: int) -> None:
'''
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.
'''
# ../extmod/modtrezorui/modtrezorui-display.h
def text_width(text: bytes, font: int) -> int:
'''
Returns a width of text in pixels. Font font is used for rendering.
'''
# ../extmod/modtrezorui/modtrezorui-display.h
def qrcode(x: int, y: int, data: bytes, scale: int) -> None:
'''
Renders data encoded as a QR code at position (x,y).
Scale determines a zoom factor.
'''
# ../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
'''
# ../extmod/modtrezorui/modtrezorui-display.h
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.
'''
# ../extmod/modtrezorui/modtrezorui-display.h
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.
'''
# ../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.
'''
2016-09-27 14:48:21 +00:00
# ../extmod/modtrezorui/modtrezorui-display.h
2016-10-18 12:32:37 +00:00
def raw(reg: int, data: bytes=None) -> None:
2016-09-27 14:48:21 +00:00
'''
Performs a raw command on the display. Read the datasheet to learn more.
'''
2016-10-07 11:27:43 +00:00
# ../extmod/modtrezorui/modtrezorui-display.h
def save(filename: string) -> None:
'''
Saves current display contents to file filename.
'''