1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 12:28:09 +00:00

fix(legacy): refactor oledDrawBitmap and oledDrawBitmapFlip

into a single function
This commit is contained in:
Pavol Rusnak 2021-02-22 12:59:58 +01:00
parent 72691a93d5
commit 4d2237b32b

View File

@ -340,21 +340,9 @@ void oledDrawStringRight(int x, int y, const char *text, uint8_t font) {
oledDrawString(x, y, text, font);
}
void oledDrawBitmap(int x, int y, const BITMAP *bmp) {
static void oled_draw_bitmap_flip(int x, int y, const BITMAP *bmp, bool flip) {
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);
}
}
}
}
void oledDrawBitmapFlip(int x, int y, const BITMAP *bmp) {
for (int i = 0; i < bmp->width; i++) {
int ii = bmp->width - 1 - i;
int ii = flip ? i : (bmp->width - 1 - i);
for (int j = 0; j < bmp->height; j++) {
if (bmp->data[(ii / 8) + j * bmp->width / 8] & (1 << (7 - ii % 8))) {
oledDrawPixel(x + i, y + j);
@ -365,6 +353,14 @@ void oledDrawBitmapFlip(int x, int y, const BITMAP *bmp) {
}
}
void oledDrawBitmap(int x, int y, const BITMAP *bmp) {
oled_draw_bitmap_flip(x, y, bmp, false);
}
void oledDrawBitmapFlip(int x, int y, const BITMAP *bmp) {
oled_draw_bitmap_flip(x, y, bmp, true);
}
/*
* Inverts box between (x1,y1) and (x2,y2) inclusive.
*/