void oledBox(int x1, int y1, int x2, int y2, char val) { int x, y; for (x = x1; x <= x2; x++) { for (y = y1; y <= y2; y++) { val ? oledDrawPixel(x, y) : oledClearPixel(x, y); } } }
/* * Draw a filled rectangle. */ void oledBox(int x1, int y1, int x2, int y2, bool set) { int x, y; for (x = x1; x <= x2; x++) { for (y = y1; y <= y2; y++) { set ? oledDrawPixel(x, y) : oledClearPixel(x, y); } } }
void oledDrawBitmap(int x, int y, const BITMAP *bmp) { for (int i = 0; i < bmp->width; i++) { for (int j = 0; j < bmp->height; j++) { if (bmp->data[(i / 8) + j * bmp->width / 8] & (1 << (7 - i % 8))) { oledDrawPixel(x + i, y + j); } else { oledClearPixel(x + i, y + j); } } } }
/* * Draw a filled rectangle. */ void oledBox(int x1, int y1, int x2, int y2, bool set) { x1 = MAX(x1, 0); y1 = MAX(y1, 0); x2 = MIN(x2, OLED_WIDTH - 1); y2 = MIN(y2, OLED_HEIGHT - 1); for (int x = x1; x <= x2; x++) { for (int y = y1; y <= y2; y++) { set ? oledDrawPixel(x, y) : oledClearPixel(x, y); } } }
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(); }