Commit b9732487 authored by turiphro's avatar turiphro

Fix width/height override issue when using setRotation

This commit fixes an issue when setting screen width
and height from the constructor (e.g., user sketch),
followed by setRotation(i). Previously, setRotation
used TFT_WIDTH and TFT_HEIGHT, ignoring user overrides.
parent 58fa8326
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
switch (rotation) { switch (rotation) {
case 0: case 0:
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR); writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
#ifdef CGRAM_OFFSET #ifdef CGRAM_OFFSET
colstart = 0; colstart = 0;
rowstart = 0; rowstart = 0;
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
break; break;
case 1: case 1:
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR); writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR);
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
#ifdef CGRAM_OFFSET #ifdef CGRAM_OFFSET
colstart = 0; colstart = 0;
rowstart = 0; rowstart = 0;
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
break; break;
case 2: case 2:
writedata(TFT_MAD_BGR); writedata(TFT_MAD_BGR);
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
#ifdef CGRAM_OFFSET #ifdef CGRAM_OFFSET
colstart = 0; colstart = 0;
rowstart = 32; rowstart = 32;
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
break; break;
case 3: case 3:
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR); writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
#ifdef CGRAM_OFFSET #ifdef CGRAM_OFFSET
colstart = 32; colstart = 32;
rowstart = 0; rowstart = 0;
......
...@@ -7,44 +7,44 @@ ...@@ -7,44 +7,44 @@
switch (rotation) { switch (rotation) {
case 0: case 0:
writedata(TFT_MAD_MX | TFT_MAD_BGR); writedata(TFT_MAD_MX | TFT_MAD_BGR);
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
break; break;
case 1: case 1:
writedata(TFT_MAD_MV | TFT_MAD_BGR); writedata(TFT_MAD_MV | TFT_MAD_BGR);
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
break; break;
case 2: case 2:
writedata(TFT_MAD_MY | TFT_MAD_BGR); writedata(TFT_MAD_MY | TFT_MAD_BGR);
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
break; break;
case 3: case 3:
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
break; break;
// These next rotations are for bottum up BMP drawing // These next rotations are for bottum up BMP drawing
case 4: case 4:
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR); writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
break; break;
case 5: case 5:
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_BGR); writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_BGR);
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
break; break;
case 6: case 6:
writedata(TFT_MAD_BGR); writedata(TFT_MAD_BGR);
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
break; break;
case 7: case 7:
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
break; break;
} }
\ No newline at end of file
...@@ -5,43 +5,43 @@ ...@@ -5,43 +5,43 @@
switch (rotation) { switch (rotation) {
case 0: // Portrait case 0: // Portrait
writedata(TFT_MAD_BGR | TFT_MAD_MX); writedata(TFT_MAD_BGR | TFT_MAD_MX);
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
break; break;
case 1: // Landscape (Portrait + 90) case 1: // Landscape (Portrait + 90)
writedata(TFT_MAD_BGR | TFT_MAD_MV); writedata(TFT_MAD_BGR | TFT_MAD_MV);
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
break; break;
case 2: // Inverter portrait case 2: // Inverter portrait
writedata( TFT_MAD_BGR | TFT_MAD_MY); writedata( TFT_MAD_BGR | TFT_MAD_MY);
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
break; break;
case 3: // Inverted landscape case 3: // Inverted landscape
writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_MY); writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_MY);
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
break; break;
case 4: // Portrait case 4: // Portrait
writedata(TFT_MAD_BGR | TFT_MAD_MX | TFT_MAD_MY); writedata(TFT_MAD_BGR | TFT_MAD_MX | TFT_MAD_MY);
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
break; break;
case 5: // Landscape (Portrait + 90) case 5: // Landscape (Portrait + 90)
writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MX); writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MX);
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
break; break;
case 6: // Inverter portrait case 6: // Inverter portrait
writedata( TFT_MAD_BGR); writedata( TFT_MAD_BGR);
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
break; break;
case 7: // Inverted landscape case 7: // Inverted landscape
writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MY); writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MY);
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
break; break;
} }
\ No newline at end of file
...@@ -7,22 +7,22 @@ ...@@ -7,22 +7,22 @@
switch (rotation) { switch (rotation) {
case 0: case 0:
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR); writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
break; break;
case 1: case 1:
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR); writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR);
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
break; break;
case 2: case 2:
writedata(TFT_MAD_BGR); writedata(TFT_MAD_BGR);
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
break; break;
case 3: case 3:
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR); writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
break; break;
} }
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
} else { } else {
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR); writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
} }
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
break; break;
case 1: case 1:
if (tabcolor == INITR_BLACKTAB) { if (tabcolor == INITR_BLACKTAB) {
...@@ -44,8 +44,8 @@ ...@@ -44,8 +44,8 @@
} else { } else {
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
} }
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
break; break;
case 2: case 2:
if (tabcolor == INITR_BLACKTAB) { if (tabcolor == INITR_BLACKTAB) {
...@@ -65,8 +65,8 @@ ...@@ -65,8 +65,8 @@
} else { } else {
writedata(TFT_MAD_BGR); writedata(TFT_MAD_BGR);
} }
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
break; break;
case 3: case 3:
if (tabcolor == INITR_BLACKTAB) { if (tabcolor == INITR_BLACKTAB) {
...@@ -86,30 +86,30 @@ ...@@ -86,30 +86,30 @@
} else { } else {
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR); writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
} }
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
break; break;
// These next rotations are for bottum up BMP drawing // These next rotations are for bottum up BMP drawing
/* case 4: /* case 4:
writedata(ST7735_TFT_MAD_MX | ST7735_TFT_MAD_MY | ST7735_TFT_MAD_BGR); writedata(ST7735_TFT_MAD_MX | ST7735_TFT_MAD_MY | ST7735_TFT_MAD_BGR);
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
break; break;
case 5: case 5:
writedata(ST7735_TFT_MAD_MV | ST7735_TFT_MAD_MX | ST7735_TFT_MAD_BGR); writedata(ST7735_TFT_MAD_MV | ST7735_TFT_MAD_MX | ST7735_TFT_MAD_BGR);
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
break; break;
case 6: case 6:
writedata(ST7735_TFT_MAD_BGR); writedata(ST7735_TFT_MAD_BGR);
_width = TFT_WIDTH; _width = _width_orig;
_height = TFT_HEIGHT; _height = _height_orig;
break; break;
case 7: case 7:
writedata(ST7735_TFT_MAD_MY | ST7735_TFT_MAD_MV | ST7735_TFT_MAD_BGR); writedata(ST7735_TFT_MAD_MY | ST7735_TFT_MAD_MV | ST7735_TFT_MAD_BGR);
_width = TFT_HEIGHT; _width = _height_orig;
_height = TFT_WIDTH; _height = _width_orig;
break; break;
*/ */
} }
\ No newline at end of file
...@@ -109,8 +109,8 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h) ...@@ -109,8 +109,8 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h)
} }
#endif #endif
_width = w; // Set by specific xxxxx_Defines.h file or by users sketch _width_orig = _width = w; // Set by specific xxxxx_Defines.h file or by users sketch
_height = h; // Set by specific xxxxx_Defines.h file or by users sketch _height_orig = _height = h; // Set by specific xxxxx_Defines.h file or by users sketch
rotation = 0; rotation = 0;
cursor_y = cursor_x = 0; cursor_y = cursor_x = 0;
textfont = 1; textfont = 1;
......
...@@ -480,6 +480,7 @@ class TFT_eSPI : public Print { ...@@ -480,6 +480,7 @@ class TFT_eSPI : public Print {
int32_t cursor_x, cursor_y, win_xe, win_ye, padX; int32_t cursor_x, cursor_y, win_xe, win_ye, padX;
uint32_t _width_orig, _height_orig; // Display w/h as input, used by setRotation()
uint32_t _width, _height; // Display w/h as modified by current rotation uint32_t _width, _height; // Display w/h as modified by current rotation
uint32_t textcolor, textbgcolor, fontsloaded, addr_row, addr_col; uint32_t textcolor, textbgcolor, fontsloaded, addr_row, addr_col;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment