Merge pull request #13271 from gemu2015/udisp_fix

fix rotate
This commit is contained in:
Theo Arends 2021-10-04 14:57:38 +02:00 committed by GitHub
commit 47a85d975a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 17 deletions

View File

@ -903,8 +903,13 @@ void uDisplay::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) {
SPI_END_TRANSACTION SPI_END_TRANSACTION
} }
//#define CD_XS gxs
//#define CD_YS gys
#define CD_XS width()
#define CD_YS height()
void uDisplay::fillScreen(uint16_t color) { void uDisplay::fillScreen(uint16_t color) {
fillRect(0, 0, gxs, gys, color); fillRect(0, 0, CD_XS, CD_YS, color);
} }
// fill a rectangle // fill a rectangle
@ -921,9 +926,9 @@ void uDisplay::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t col
return; return;
} }
if((x >= gxs) || (y >= gys)) return; if((x >= CD_XS) || (y >= CD_YS)) return;
if((x + w - 1) >= gxs) w = gxs - x; if((x + w - 1) >= CD_XS) w = CD_XS - x;
if((y + h - 1) >= gys) h = gys - y; if((y + h - 1) >= CD_YS) h = CD_YS - y;
SPI_BEGIN_TRANSACTION SPI_BEGIN_TRANSACTION
@ -1424,14 +1429,24 @@ void uDisplay::dim8(uint8_t dim, uint8_t dim_gamma) { // dimmer with 8
void uDisplay::TS_RotConvert(int16_t *x, int16_t *y) { void uDisplay::TS_RotConvert(int16_t *x, int16_t *y) {
int16_t temp; int16_t temp;
if (rot_t[cur_rot] & 0x80) {
temp = *y;
*y = *x;
*x = temp;
}
if (rotmap_xmin >= 0) { if (rotmap_xmin >= 0) {
*y = map(*y, rotmap_ymin, rotmap_ymax, 0, gys); *y = map(*y, rotmap_ymin, rotmap_ymax, 0, gys);
*x = map(*x, rotmap_xmin, rotmap_xmax, 0, gxs); *x = map(*x, rotmap_xmin, rotmap_xmax, 0, gxs);
*x = constrain(*x, 0, gxs);
*y = constrain(*y, 0, gys);
} }
*x = constrain(*x, 0, gxs); // *x = constrain(*x, 0, gxs);
*y = constrain(*y, 0, gys); // *y = constrain(*y, 0, gys);
switch (rot_t[cur_rot]) { //Serial.printf("rot 1 %d - %d\n",*x,*y );
switch (rot_t[cur_rot] & 0xf) {
case 0: case 0:
break; break;
case 1: case 1:
@ -1448,7 +1463,15 @@ void uDisplay::TS_RotConvert(int16_t *x, int16_t *y) {
*y = *x; *y = *x;
*x = width() - temp; *x = width() - temp;
break; break;
case 4:
*x = width() - *x;
break;
case 5:
*y = height() - *y;
break;
} }
//Serial.printf("rot 2 %d - %d\n",*x,*y );
} }
uint8_t uDisplay::strlen_ln(char *str) { uint8_t uDisplay::strlen_ln(char *str) {

View File

@ -20,12 +20,12 @@ F7,4,A9,51,2C,82
:O,29 :O,29
:A,2A,2B,2C,16 :A,2A,2B,2C,16
:R,36 :R,36
;:0,48,00,00,00 :0,28,00,00,85
:0,28,00,00,01 :1,88,00,00,02
:1,28,00,00,00 :2,E8,00,00,84
:2,E8,00,00,03 :3,48,00,00,00
:3,88,00,00,02
:P,18 :P,18
:i,20,21 :i,20,21
:TI1,38,*,* :TI1,38,*,*
:B,20,0
# #

View File

@ -30,9 +30,9 @@ E1,0F,00,0E,14,03,11,07,31,C1,48,08,0F,0C,31,36,0F
:A,2A,2B,2C,16 :A,2A,2B,2C,16
:R,36 :R,36
:0,08,00,00,00 :0,08,00,00,00
:1,A8,00,00,01 :1,A8,00,00,84
:2,C8,00,00,02 :2,C8,00,00,02
:3,68,00,00,03 :3,68,00,00,85
:i,21,20 :i,21,20
:TI2,38,22,21 :TI2,38,22,21
# #

View File

@ -294,14 +294,20 @@ uDisplay *udisp;
} }
#endif #endif
uint8_t inirot = Settings->display_rotate;
cp = strstr(ddesc, ":r,");
if (cp) {
cp+=3;
inirot = strtol(cp, &cp, 10);
}
// release desc buffer // release desc buffer
if (fbuff) free(fbuff); if (fbuff) free(fbuff);
renderer = udisp->Init(); renderer = udisp->Init();
if (!renderer) return 0; if (!renderer) return 0;
Settings->display_width = renderer->width();
Settings->display_height = renderer->height();
fg_color = renderer->fgcol(); fg_color = renderer->fgcol();
bg_color = renderer->bgcol(); bg_color = renderer->bgcol();
color_type = renderer->color_type(); color_type = renderer->color_type();
@ -311,7 +317,11 @@ uDisplay *udisp;
renderer->SetDimCB(Core2DisplayDim); renderer->SetDimCB(Core2DisplayDim);
#endif #endif
renderer->DisplayInit(DISPLAY_INIT_MODE, Settings->display_size, Settings->display_rotate, Settings->display_font); renderer->DisplayInit(DISPLAY_INIT_MODE, Settings->display_size, inirot, Settings->display_font);
Settings->display_width = renderer->width();
Settings->display_height = renderer->height();
ApplyDisplayDimmer(); ApplyDisplayDimmer();
#ifdef SHOW_SPLASH #ifdef SHOW_SPLASH