Add screen mirror function for ST7789
This commit is contained in:
parent
58f457ba97
commit
07f21b5120
|
|
@ -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;
|
||||
|
|
@ -24,6 +27,7 @@
|
|||
|
||||
case 1: // Landscape (Portrait + 90)
|
||||
#ifdef CGRAM_OFFSET
|
||||
// TODO: Fix offset after mirror
|
||||
if (_init_width == 135)
|
||||
{
|
||||
colstart = 40;
|
||||
|
|
@ -31,11 +35,20 @@
|
|||
}
|
||||
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,13 +67,18 @@
|
|||
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;
|
||||
break;
|
||||
case 3: // Inverted landscape
|
||||
#ifdef CGRAM_OFFSET
|
||||
// TODO: Fix offset after mirror
|
||||
if (_init_width == 135)
|
||||
{
|
||||
colstart = 40;
|
||||
|
|
@ -68,11 +86,20 @@
|
|||
}
|
||||
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,6 +1,6 @@
|
|||
// This is the command sequence that rotates the ST7789 driver coordinate frame
|
||||
|
||||
writecommand(TFT_MADCTL);
|
||||
uint8_t writedata(0);
|
||||
rotation = m % 4;
|
||||
switch (rotation) {
|
||||
case 0: // Portrait
|
||||
|
|
@ -16,7 +16,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;
|
||||
|
|
@ -24,6 +28,7 @@
|
|||
|
||||
case 1: // Landscape (Portrait + 90)
|
||||
#ifdef CGRAM_OFFSET
|
||||
// TODO: Fix offset after mirror
|
||||
if (_init_width == 135)
|
||||
{
|
||||
colstart = 40;
|
||||
|
|
@ -31,11 +36,20 @@
|
|||
}
|
||||
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,13 +68,18 @@
|
|||
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;
|
||||
break;
|
||||
case 3: // Inverted landscape
|
||||
#ifdef CGRAM_OFFSET
|
||||
// TODO: Fix offset after mirror
|
||||
if (_init_width == 135)
|
||||
{
|
||||
colstart = 40;
|
||||
|
|
@ -68,11 +87,20 @@
|
|||
}
|
||||
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;
|
||||
|
|
|
|||
16
TFT_eSPI.h
16
TFT_eSPI.h
|
|
@ -303,7 +303,15 @@ static const uint16_t default_4bit_palette[] PROGMEM = {
|
|||
};
|
||||
|
||||
/***************************************************************************************
|
||||
** Section 7: Diagnostic support
|
||||
** Section 7: Screen rotation enumeration
|
||||
***************************************************************************************/
|
||||
#define TFT_PORTRAIT 0
|
||||
#define TFT_LANDSCAPE 1
|
||||
#define TFT_PORTRAIT_INVERT 2
|
||||
#define TFT_LANDSCAPE_INVERT 3
|
||||
|
||||
/***************************************************************************************
|
||||
** Section 8: Diagnostic support
|
||||
***************************************************************************************/
|
||||
// #define TFT_eSPI_DEBUG // Switch on debug support serial messages (not used yet)
|
||||
// #define TFT_eSPI_FNx_DEBUG // Switch on debug support for function "x" (not used yet)
|
||||
|
|
@ -369,7 +377,7 @@ int16_t tch_spi_freq;// Touch controller read/write SPI frequency
|
|||
} setup_t;
|
||||
|
||||
/***************************************************************************************
|
||||
** Section 8: Class member and support functions
|
||||
** Section 9: Class member and support functions
|
||||
***************************************************************************************/
|
||||
// Swap any type
|
||||
template <typename T> static inline void
|
||||
|
|
@ -799,7 +807,7 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
|
|||
#endif
|
||||
|
||||
/***************************************************************************************
|
||||
** Section 9: TFT_eSPI class conditional extensions
|
||||
** Section 10: TFT_eSPI class conditional extensions
|
||||
***************************************************************************************/
|
||||
// Load the Touch extension
|
||||
#ifdef TOUCH_CS
|
||||
|
|
@ -814,7 +822,7 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
|
|||
}; // End of class TFT_eSPI
|
||||
|
||||
/***************************************************************************************
|
||||
** Section 10: Additional extension classes
|
||||
** Section 11: Additional extension classes
|
||||
***************************************************************************************/
|
||||
// Load the Button Class
|
||||
#include "Extensions/Button.h"
|
||||
|
|
|
|||
Loading…
Reference in New Issue