|
|
|
@ -9,10 +9,18 @@
|
|
|
|
|
|
|
|
|
|
#include "display.h"
|
|
|
|
|
|
|
|
|
|
/// class Display:
|
|
|
|
|
/// '''
|
|
|
|
|
/// Provide access to device display.
|
|
|
|
|
/// '''
|
|
|
|
|
typedef struct _mp_obj_Display_t {
|
|
|
|
|
mp_obj_base_t base;
|
|
|
|
|
} mp_obj_Display_t;
|
|
|
|
|
|
|
|
|
|
/// def __init__(self) -> None:
|
|
|
|
|
/// '''
|
|
|
|
|
/// Initialize the display.
|
|
|
|
|
/// '''
|
|
|
|
|
STATIC mp_obj_t mod_TrezorUI_Display_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
|
|
|
|
mp_arg_check_num(n_args, n_kw, 0, 0, false);
|
|
|
|
|
display_init();
|
|
|
|
@ -21,9 +29,9 @@ STATIC mp_obj_t mod_TrezorUI_Display_make_new(const mp_obj_type_t *type, size_t
|
|
|
|
|
return MP_OBJ_FROM_PTR(o);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.clear() -> None
|
|
|
|
|
/// def clear(self) -> None:
|
|
|
|
|
/// '''
|
|
|
|
|
/// Clear display (with black color)
|
|
|
|
|
/// Clear display with black color.
|
|
|
|
|
/// '''
|
|
|
|
|
STATIC mp_obj_t mod_TrezorUI_Display_clear(mp_obj_t self) {
|
|
|
|
|
display_clear();
|
|
|
|
@ -31,9 +39,9 @@ STATIC mp_obj_t mod_TrezorUI_Display_clear(mp_obj_t self) {
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorUI_Display_clear_obj, mod_TrezorUI_Display_clear);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.refresh() -> None
|
|
|
|
|
/// def refresh(self) -> None:
|
|
|
|
|
/// '''
|
|
|
|
|
/// Refresh display (update screen)
|
|
|
|
|
/// Refresh display (update screen).
|
|
|
|
|
/// '''
|
|
|
|
|
STATIC mp_obj_t mod_TrezorUI_Display_refresh(mp_obj_t self) {
|
|
|
|
|
display_refresh();
|
|
|
|
@ -41,7 +49,7 @@ STATIC mp_obj_t mod_TrezorUI_Display_refresh(mp_obj_t self) {
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorUI_Display_refresh_obj, mod_TrezorUI_Display_refresh);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.bar(x: int, y: int, w: int, h: int, color: int) -> None:
|
|
|
|
|
/// 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.
|
|
|
|
|
/// '''
|
|
|
|
@ -56,7 +64,7 @@ STATIC mp_obj_t mod_TrezorUI_Display_bar(size_t n_args, const mp_obj_t *args) {
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUI_Display_bar_obj, 6, 6, mod_TrezorUI_Display_bar);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.bar_radius(x: int, y: int, w: int, h: int, fgcolor: int, bgcolor: int=None, radius: int=None) -> None:
|
|
|
|
|
/// 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.
|
|
|
|
@ -74,7 +82,7 @@ STATIC mp_obj_t mod_TrezorUI_Display_bar_radius(size_t n_args, const mp_obj_t *a
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUI_Display_bar_radius_obj, 8, 8, mod_TrezorUI_Display_bar_radius);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.image(x: int, y: int, image: bytes) -> None:
|
|
|
|
|
/// 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.
|
|
|
|
@ -99,7 +107,7 @@ STATIC mp_obj_t mod_TrezorUI_Display_image(size_t n_args, const mp_obj_t *args)
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUI_Display_image_obj, 4, 4, mod_TrezorUI_Display_image);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.icon(x: int, y: int, icon: bytes, fgcolor: int, bgcolor: int) -> None:
|
|
|
|
|
/// 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 image needs to be in TREZOR Optimized Image Format (TOIF) - gray-scale mode.
|
|
|
|
@ -126,9 +134,9 @@ STATIC mp_obj_t mod_TrezorUI_Display_icon(size_t n_args, const mp_obj_t *args) {
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUI_Display_icon_obj, 6, 6, mod_TrezorUI_Display_icon);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.print(text: str) -> None:
|
|
|
|
|
/// def print(self, text: str) -> None:
|
|
|
|
|
/// '''
|
|
|
|
|
/// Renders text using 5x8 bitmap font (using special text mode)
|
|
|
|
|
/// Renders text using 5x8 bitmap font (using special text mode).
|
|
|
|
|
/// '''
|
|
|
|
|
STATIC mp_obj_t mod_TrezorUI_Display_print(mp_obj_t self, mp_obj_t text) {
|
|
|
|
|
mp_buffer_info_t buf;
|
|
|
|
@ -140,7 +148,7 @@ STATIC mp_obj_t mod_TrezorUI_Display_print(mp_obj_t self, mp_obj_t text) {
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorUI_Display_print_obj, mod_TrezorUI_Display_print);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.text(x: int, y: int, text: str, font: int, fgcolor: int, bgcolor: int) -> None:
|
|
|
|
|
/// def text(self, x: int, y: int, text: str, 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.
|
|
|
|
@ -160,7 +168,7 @@ STATIC mp_obj_t mod_TrezorUI_Display_text(size_t n_args, const mp_obj_t *args) {
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUI_Display_text_obj, 7, 7, mod_TrezorUI_Display_text);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.text_center(x: int, y: int, text: str, font: int, fgcolor: int, bgcolor: int) -> None:
|
|
|
|
|
/// def text_center(self, x: int, y: int, text: str, 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.
|
|
|
|
@ -180,7 +188,7 @@ STATIC mp_obj_t mod_TrezorUI_Display_text_center(size_t n_args, const mp_obj_t *
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUI_Display_text_center_obj, 7, 7, mod_TrezorUI_Display_text_center);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.text_right(x: int, y: int, text: str, font: int, fgcolor: int, bgcolor: int) -> None:
|
|
|
|
|
/// def text_right(self, x: int, y: int, text: str, 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.
|
|
|
|
@ -200,7 +208,7 @@ STATIC mp_obj_t mod_TrezorUI_Display_text_right(size_t n_args, const mp_obj_t *a
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUI_Display_text_right_obj, 7, 7, mod_TrezorUI_Display_text_right);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.text_width(text: str, font: int) -> int:
|
|
|
|
|
/// def text_width(self, text: str, font: int) -> int:
|
|
|
|
|
/// '''
|
|
|
|
|
/// Returns a width of text in pixels. Font font is used for rendering.
|
|
|
|
|
/// '''
|
|
|
|
@ -216,7 +224,7 @@ STATIC mp_obj_t mod_TrezorUI_Display_text_width(mp_obj_t self, mp_obj_t text, mp
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_TrezorUI_Display_text_width_obj, mod_TrezorUI_Display_text_width);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.qrcode(x: int, y: int, data: bytes, scale: int) -> None:
|
|
|
|
|
/// 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.
|
|
|
|
@ -237,7 +245,7 @@ STATIC mp_obj_t mod_TrezorUI_Display_qrcode(size_t n_args, const mp_obj_t *args)
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUI_Display_qrcode_obj, 5, 5, mod_TrezorUI_Display_qrcode);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.loader(progress: int, yoffset: int, fgcolor: int, bgcolor: int, icon: bytes=None, iconfgcolor: int=None) -> None:
|
|
|
|
|
/// def loader(self, progress: int, 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.
|
|
|
|
@ -279,7 +287,7 @@ STATIC mp_obj_t mod_TrezorUI_Display_loader(size_t n_args, const mp_obj_t *args)
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUI_Display_loader_obj, 5, 7, mod_TrezorUI_Display_loader);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.orientation(degrees: int=None) -> int:
|
|
|
|
|
/// 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.
|
|
|
|
@ -300,7 +308,7 @@ STATIC mp_obj_t mod_TrezorUI_Display_orientation(size_t n_args, const mp_obj_t *
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUI_Display_orientation_obj, 1, 2, mod_TrezorUI_Display_orientation);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.backlight(val: int=None) -> int:
|
|
|
|
|
/// 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.
|
|
|
|
@ -320,7 +328,7 @@ STATIC mp_obj_t mod_TrezorUI_Display_backlight(size_t n_args, const mp_obj_t *ar
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUI_Display_backlight_obj, 1, 2, mod_TrezorUI_Display_backlight);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.offset(xy: tuple=None) -> tuple:
|
|
|
|
|
/// 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.
|
|
|
|
@ -352,7 +360,7 @@ STATIC mp_obj_t mod_TrezorUI_Display_offset(size_t n_args, const mp_obj_t *args)
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUI_Display_offset_obj, 1, 2, mod_TrezorUI_Display_offset);
|
|
|
|
|
|
|
|
|
|
/// def trezor.ui.display.save(filename: string) -> None:
|
|
|
|
|
/// def save(self, filename: str) -> None:
|
|
|
|
|
/// '''
|
|
|
|
|
/// Saves current display contents to file filename.
|
|
|
|
|
/// '''
|
|
|
|
|