1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-29 10:58:21 +00:00

legacy: don't add more pixels than needed in oledSCA

This commit is contained in:
Pavol Rusnak 2019-07-31 11:42:56 +02:00
parent f237a26137
commit 6720690452
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
5 changed files with 15 additions and 8 deletions

View File

@ -546,7 +546,9 @@ void layoutResetWord(const char *word, int pass, int word_pos, bool last) {
FONT_STANDARD);
oledDrawStringCenter(OLED_WIDTH / 2, 4 * 9 - 3, word,
FONT_FIXED | FONT_DOUBLE);
oledSCA(4 * 9 - 3 - 2, 4 * 9 - 3 + 15 + 2, OLED_WIDTH / 2);
// 30 is the maximum pixels used for a pixel row in the BIP39 word "abstract"
oledSCA(4 * 9 - 3 - 2, 4 * 9 - 3 + 15 + 2, 30);
oledInvert(0, 4 * 9 - 3 - 2, OLED_WIDTH - 1, 4 * 9 - 3 + 15 + 2);
layoutButtonYes(btnYes);
oledRefresh();
}

View File

@ -46,8 +46,8 @@ void pinmatrix_draw(const char *text) {
}
}
for (int i = 0; i < 3; i++) {
oledSCA(12 + i * (h + pad), 12 + i * (h + pad) + h - 1, OLED_WIDTH / 2);
oledInvert(0, 12 + i * (h + pad), OLED_WIDTH - 1, 12 + i * (h + pad) + h - 1);
// 36 is the maximum pixels used for a pin matrix pixel row
oledSCA(12 + i * (h + pad), 12 + i * (h + pad) + h - 1, 36);
}
oledRefresh();
}

View File

@ -6,7 +6,7 @@ const uint8_t bmp_digit1_data[] = { 0xff, 0xff, 0xfc, 0x3f, 0xf8, 0x3f, 0xf0, 0x
const uint8_t bmp_digit2_data[] = { 0xff, 0xff, 0xe0, 0x1f, 0xe0, 0x0f, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xf8, 0x0f, 0xf0, 0x1f, 0xe1, 0xff, 0xe1, 0xff, 0xe1, 0xff, 0xe1, 0xff, 0xe0, 0x07, 0xe0, 0x07, 0xff, 0xff, };
const uint8_t bmp_digit3_data[] = { 0xff, 0xff, 0xe0, 0x1f, 0xe0, 0x0f, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xf8, 0x0f, 0xf8, 0x0f, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xe0, 0x0f, 0xe0, 0x1f, 0xff, 0xff, };
const uint8_t bmp_digit4_data[] = { 0xff, 0xff, 0xff, 0x0f, 0xfe, 0x0f, 0xfc, 0x0f, 0xf8, 0x0f, 0xf1, 0x0f, 0xe3, 0x0f, 0xc7, 0x0f, 0xcf, 0x0f, 0xc0, 0x0f, 0xc0, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0xff, };
const uint8_t bmp_digit5_data[] = { 0xff, 0xff, 0xe0, 0x1f, 0xe0, 0x1f, 0xe7, 0xff, 0xe7, 0xff, 0xe0, 0x1f, 0xe0, 0x0f, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xe0, 0x0f, 0xe0, 0x1f, 0xff, 0xff, };
const uint8_t bmp_digit5_data[] = { 0xff, 0xff, 0xe0, 0x0f, 0xe0, 0x0f, 0xe1, 0xff, 0xe1, 0xff, 0xe0, 0x1f, 0xe0, 0x0f, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xff, 0x87, 0xe0, 0x0f, 0xe0, 0x1f, 0xff, 0xff, };
const uint8_t bmp_digit6_data[] = { 0xff, 0xff, 0xf8, 0x1f, 0xf0, 0x1f, 0xe1, 0xff, 0xe1, 0xff, 0xe0, 0x1f, 0xe0, 0x0f, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xf0, 0x0f, 0xf8, 0x1f, 0xff, 0xff, };
const uint8_t bmp_digit7_data[] = { 0xff, 0xff, 0xe0, 0x07, 0xe0, 0x07, 0xff, 0x87, 0xff, 0x87, 0xff, 0x0f, 0xfe, 0x1f, 0xfc, 0x1f, 0xfc, 0x3f, 0xf8, 0x7f, 0xf8, 0x7f, 0xf8, 0x7f, 0xf8, 0x7f, 0xf8, 0x7f, 0xf8, 0x7f, 0xff, 0xff, };
const uint8_t bmp_digit8_data[] = { 0xff, 0xff, 0xf8, 0x1f, 0xf0, 0x0f, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xf0, 0x0f, 0xf0, 0x0f, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xe1, 0x87, 0xf0, 0x0f, 0xf8, 0x1f, 0xff, 0xff, };

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 B

After

Width:  |  Height:  |  Size: 882 B

View File

@ -422,7 +422,7 @@ void oledSwipeRight(void) {
}
/*
* Mitigate SCA on lines y1-y2 by setting exactly width pixels black
* Mitigate SCA on lines y1-y2 by setting at least width pixels white
*/
void oledSCA(int y1, int y2, int width) {
y1 = MAX(y1, 0);
@ -432,9 +432,14 @@ void oledSCA(int y1, int y2, int width) {
for (int x = 0; x < OLED_WIDTH; x++) {
pix += oledGetPixel(x, y);
}
pix = MAX(width - pix, 0);
for (int x = 0 + (pix / 2); x < OLED_WIDTH - ((pix + 1) / 2); x++) {
oledInvertPixel(x, y);
if (width > pix) {
pix = width - pix;
for (int x = 0; x < pix / 2; x++) {
oledDrawPixel(x, y);
}
for (int x = OLED_WIDTH - ((pix + 1) / 2); x < OLED_WIDTH; x++) {
oledDrawPixel(x, y);
}
}
}
}