__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, 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 layoutHome(void) { if (layoutLast == layoutHome || layoutLast == layoutScreensaver) { oledClear(); } else { layoutSwipe(); } layoutLast = layoutHome; const char *label = storage_isInitialized() ? storage_getLabel() : _("Go to trezor.io/start"); const uint8_t *homescreen = storage_getHomescreen(); if (homescreen) { BITMAP b; b.width = 128; b.height = 64; b.data = homescreen; oledDrawBitmap(0, 0, &b); } else { if (label && strlen(label) > 0) { oledDrawBitmap(44, 4, &bmp_logo48); oledDrawStringCenter(OLED_HEIGHT - 8, label, FONT_STANDARD); } else { oledDrawBitmap(40, 0, &bmp_logo64); } } if (storage_noBackup()) { oledBox(0, 0, 127, 8, false); oledDrawStringCenter(0, "SEEDLESS", FONT_STANDARD); } else if (storage_unfinishedBackup()) { oledBox(0, 0, 127, 8, false); oledDrawStringCenter(0, "BACKUP FAILED!", FONT_STANDARD); } else if (storage_needsBackup()) { oledBox(0, 0, 127, 8, false); oledDrawStringCenter(0, "NEEDS BACKUP!", FONT_STANDARD); } oledRefresh(); // Reset lock screen timeout system_millis_lock_start = timer_ms(); }
void pinmatrix_draw(const char *text) { const BITMAP *bmp_digits[10] = { &bmp_digit0, &bmp_digit1, &bmp_digit2, &bmp_digit3, &bmp_digit4, &bmp_digit5, &bmp_digit6, &bmp_digit7, &bmp_digit8, &bmp_digit9, }; oledSwipeLeft(); const int w = bmp_digit0.width, h = bmp_digit0.height, pad = 2; int i, j, k; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { // use (2 - j) instead of j to achieve 789456123 layout k = pinmatrix_perm[i + (2 - j) * 3] - '0'; if (text) { oledDrawStringCenter(0, text); } oledDrawBitmap((OLED_WIDTH - 3 * w - 2 * pad) / 2 + i * (w + pad), OLED_HEIGHT - 3 * h - 2 * pad + j * (h + pad), bmp_digits[k]); } } oledRefresh(); }
void layoutProgress(const char *desc, int permil) { oledClear(); layoutProgressUpdate(false); // progressbar oledFrame(0, OLED_HEIGHT - 8, OLED_WIDTH - 1, OLED_HEIGHT - 1); oledBox(1, OLED_HEIGHT - 7, OLED_WIDTH - 2, OLED_HEIGHT - 2, 0); permil = permil * (OLED_WIDTH - 4) / 1000; if (permil < 0) { permil = 0; } if (permil > OLED_WIDTH - 4) { permil = OLED_WIDTH - 4; } oledBox(2, OLED_HEIGHT - 6, 1 + permil, OLED_HEIGHT - 3, 1); // text oledBox(0, OLED_HEIGHT - 16, OLED_WIDTH - 1, OLED_HEIGHT - 16 + 7, 0); if (desc) { oledDrawStringCenter(OLED_HEIGHT - 16, desc); } 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(); }