Add mirror option on setRotation for ST7789
This commit is contained in:
parent
58f457ba97
commit
f21e66ae15
|
|
@ -1,5 +1,4 @@
|
|||
// This is the command sequence that rotates the ST7789 driver coordinate frame
|
||||
|
||||
writecommand(TFT_MADCTL);
|
||||
rotation = m % 4;
|
||||
switch (rotation) {
|
||||
|
|
@ -16,7 +15,11 @@
|
|||
rowstart = 0;
|
||||
}
|
||||
#endif
|
||||
if (mirror) {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
|
||||
} else {
|
||||
writedata(TFT_MAD_COLOR_ORDER);
|
||||
}
|
||||
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
|
|
@ -26,16 +29,26 @@
|
|||
#ifdef CGRAM_OFFSET
|
||||
if (_init_width == 135)
|
||||
{
|
||||
// TODO: Fix offset after mirror
|
||||
colstart = 40;
|
||||
rowstart = 53;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mirror) {
|
||||
colstart = 80;
|
||||
rowstart = 0;
|
||||
} else {
|
||||
colstart = 0;
|
||||
rowstart = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (mirror) {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
} else {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
|
||||
}
|
||||
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
|
|
@ -54,7 +67,11 @@
|
|||
rowstart = 80;
|
||||
}
|
||||
#endif
|
||||
if (mirror) {
|
||||
writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
} else {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
}
|
||||
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
|
|
@ -63,16 +80,26 @@
|
|||
#ifdef CGRAM_OFFSET
|
||||
if (_init_width == 135)
|
||||
{
|
||||
// TODO: Fix offset after mirror
|
||||
colstart = 40;
|
||||
rowstart = 52;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mirror) {
|
||||
colstart = 0;
|
||||
rowstart = 0;
|
||||
} else {
|
||||
colstart = 80;
|
||||
rowstart = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (mirror) {
|
||||
writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
|
||||
} else {
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
}
|
||||
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
// This is the command sequence that rotates the ST7789 driver coordinate frame
|
||||
|
||||
writecommand(TFT_MADCTL);
|
||||
rotation = m % 4;
|
||||
switch (rotation) {
|
||||
|
|
@ -16,7 +15,11 @@
|
|||
rowstart = 0;
|
||||
}
|
||||
#endif
|
||||
if (mirror) {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
|
||||
} else {
|
||||
writedata(TFT_MAD_COLOR_ORDER);
|
||||
}
|
||||
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
|
|
@ -26,16 +29,26 @@
|
|||
#ifdef CGRAM_OFFSET
|
||||
if (_init_width == 135)
|
||||
{
|
||||
// TODO: Fix offset after mirror
|
||||
colstart = 40;
|
||||
rowstart = 53;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mirror) {
|
||||
colstart = 80;
|
||||
rowstart = 0;
|
||||
} else {
|
||||
colstart = 0;
|
||||
rowstart = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (mirror) {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
} else {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
|
||||
}
|
||||
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
|
|
@ -54,7 +67,11 @@
|
|||
rowstart = 80;
|
||||
}
|
||||
#endif
|
||||
if (mirror) {
|
||||
writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
} else {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
}
|
||||
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
|
|
@ -63,16 +80,26 @@
|
|||
#ifdef CGRAM_OFFSET
|
||||
if (_init_width == 135)
|
||||
{
|
||||
// TODO: Fix offset after mirror
|
||||
colstart = 40;
|
||||
rowstart = 52;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mirror) {
|
||||
colstart = 0;
|
||||
rowstart = 0;
|
||||
} else {
|
||||
colstart = 80;
|
||||
rowstart = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (mirror) {
|
||||
writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
|
||||
} else {
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
}
|
||||
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
|
|
|
|||
|
|
@ -691,7 +691,13 @@ void TFT_eSPI::init(uint8_t tc)
|
|||
** Function name: setRotation
|
||||
** Description: rotate the screen orientation m = 0-3 or 4-7 for BMP drawing
|
||||
***************************************************************************************/
|
||||
|
||||
void TFT_eSPI::setRotation(uint8_t m)
|
||||
{
|
||||
setRotation(m, false);
|
||||
}
|
||||
|
||||
void TFT_eSPI::setRotation(uint8_t m, bool mirror)
|
||||
{
|
||||
|
||||
begin_tft_write();
|
||||
|
|
|
|||
|
|
@ -277,6 +277,11 @@ const PROGMEM fontinfo fontdata [] = {
|
|||
#define TFT_SKYBLUE 0x867D /* 135, 206, 235 */
|
||||
#define TFT_VIOLET 0x915C /* 180, 46, 226 */
|
||||
|
||||
#define TFT_PORTRAIT 0
|
||||
#define TFT_LANDSCAPE 1
|
||||
#define TFT_PORTRAIT_INVERT 2
|
||||
#define TFT_LANDSCAPE_INVERT 3
|
||||
|
||||
// Next is a special 16 bit colour value that encodes to 8 bits
|
||||
// and will then decode back to the same 16 bit value.
|
||||
// Convenient for 8 bit and 16 bit transparent sprites.
|
||||
|
|
@ -404,6 +409,7 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
|
|||
width(void);
|
||||
|
||||
void setRotation(uint8_t r); // Set the display image orientation to 0, 1, 2 or 3
|
||||
void setRotation(uint8_t r, bool mirror); // Set the display image orientation with mirro flag
|
||||
uint8_t getRotation(void); // Read the current rotation
|
||||
|
||||
void invertDisplay(bool i); // Tell TFT to invert all displayed colours
|
||||
|
|
|
|||
Loading…
Reference in New Issue