2018-02-26 13:06:10 +00:00
|
|
|
/*
|
2019-06-17 18:27:55 +00:00
|
|
|
* This file is part of the Trezor project, https://trezor.io/
|
2018-02-26 13:06:10 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) SatoshiLabs
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2017-12-17 00:09:45 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "bootui.h"
|
2021-03-04 15:33:05 +00:00
|
|
|
#include "display.h"
|
2018-01-24 13:15:43 +00:00
|
|
|
#include "icon_cancel.h"
|
|
|
|
#include "icon_confirm.h"
|
2017-12-17 00:09:45 +00:00
|
|
|
#include "icon_done.h"
|
|
|
|
#include "icon_fail.h"
|
2019-03-29 15:26:02 +00:00
|
|
|
#include "icon_info.h"
|
2017-12-17 00:09:45 +00:00
|
|
|
#include "icon_install.h"
|
2018-01-24 17:28:10 +00:00
|
|
|
#include "icon_logo.h"
|
|
|
|
#include "icon_safeplace.h"
|
|
|
|
#include "icon_welcome.h"
|
2021-03-04 15:33:05 +00:00
|
|
|
#include "icon_wipe.h"
|
|
|
|
#include "mini_printf.h"
|
|
|
|
#include "touch.h"
|
|
|
|
#include "version.h"
|
|
|
|
|
2017-12-17 00:09:45 +00:00
|
|
|
#define BACKLIGHT_NORMAL 150
|
|
|
|
|
2021-03-10 16:54:30 +00:00
|
|
|
#define COLOR_BL_BG COLOR_WHITE // background
|
|
|
|
#define COLOR_BL_FG COLOR_BLACK // foreground
|
2019-03-29 15:26:02 +00:00
|
|
|
#define COLOR_BL_FAIL RGB16(0xFF, 0x00, 0x00) // red
|
|
|
|
#define COLOR_BL_DONE RGB16(0x00, 0xAE, 0x0B) // green
|
|
|
|
#define COLOR_BL_PROCESS RGB16(0x4A, 0x90, 0xE2) // blue
|
|
|
|
#define COLOR_BL_GRAY RGB16(0x99, 0x99, 0x99) // gray
|
2017-12-17 00:09:45 +00:00
|
|
|
|
2021-03-10 16:54:30 +00:00
|
|
|
#define COLOR_WELCOME_BG COLOR_WHITE // welcome background
|
|
|
|
#define COLOR_WELCOME_FG COLOR_BLACK // welcome foreground
|
|
|
|
|
2018-01-26 15:05:45 +00:00
|
|
|
// common shared functions
|
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
static void ui_confirm_cancel_buttons(void) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_bar_radius(9, 184, 108, 50, COLOR_BL_FAIL, COLOR_BL_BG, 4);
|
2019-03-29 15:26:02 +00:00
|
|
|
display_icon(9 + (108 - 16) / 2, 184 + (50 - 16) / 2, 16, 16,
|
2021-03-10 16:54:30 +00:00
|
|
|
toi_icon_cancel + 12, sizeof(toi_icon_cancel) - 12, COLOR_BL_BG,
|
2019-03-29 15:26:02 +00:00
|
|
|
COLOR_BL_FAIL);
|
2021-03-10 16:54:30 +00:00
|
|
|
display_bar_radius(123, 184, 108, 50, COLOR_BL_DONE, COLOR_BL_BG, 4);
|
2019-03-29 15:26:02 +00:00
|
|
|
display_icon(123 + (108 - 19) / 2, 184 + (50 - 16) / 2, 20, 16,
|
|
|
|
toi_icon_confirm + 12, sizeof(toi_icon_confirm) - 12,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_BL_BG, COLOR_BL_DONE);
|
2018-01-26 15:05:45 +00:00
|
|
|
}
|
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
static const char *format_ver(const char *format, uint32_t version) {
|
|
|
|
static char ver_str[64];
|
|
|
|
mini_snprintf(ver_str, sizeof(ver_str), format, (int)(version & 0xFF),
|
|
|
|
(int)((version >> 8) & 0xFF), (int)((version >> 16) & 0xFF)
|
|
|
|
// ignore build field (int)((version >> 24) & 0xFF)
|
|
|
|
);
|
|
|
|
return ver_str;
|
2018-01-26 15:05:45 +00:00
|
|
|
}
|
|
|
|
|
2017-12-17 00:09:45 +00:00
|
|
|
// boot UI
|
|
|
|
|
2018-01-28 12:47:03 +00:00
|
|
|
static uint16_t boot_background;
|
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
void ui_screen_boot(const vendor_header *const vhdr,
|
|
|
|
const image_header *const hdr) {
|
|
|
|
const int show_string = ((vhdr->vtrust & VTRUST_STRING) == 0);
|
|
|
|
if ((vhdr->vtrust & VTRUST_RED) == 0) {
|
2021-03-10 16:54:30 +00:00
|
|
|
boot_background = RGB16(0xFF, 0x00, 0x00); // red
|
2019-03-29 15:26:02 +00:00
|
|
|
} else {
|
|
|
|
boot_background = COLOR_BLACK;
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint8_t *vimg = vhdr->vimg;
|
|
|
|
const uint32_t fw_version = hdr->version;
|
|
|
|
|
|
|
|
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, boot_background);
|
|
|
|
|
|
|
|
int image_top = show_string ? 30 : (DISPLAY_RESY - 120) / 2;
|
|
|
|
|
|
|
|
// check whether vendor image is 120x120
|
|
|
|
if (memcmp(vimg, "TOIf\x78\x00\x78\x00", 4) == 0) {
|
|
|
|
uint32_t datalen = *(uint32_t *)(vimg + 8);
|
|
|
|
display_image((DISPLAY_RESX - 120) / 2, image_top, 120, 120, vimg + 12,
|
|
|
|
datalen);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (show_string) {
|
|
|
|
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5 - 50, vhdr->vstr,
|
2021-03-10 16:54:30 +00:00
|
|
|
vhdr->vstr_len, FONT_NORMAL, COLOR_BL_BG,
|
2019-03-29 15:26:02 +00:00
|
|
|
boot_background);
|
|
|
|
const char *ver_str = format_ver("%d.%d.%d", fw_version);
|
|
|
|
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5 - 25, ver_str, -1,
|
2021-03-10 16:54:30 +00:00
|
|
|
FONT_NORMAL, COLOR_BL_BG, boot_background);
|
2019-03-29 15:26:02 +00:00
|
|
|
}
|
2017-12-17 00:09:45 +00:00
|
|
|
}
|
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
void ui_screen_boot_wait(int wait_seconds) {
|
|
|
|
char wait_str[16];
|
|
|
|
mini_snprintf(wait_str, sizeof(wait_str), "starting in %d s", wait_seconds);
|
|
|
|
display_bar(0, DISPLAY_RESY - 5 - 20, DISPLAY_RESX, 5 + 20, boot_background);
|
|
|
|
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5, wait_str, -1,
|
2021-03-10 16:54:30 +00:00
|
|
|
FONT_NORMAL, COLOR_BL_BG, boot_background);
|
2017-12-17 00:09:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ui_screen_boot_click(void) {
|
2019-03-29 15:26:02 +00:00
|
|
|
display_bar(0, DISPLAY_RESY - 5 - 20, DISPLAY_RESX, 5 + 20, boot_background);
|
|
|
|
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5,
|
2021-03-10 16:54:30 +00:00
|
|
|
"click to continue ...", -1, FONT_NORMAL, COLOR_BL_BG,
|
2019-03-29 15:26:02 +00:00
|
|
|
boot_background);
|
2017-12-17 00:09:45 +00:00
|
|
|
}
|
|
|
|
|
2018-01-25 13:16:21 +00:00
|
|
|
// welcome UI
|
2017-12-17 00:09:45 +00:00
|
|
|
|
2021-03-04 15:33:05 +00:00
|
|
|
void ui_screen_welcome_first(void) {
|
2019-03-29 15:26:02 +00:00
|
|
|
display_icon(0, 0, 240, 240, toi_icon_logo + 12, sizeof(toi_icon_logo) - 12,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_WELCOME_FG, COLOR_WELCOME_BG);
|
2018-01-24 17:28:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-04 15:33:05 +00:00
|
|
|
void ui_screen_welcome_second(void) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_WELCOME_BG);
|
2019-03-29 15:26:02 +00:00
|
|
|
display_icon((DISPLAY_RESX - 200) / 2, (DISPLAY_RESY - 60) / 2, 200, 60,
|
|
|
|
toi_icon_safeplace + 12, sizeof(toi_icon_safeplace) - 12,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_WELCOME_FG, COLOR_WELCOME_BG);
|
2018-01-24 17:28:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-04 15:33:05 +00:00
|
|
|
void ui_screen_welcome_third(void) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_WELCOME_BG);
|
2019-03-29 15:26:02 +00:00
|
|
|
display_icon((DISPLAY_RESX - 180) / 2, (DISPLAY_RESY - 30) / 2 - 5, 180, 30,
|
|
|
|
toi_icon_welcome + 12, sizeof(toi_icon_welcome) - 12,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_WELCOME_FG, COLOR_WELCOME_BG);
|
2019-03-29 15:26:02 +00:00
|
|
|
display_text_center(120, 220, "Go to trezor.io/start", -1, FONT_NORMAL,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_WELCOME_FG, COLOR_WELCOME_BG);
|
2018-01-24 17:28:10 +00:00
|
|
|
}
|
|
|
|
|
2018-01-25 13:16:21 +00:00
|
|
|
// info UI
|
|
|
|
|
2020-02-19 20:42:37 +00:00
|
|
|
static int display_vendor_string(const char *text, int textlen,
|
|
|
|
uint16_t fgcolor) {
|
|
|
|
int split = display_text_split(text, textlen, FONT_NORMAL, DISPLAY_RESX - 55);
|
|
|
|
if (split >= textlen) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_text(55, 95, text, textlen, FONT_NORMAL, fgcolor, COLOR_BL_BG);
|
2020-02-19 20:42:37 +00:00
|
|
|
return 120;
|
|
|
|
} else {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_text(55, 95, text, split, FONT_NORMAL, fgcolor, COLOR_BL_BG);
|
2020-02-19 20:42:37 +00:00
|
|
|
if (text[split] == ' ') {
|
|
|
|
split++;
|
|
|
|
}
|
|
|
|
display_text(55, 120, text + split, textlen - split, FONT_NORMAL, fgcolor,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_BL_BG);
|
2020-02-19 20:42:37 +00:00
|
|
|
return 145;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-10 16:18:50 +00:00
|
|
|
void ui_screen_firmware_info(const vendor_header *const vhdr,
|
|
|
|
const image_header *const hdr) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_BL_BG);
|
2019-03-29 15:26:02 +00:00
|
|
|
const char *ver_str = format_ver("Bootloader %d.%d.%d", VERSION_UINT32);
|
2021-03-10 16:54:30 +00:00
|
|
|
display_text(16, 32, ver_str, -1, FONT_NORMAL, COLOR_BL_FG, COLOR_BL_BG);
|
|
|
|
display_bar(16, 44, DISPLAY_RESX - 14 * 2, 1, COLOR_BL_FG);
|
2019-03-29 15:26:02 +00:00
|
|
|
display_icon(16, 54, 32, 32, toi_icon_info + 12, sizeof(toi_icon_info) - 12,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_BL_GRAY, COLOR_BL_BG);
|
2019-03-29 15:26:02 +00:00
|
|
|
if (vhdr && hdr) {
|
2020-02-19 20:42:37 +00:00
|
|
|
ver_str = format_ver("Firmware %d.%d.%d by", (hdr->version));
|
2021-03-10 16:54:30 +00:00
|
|
|
display_text(55, 70, ver_str, -1, FONT_NORMAL, COLOR_BL_GRAY, COLOR_BL_BG);
|
2020-02-19 20:42:37 +00:00
|
|
|
display_vendor_string(vhdr->vstr, vhdr->vstr_len, COLOR_BL_GRAY);
|
2019-03-29 15:26:02 +00:00
|
|
|
} else {
|
|
|
|
display_text(55, 70, "No Firmware", -1, FONT_NORMAL, COLOR_BL_GRAY,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_BL_BG);
|
2019-03-29 15:26:02 +00:00
|
|
|
}
|
2021-03-10 16:18:50 +00:00
|
|
|
display_text_center(120, 220, "Go to trezor.io/start", -1, FONT_NORMAL,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_BL_FG, COLOR_BL_BG);
|
2017-12-17 00:09:45 +00:00
|
|
|
}
|
|
|
|
|
2021-03-10 16:18:50 +00:00
|
|
|
void ui_screen_firmware_fingerprint(const image_header *const hdr) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_BL_BG);
|
|
|
|
display_text(16, 32, "Firmware fingerprint", -1, FONT_NORMAL, COLOR_BL_FG,
|
|
|
|
COLOR_BL_BG);
|
|
|
|
display_bar(16, 44, DISPLAY_RESX - 14 * 2, 1, COLOR_BL_FG);
|
2019-03-29 15:26:02 +00:00
|
|
|
|
|
|
|
static const char *hexdigits = "0123456789abcdef";
|
|
|
|
char fingerprint_str[64];
|
|
|
|
for (int i = 0; i < 32; i++) {
|
|
|
|
fingerprint_str[i * 2] = hexdigits[(hdr->fingerprint[i] >> 4) & 0xF];
|
|
|
|
fingerprint_str[i * 2 + 1] = hexdigits[hdr->fingerprint[i] & 0xF];
|
|
|
|
}
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
display_text_center(120, 70 + i * 25, fingerprint_str + i * 16, 16,
|
2021-03-10 16:54:30 +00:00
|
|
|
FONT_MONO, COLOR_BL_FG, COLOR_BL_BG);
|
2019-03-29 15:26:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-10 16:54:30 +00:00
|
|
|
display_bar_radius(9, 184, 222, 50, COLOR_BL_DONE, COLOR_BL_BG, 4);
|
2019-03-29 15:26:02 +00:00
|
|
|
display_icon(9 + (222 - 19) / 2, 184 + (50 - 16) / 2, 20, 16,
|
|
|
|
toi_icon_confirm + 12, sizeof(toi_icon_confirm) - 12,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_BL_BG, COLOR_BL_DONE);
|
2018-01-25 13:16:21 +00:00
|
|
|
}
|
|
|
|
|
2017-12-17 00:09:45 +00:00
|
|
|
// install UI
|
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
void ui_screen_install_confirm_upgrade(const vendor_header *const vhdr,
|
|
|
|
const image_header *const hdr) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_BL_BG);
|
|
|
|
display_text(16, 32, "Firmware update", -1, FONT_NORMAL, COLOR_BL_FG,
|
|
|
|
COLOR_BL_BG);
|
|
|
|
display_bar(16, 44, DISPLAY_RESX - 14 * 2, 1, COLOR_BL_FG);
|
2019-03-29 15:26:02 +00:00
|
|
|
display_icon(16, 54, 32, 32, toi_icon_info + 12, sizeof(toi_icon_info) - 12,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_BL_FG, COLOR_BL_BG);
|
|
|
|
display_text(55, 70, "Update firmware by", -1, FONT_NORMAL, COLOR_BL_FG,
|
|
|
|
COLOR_BL_BG);
|
|
|
|
int next_y = display_vendor_string(vhdr->vstr, vhdr->vstr_len, COLOR_BL_FG);
|
2019-03-29 15:26:02 +00:00
|
|
|
const char *ver_str = format_ver("to version %d.%d.%d?", hdr->version);
|
2021-03-10 16:54:30 +00:00
|
|
|
display_text(55, next_y, ver_str, -1, FONT_NORMAL, COLOR_BL_FG, COLOR_BL_BG);
|
2019-03-29 15:26:02 +00:00
|
|
|
ui_confirm_cancel_buttons();
|
2018-01-26 13:55:01 +00:00
|
|
|
}
|
2018-01-24 16:00:25 +00:00
|
|
|
|
2020-03-24 17:53:08 +00:00
|
|
|
void ui_screen_install_confirm_newvendor_or_downgrade_wipe(
|
|
|
|
const vendor_header *const vhdr, const image_header *const hdr,
|
|
|
|
secbool downgrade_wipe) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_BL_BG);
|
2020-03-24 17:53:08 +00:00
|
|
|
display_text(
|
|
|
|
16, 32,
|
|
|
|
(sectrue == downgrade_wipe) ? "Firmware downgrade" : "Vendor change", -1,
|
2021-03-10 16:54:30 +00:00
|
|
|
FONT_NORMAL, COLOR_BL_FG, COLOR_BL_BG);
|
|
|
|
display_bar(16, 44, DISPLAY_RESX - 14 * 2, 1, COLOR_BL_FG);
|
2019-03-29 15:26:02 +00:00
|
|
|
display_icon(16, 54, 32, 32, toi_icon_info + 12, sizeof(toi_icon_info) - 12,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_BL_FG, COLOR_BL_BG);
|
|
|
|
display_text(55, 70, "Install firmware by", -1, FONT_NORMAL, COLOR_BL_FG,
|
|
|
|
COLOR_BL_BG);
|
|
|
|
int next_y = display_vendor_string(vhdr->vstr, vhdr->vstr_len, COLOR_BL_FG);
|
2019-03-29 15:26:02 +00:00
|
|
|
const char *ver_str = format_ver("(version %d.%d.%d)?", hdr->version);
|
2021-03-10 16:54:30 +00:00
|
|
|
display_text(55, next_y, ver_str, -1, FONT_NORMAL, COLOR_BL_FG, COLOR_BL_BG);
|
2019-03-29 15:26:02 +00:00
|
|
|
display_text_center(120, 170, "Seed will be erased!", -1, FONT_NORMAL,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_BL_FAIL, COLOR_BL_BG);
|
2019-03-29 15:26:02 +00:00
|
|
|
ui_confirm_cancel_buttons();
|
2018-01-24 16:00:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-04 15:33:05 +00:00
|
|
|
void ui_screen_install_start(void) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_BL_BG);
|
|
|
|
display_loader(0, false, -20, COLOR_BL_PROCESS, COLOR_BL_BG, toi_icon_install,
|
|
|
|
sizeof(toi_icon_install), COLOR_BL_FG);
|
2019-03-29 15:26:02 +00:00
|
|
|
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24,
|
2021-03-10 16:54:30 +00:00
|
|
|
"Installing firmware", -1, FONT_NORMAL, COLOR_BL_FG,
|
|
|
|
COLOR_BL_BG);
|
2017-12-17 00:09:45 +00:00
|
|
|
}
|
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
void ui_screen_install_progress_erase(int pos, int len) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_loader(250 * pos / len, false, -20, COLOR_BL_PROCESS, COLOR_BL_BG,
|
|
|
|
toi_icon_install, sizeof(toi_icon_install), COLOR_BL_FG);
|
2017-12-17 00:09:45 +00:00
|
|
|
}
|
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
void ui_screen_install_progress_upload(int pos) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_loader(pos, false, -20, COLOR_BL_PROCESS, COLOR_BL_BG,
|
|
|
|
toi_icon_install, sizeof(toi_icon_install), COLOR_BL_FG);
|
2017-12-17 00:09:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// wipe UI
|
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
void ui_screen_wipe_confirm(void) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_BL_BG);
|
|
|
|
display_text(16, 32, "Wipe device", -1, FONT_NORMAL, COLOR_BL_FG,
|
|
|
|
COLOR_BL_BG);
|
|
|
|
display_bar(16, 44, DISPLAY_RESX - 14 * 2, 1, COLOR_BL_FG);
|
2019-03-29 15:26:02 +00:00
|
|
|
display_icon(16, 54, 32, 32, toi_icon_info + 12, sizeof(toi_icon_info) - 12,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_BL_FG, COLOR_BL_BG);
|
|
|
|
display_text(55, 70, "Do you want to", -1, FONT_NORMAL, COLOR_BL_FG,
|
|
|
|
COLOR_BL_BG);
|
|
|
|
display_text(55, 95, "wipe the device?", -1, FONT_NORMAL, COLOR_BL_FG,
|
|
|
|
COLOR_BL_BG);
|
2019-03-29 15:26:02 +00:00
|
|
|
|
|
|
|
display_text_center(120, 170, "Seed will be erased!", -1, FONT_NORMAL,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_BL_FAIL, COLOR_BL_BG);
|
2019-03-29 15:26:02 +00:00
|
|
|
ui_confirm_cancel_buttons();
|
2018-01-24 16:00:25 +00:00
|
|
|
}
|
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
void ui_screen_wipe(void) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_BL_BG);
|
|
|
|
display_loader(0, false, -20, COLOR_BL_PROCESS, COLOR_BL_BG, toi_icon_wipe,
|
|
|
|
sizeof(toi_icon_wipe), COLOR_BL_FG);
|
2019-03-29 15:26:02 +00:00
|
|
|
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24, "Wiping device", -1,
|
2021-03-10 16:54:30 +00:00
|
|
|
FONT_NORMAL, COLOR_BL_FG, COLOR_BL_BG);
|
2017-12-17 00:09:45 +00:00
|
|
|
}
|
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
void ui_screen_wipe_progress(int pos, int len) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_loader(1000 * pos / len, false, -20, COLOR_BL_PROCESS, COLOR_BL_BG,
|
|
|
|
toi_icon_wipe, sizeof(toi_icon_wipe), COLOR_BL_FG);
|
2017-12-17 00:09:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// done UI
|
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
void ui_screen_done(int restart_seconds, secbool full_redraw) {
|
|
|
|
const char *str;
|
|
|
|
char count_str[24];
|
|
|
|
if (restart_seconds >= 1) {
|
|
|
|
mini_snprintf(count_str, sizeof(count_str), "Done! Restarting in %d s",
|
|
|
|
restart_seconds);
|
|
|
|
str = count_str;
|
|
|
|
} else {
|
|
|
|
str = "Done! Unplug the device.";
|
|
|
|
}
|
|
|
|
if (sectrue == full_redraw) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_BL_BG);
|
2019-03-29 15:26:02 +00:00
|
|
|
}
|
2021-03-10 16:54:30 +00:00
|
|
|
display_loader(1000, false, -20, COLOR_BL_DONE, COLOR_BL_BG, toi_icon_done,
|
|
|
|
sizeof(toi_icon_done), COLOR_BL_FG);
|
2019-03-29 15:26:02 +00:00
|
|
|
if (secfalse == full_redraw) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_bar(0, DISPLAY_RESY - 24 - 18, 240, 23, COLOR_BL_BG);
|
2019-03-29 15:26:02 +00:00
|
|
|
}
|
|
|
|
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24, str, -1, FONT_NORMAL,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_BL_FG, COLOR_BL_BG);
|
2017-12-17 00:09:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// error UI
|
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
void ui_screen_fail(void) {
|
2021-03-10 16:54:30 +00:00
|
|
|
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_BL_BG);
|
|
|
|
display_loader(1000, false, -20, COLOR_BL_FAIL, COLOR_BL_BG, toi_icon_fail,
|
|
|
|
sizeof(toi_icon_fail), COLOR_BL_FG);
|
2019-03-29 15:26:02 +00:00
|
|
|
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24,
|
|
|
|
"Failed! Please, reconnect.", -1, FONT_NORMAL,
|
2021-03-10 16:54:30 +00:00
|
|
|
COLOR_BL_FG, COLOR_BL_BG);
|
2017-12-17 00:09:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// general functions
|
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
void ui_fadein(void) { display_fade(0, BACKLIGHT_NORMAL, 1000); }
|
2017-12-17 00:09:45 +00:00
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
void ui_fadeout(void) {
|
|
|
|
display_fade(BACKLIGHT_NORMAL, 0, 500);
|
|
|
|
display_clear();
|
2017-12-17 00:09:45 +00:00
|
|
|
}
|
2018-01-24 16:00:25 +00:00
|
|
|
|
2019-03-29 15:26:02 +00:00
|
|
|
int ui_user_input(int zones) {
|
|
|
|
for (;;) {
|
|
|
|
uint32_t evt = touch_click();
|
|
|
|
uint16_t x = touch_unpack_x(evt);
|
|
|
|
uint16_t y = touch_unpack_y(evt);
|
|
|
|
// clicked on Cancel button
|
|
|
|
if ((zones & INPUT_CANCEL) && x >= 9 && x < 9 + 108 && y > 184 &&
|
|
|
|
y < 184 + 50) {
|
|
|
|
return INPUT_CANCEL;
|
|
|
|
}
|
|
|
|
// clicked on Confirm button
|
|
|
|
if ((zones & INPUT_CONFIRM) && x >= 123 && x < 123 + 108 && y > 184 &&
|
|
|
|
y < 184 + 50) {
|
|
|
|
return INPUT_CONFIRM;
|
|
|
|
}
|
|
|
|
// clicked on Long Confirm button
|
|
|
|
if ((zones & INPUT_LONG_CONFIRM) && x >= 9 && x < 9 + 222 && y > 184 &&
|
|
|
|
y < 184 + 50) {
|
|
|
|
return INPUT_LONG_CONFIRM;
|
|
|
|
}
|
|
|
|
// clicked on Info icon
|
|
|
|
if ((zones & INPUT_INFO) && x >= 16 && x < 16 + 32 && y > 54 &&
|
|
|
|
y < 54 + 32) {
|
|
|
|
return INPUT_INFO;
|
2018-01-24 16:00:25 +00:00
|
|
|
}
|
2019-03-29 15:26:02 +00:00
|
|
|
}
|
2018-01-26 15:05:45 +00:00
|
|
|
}
|