__fatal_error(const char *expr, const char *msg, const char *file, int line_num, const char *func) { const BITMAP *icon = &bmp_icon_error; char line[128] = {0}; int y = icon->height + 3; oledClear(); oledDrawBitmap(0, 0, icon); oledDrawStringCenter(OLED_WIDTH / 2, (icon->height - FONT_HEIGHT) / 2 + 1, "FATAL ERROR", FONT_STANDARD); snprintf(line, sizeof(line), "Expr: %s", expr ? expr : "(null)"); oledDrawString(0, y, line, FONT_STANDARD); y += FONT_HEIGHT + 1; snprintf(line, sizeof(line), "Msg: %s", msg ? msg : "(null)"); oledDrawString(0, y, line, FONT_STANDARD); y += FONT_HEIGHT + 1; const char *label = "File: "; snprintf(line, sizeof(line), "%s:%d", file ? file : "(null)", line_num); oledDrawStringRight(OLED_WIDTH - 1, y, line, FONT_STANDARD); oledBox(0, y, oledStringWidth(label, FONT_STANDARD), y + FONT_HEIGHT, false); oledDrawString(0, y, label, FONT_STANDARD); y += FONT_HEIGHT + 1; snprintf(line, sizeof(line), "Func: %s", func ? func : "(null)"); oledDrawString(0, y, line, FONT_STANDARD); y += FONT_HEIGHT + 1; oledDrawString(0, y, "Contact TREZOR support.", FONT_STANDARD); oledRefresh(); shutdown(); }
void layoutResetWord(const char *word, int pass, int word_pos, bool last) { layoutLast = layoutResetWord; layoutSwipe(); const char *btnYes; if (last) { if (pass == 1) { btnYes = _("Finish"); } else { btnYes = _("Again"); } } else { btnYes = _("Next"); } const char *action; if (pass == 1) { action = _("Please check the seed"); } else { action = _("Write down the seed"); } char index_str[] = "##th word is:"; if (word_pos < 10) { index_str[0] = ' '; } else { index_str[0] = '0' + word_pos / 10; } index_str[1] = '0' + word_pos % 10; if (word_pos == 1 || word_pos == 21) { index_str[2] = 's'; index_str[3] = 't'; } else if (word_pos == 2 || word_pos == 22) { index_str[2] = 'n'; index_str[3] = 'd'; } else if (word_pos == 3 || word_pos == 23) { index_str[2] = 'r'; index_str[3] = 'd'; } int left = 0; oledClear(); oledDrawBitmap(0, 0, &bmp_icon_info); left = bmp_icon_info.width + 4; oledDrawString(left, 0 * 9, action, FONT_STANDARD); oledDrawString(left, 2 * 9, word_pos < 10 ? index_str + 1 : index_str, FONT_STANDARD); oledDrawString(left, 3 * 9, word, FONT_STANDARD | FONT_DOUBLE); oledHLine(OLED_HEIGHT - 13); layoutButtonYes(btnYes); oledRefresh(); }
void bootloader_loop(void) { static char serial[25]; fill_serialno_fixed(serial); oledDrawBitmap(0, 0, &bmp_logo64); oledDrawString(52, 0, "TREZOR"); oledDrawString(52, 20, "Serial No."); oledDrawString(52, 40, serial + 12); // second part of serial serial[12] = 0; oledDrawString(52, 30, serial); // first part of serial oledDrawStringRight(OLED_WIDTH - 1, OLED_HEIGHT - 8, "BLv" VERSTR(VERSION_MAJOR) "." VERSTR(VERSION_MINOR) "." VERSTR(VERSION_PATCH)); oledRefresh(); usbInit(); usbLoop(); }
void layoutDialog(const BITMAP *icon, const char *btnNo, const char *btnYes, const char *desc, const char *line1, const char *line2, const char *line3, const char *line4, const char *line5, const char *line6) { int left = 0; oledClear(); if (icon) { oledDrawBitmap(0, 0, icon); left = icon->width + 4; } if (line1) oledDrawString(left, 0 * 9, line1, FONT_STANDARD); if (line2) oledDrawString(left, 1 * 9, line2, FONT_STANDARD); if (line3) oledDrawString(left, 2 * 9, line3, FONT_STANDARD); if (line4) oledDrawString(left, 3 * 9, line4, FONT_STANDARD); if (desc) { oledDrawStringCenter(OLED_HEIGHT - 2 * 9 - 1, desc, FONT_STANDARD); if (btnYes || btnNo) { oledHLine(OLED_HEIGHT - 21); } } else { if (line5) oledDrawString(left, 4 * 9, line5, FONT_STANDARD); if (line6) oledDrawString(left, 5 * 9, line6, FONT_STANDARD); if (btnYes || btnNo) { oledHLine(OLED_HEIGHT - 13); } } if (btnNo) { layoutButtonNo(btnNo); } if (btnYes) { layoutButtonYes(btnYes); } oledRefresh(); }
void layoutDialog(const BITMAP *icon, const char *btnNo, const char *btnYes, const char *desc, const char *line1, const char *line2, const char *line3, const char *line4, const char *line5, const char *line6) { int left = 0; oledClear(); if (icon) { oledDrawBitmap(0, 0, icon); left = icon->width + 4; } if (line1) oledDrawString(left, 0 * 9, line1); if (line2) oledDrawString(left, 1 * 9, line2); if (line3) oledDrawString(left, 2 * 9, line3); if (line4) oledDrawString(left, 3 * 9, line4); if (desc) { oledDrawStringCenter(OLED_HEIGHT - 2 * 9 - 1, desc); if (btnYes || btnNo) { oledHLine(OLED_HEIGHT - 21); } } else { if (line5) oledDrawString(left, 4 * 9, line5); if (line6) oledDrawString(left, 5 * 9, line6); if (btnYes || btnNo) { oledHLine(OLED_HEIGHT - 13); } } if (btnNo) { oledDrawString(1, OLED_HEIGHT - 8, "\x15"); oledDrawString(fontCharWidth('\x15') + 3, OLED_HEIGHT - 8, btnNo); oledInvert(0, OLED_HEIGHT - 9, fontCharWidth('\x15') + oledStringWidth(btnNo) + 2, OLED_HEIGHT - 1); } if (btnYes) { oledDrawString(OLED_WIDTH - fontCharWidth('\x06') - 1, OLED_HEIGHT - 8, "\x06"); oledDrawString(OLED_WIDTH - oledStringWidth(btnYes) - fontCharWidth('\x06') - 3, OLED_HEIGHT - 8, btnYes); oledInvert(OLED_WIDTH - oledStringWidth(btnYes) - fontCharWidth('\x06') - 4, OLED_HEIGHT - 9, OLED_WIDTH - 1, OLED_HEIGHT - 1); } oledRefresh(); }
void oledDebug(const char *line) { int i; static const char *lines[8] = {0, 0, 0, 0, 0, 0, 0, 0}; static char id = 3; for (i = 0; i < 7; i++) { lines[i] = lines[i + 1]; } lines[7] = line; oledClear(); for (i = 0; i < 8; i++) { if (lines[i]) { oledDrawChar(0, i * 8, '0' + (id + i) % 10, 1); oledDrawString(8, i * 8, lines[i]); } } oledRefresh(); id = (id + 1) % 10; }
static void render_address_dialog(const CoinInfo *coin, const char *address, const char *line1, const char *line2, const char *extra_line) { if (coin && coin->cashaddr_prefix) { /* If this is a cashaddr address, remove the prefix from the * string presented to the user */ int prefix_len = strlen(coin->cashaddr_prefix); if (strncmp(address, coin->cashaddr_prefix, prefix_len) == 0 && address[prefix_len] == ':') { address += prefix_len + 1; } } int addrlen = strlen(address); int numlines = addrlen <= 42 ? 2 : 3; int linelen = (addrlen - 1) / numlines + 1; if (linelen > 21) { linelen = 21; } const char **str = split_message((const uint8_t *)address, addrlen, linelen); layoutLast = layoutDialogSwipe; layoutSwipe(); oledClear(); oledDrawBitmap(0, 0, &bmp_icon_question); oledDrawString(20, 0 * 9, line1, FONT_STANDARD); oledDrawString(20, 1 * 9, line2, FONT_STANDARD); int left = linelen > 18 ? 0 : 20; oledDrawString(left, 2 * 9, str[0], FONT_FIXED); oledDrawString(left, 3 * 9, str[1], FONT_FIXED); oledDrawString(left, 4 * 9, str[2], FONT_FIXED); oledDrawString(left, 5 * 9, str[3], FONT_FIXED); if (!str[3][0]) { if (extra_line) { oledDrawString(0, 5 * 9, extra_line, FONT_STANDARD); } else { oledHLine(OLED_HEIGHT - 13); } } layoutButtonNo(_("Cancel")); layoutButtonYes(_("Confirm")); oledRefresh(); }
void bootloader_loop(void) { oledClear(); oledDrawBitmap(0, 0, &bmp_logo64); if (firmware_present()) { oledDrawString(52, 0, "TREZOR", FONT_STANDARD); static char serial[25]; fill_serialno_fixed(serial); oledDrawString(52, 20, "Serial No.", FONT_STANDARD); oledDrawString(52, 40, serial + 12, FONT_STANDARD); // second part of serial serial[12] = 0; oledDrawString(52, 30, serial, FONT_STANDARD); // first part of serial oledDrawStringRight(OLED_WIDTH - 1, OLED_HEIGHT - 8, "Loader " VERSTR(VERSION_MAJOR) "." VERSTR(VERSION_MINOR) "." VERSTR(VERSION_PATCH), FONT_STANDARD); } else { oledDrawString(52, 10, "Welcome!", FONT_STANDARD); oledDrawString(52, 30, "Please visit", FONT_STANDARD); oledDrawString(52, 50, "trezor.io/start", FONT_STANDARD); } oledRefresh(); usbLoop(firmware_present()); }
void oledDrawStringRight(int x, int y, const char* text) { x -= fontStringWidth(text); oledDrawString(x, y, text); }
void oledDrawStringCenter(int y, const char* text) { int x = ( OLED_WIDTH - fontStringWidth(text) ) / 2; oledDrawString(x, y, text); }
void oledDrawStringCenter(int x, int y, const char *text, int font) { x = x - oledStringWidth(text, font) / 2; oledDrawString(x, y, text, font); }
void layoutButtonYes(const char *btnYes) { oledDrawString(OLED_WIDTH - fontCharWidth(FONT_STANDARD, '\x06') - 1, OLED_HEIGHT - 8, "\x06", FONT_STANDARD); oledDrawStringRight(OLED_WIDTH - fontCharWidth(FONT_STANDARD, '\x06') - 3, OLED_HEIGHT - 8, btnYes, FONT_STANDARD); oledInvert(OLED_WIDTH - oledStringWidth(btnYes, FONT_STANDARD) - fontCharWidth(FONT_STANDARD, '\x06') - 4, OLED_HEIGHT - 9, OLED_WIDTH - 1, OLED_HEIGHT - 1); }
void layoutButtonNo(const char *btnNo) { oledDrawString(1, OLED_HEIGHT - 8, "\x15", FONT_STANDARD); oledDrawString(fontCharWidth(FONT_STANDARD, '\x15') + 3, OLED_HEIGHT - 8, btnNo, FONT_STANDARD); oledInvert(0, OLED_HEIGHT - 9, fontCharWidth(FONT_STANDARD, '\x15') + oledStringWidth(btnNo, FONT_STANDARD) + 2, OLED_HEIGHT - 1); }
void layoutAddress(const char *address, const char *desc, bool qrcode, bool ignorecase, const uint32_t *address_n, size_t address_n_count, bool address_is_account) { if (layoutLast != layoutAddress) { layoutSwipe(); } else { oledClear(); } layoutLast = layoutAddress; uint32_t addrlen = strlen(address); if (qrcode) { static unsigned char bitdata[QR_MAX_BITDATA]; char address_upcase[addrlen + 1]; if (ignorecase) { for (uint32_t i = 0; i < addrlen + 1; i++) { address_upcase[i] = address[i] >= 'a' && address[i] <= 'z' ? address[i] + 'A' - 'a' : address[i]; } } int side = qr_encode(addrlen <= (ignorecase ? 60 : 40) ? QR_LEVEL_M : QR_LEVEL_L, 0, ignorecase ? address_upcase : address, 0, bitdata); oledInvert(0, 0, 63, 63); if (side > 0 && side <= 29) { int offset = 32 - side; for (int i = 0; i < side; i++) { for (int j = 0; j< side; j++) { int a = j * side + i; if (bitdata[a / 8] & (1 << (7 - a % 8))) { oledBox(offset + i * 2, offset + j * 2, offset + 1 + i * 2, offset + 1 + j * 2, false); } } } } else if (side > 0 && side <= 60) { int offset = 32 - (side / 2); for (int i = 0; i < side; i++) { for (int j = 0; j< side; j++) { int a = j * side + i; if (bitdata[a / 8] & (1 << (7 - a % 8))) { oledClearPixel(offset + i, offset + j); } } } } } else { if (desc) { oledDrawString(0, 0 * 9, desc, FONT_STANDARD); } if (addrlen > 10) { // don't split short addresses uint32_t rowlen = (addrlen - 1) / (addrlen <= 42 ? 2 : addrlen <= 63 ? 3 : 4) + 1; const char **str = split_message((const uint8_t *)address, addrlen, rowlen); for (int i = 0; i < 4; i++) { oledDrawString(0, (i + 1) * 9 + 4, str[i], FONT_FIXED); } } else { oledDrawString(0, (0 + 1) * 9 + 4, address, FONT_FIXED); } oledDrawString(0, 42, address_n_str(address_n, address_n_count, address_is_account), FONT_STANDARD); } if (!qrcode) { layoutButtonNo(_("QR Code")); } layoutButtonYes(_("Continue")); oledRefresh(); }