diff --git a/legacy/firmware/pinmatrix.c b/legacy/firmware/pinmatrix.c index 1d863c3ed..953ed80df 100644 --- a/legacy/firmware/pinmatrix.c +++ b/legacy/firmware/pinmatrix.c @@ -47,7 +47,8 @@ void pinmatrix_draw(const char *text) { } for (int i = 0; i < 3; i++) { // 36 is the maximum pixels used for a pin matrix pixel row - oledSCA(12 + i * (h + pad), 12 + i * (h + pad) + h - 1, 36); + // but we use 56 pixels to add some extra + oledSCAInside(12 + i * (h + pad), 12 + i * (h + pad) + h - 1, 56, 38, OLED_WIDTH - 38); } oledRefresh(); } diff --git a/legacy/oled.c b/legacy/oled.c index b6a29f4d0..460ab21cb 100644 --- a/legacy/oled.c +++ b/legacy/oled.c @@ -423,6 +423,7 @@ void oledSwipeRight(void) { /* * Mitigate SCA on lines y1-y2 by setting at least width pixels white + * Pixels grow from the outside (left/right border of the screen) */ void oledSCA(int y1, int y2, int width) { y1 = MAX(y1, 0); @@ -443,3 +444,27 @@ void oledSCA(int y1, int y2, int width) { } } } + +/* + * Mitigate SCA on lines y1-y2 by setting at least width pixels white + * Pixels grow from the inside (from columns a/b to the right/left) + */ +void oledSCAInside(int y1, int y2, int width, int a, int b) { + y1 = MAX(y1, 0); + y2 = MIN(y2, OLED_HEIGHT - 1); + for (int y = y1; y <= y2; y++) { + int pix = 0; + for (int x = 0; x < OLED_WIDTH; x++) { + pix += oledGetPixel(x, y); + } + if (width > pix) { + pix = width - pix; + for (int x = a - pix / 2; x < a; x++) { + oledDrawPixel(x, y); + } + for (int x = b; x < b + (pix + 1) / 2; x++) { + oledDrawPixel(x, y); + } + } + } +} diff --git a/legacy/oled.h b/legacy/oled.h index 1bfafbbf9..114e76c27 100644 --- a/legacy/oled.h +++ b/legacy/oled.h @@ -57,5 +57,6 @@ void oledFrame(int x1, int y1, int x2, int y2); void oledSwipeLeft(void); void oledSwipeRight(void); void oledSCA(int y1, int y2, int val); +void oledSCAInside(int y1, int y2, int val, int a, int b); #endif