Files
TFT_eSPI/TFT_Drivers/RPI_ILI9486_Rotation.h
T
turiphro b97324875d 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.
2017-11-26 18:06:11 -08:00

48 lines
1.3 KiB
C

// This is the command sequence that rotates the ILI9486 driver coordinate frame
writecommand(TFT_MADCTL);
rotation = m % 8;
switch (rotation) {
case 0: // Portrait
writedata(TFT_MAD_BGR | TFT_MAD_MX);
_width = _width_orig;
_height = _height_orig;
break;
case 1: // Landscape (Portrait + 90)
writedata(TFT_MAD_BGR | TFT_MAD_MV);
_width = _height_orig;
_height = _width_orig;
break;
case 2: // Inverter portrait
writedata( TFT_MAD_BGR | TFT_MAD_MY);
_width = _width_orig;
_height = _height_orig;
break;
case 3: // Inverted landscape
writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_MY);
_width = _height_orig;
_height = _width_orig;
break;
case 4: // Portrait
writedata(TFT_MAD_BGR | TFT_MAD_MX | TFT_MAD_MY);
_width = _width_orig;
_height = _height_orig;
break;
case 5: // Landscape (Portrait + 90)
writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MX);
_width = _height_orig;
_height = _width_orig;
break;
case 6: // Inverter portrait
writedata( TFT_MAD_BGR);
_width = _width_orig;
_height = _height_orig;
break;
case 7: // Inverted landscape
writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MY);
_width = _height_orig;
_height = _width_orig;
break;
}