ST7789: Fix 240x240 display rotations.

This commit is contained in:
Phil Howard 2022-06-08 13:01:08 +01:00
parent b13470b4fb
commit 4585e5ec0f
1 changed files with 38 additions and 11 deletions

View File

@ -119,18 +119,45 @@ namespace pimoroni {
// 240x240 Square and Round LCD Breakouts // 240x240 Square and Round LCD Breakouts
if(width == 240 && height == 240) { if(width == 240 && height == 240) {
caset[0] = 0; int row_offset = round ? 40 : 80;
caset[1] = 239; int col_offset = 0;
if(round) {
raset[0] = 40; switch(rotate) {
raset[1] = 279; case ROTATE_0:
} else { if (!round) row_offset = 0;
raset[0] = rotate180 ? 80 : 0; caset[0] = col_offset;
raset[1] = rotate180 ? 329 : 239; caset[1] = width + col_offset - 1;
raset[0] = row_offset;
raset[1] = width + row_offset - 1;
madctl = MADCTL::HORIZ_ORDER;
break;
case ROTATE_90:
if (!round) row_offset = 0;
caset[0] = row_offset;
caset[1] = width + row_offset - 1;
raset[0] = col_offset;
raset[1] = width + col_offset - 1;
madctl = MADCTL::HORIZ_ORDER | MADCTL::COL_ORDER | MADCTL::SWAP_XY;
break;
case ROTATE_180:
caset[0] = col_offset;
caset[1] = width + col_offset - 1;
raset[0] = row_offset;
raset[1] = width + row_offset - 1;
madctl = MADCTL::HORIZ_ORDER | MADCTL::COL_ORDER | MADCTL::ROW_ORDER;
break;
case ROTATE_270:
caset[0] = row_offset;
caset[1] = width + row_offset - 1;
raset[0] = col_offset;
raset[1] = width + col_offset - 1;
madctl = MADCTL::ROW_ORDER | MADCTL::SWAP_XY;
break;
} }
madctl = rotate180 ? (MADCTL::COL_ORDER | MADCTL::ROW_ORDER) : 0;
if (rotate == ROTATE_90) madctl |= MADCTL::SWAP_XY;
madctl |= MADCTL::HORIZ_ORDER;
} }
// Pico Display // Pico Display