__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 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 oledDrawStringRight(int x, int y, const char* text) { x -= oledStringWidth(text); oledDrawString(x, y, text); }
void oledDrawStringCenter(int y, const char* text) { int x = ( OLED_WIDTH - oledStringWidth(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); }