legacy: make sca pixels for pin matrix grow from the inside

pull/464/head
Pavol Rusnak 5 years ago
parent 34ec1ed294
commit 41428ab2df
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -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();
}

@ -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);
}
}
}
}

@ -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

Loading…
Cancel
Save