class ST7789_custom : public ST7789_t3 {
public:
ST7789_custom(uint8_t CS, uint8_t RS, uint8_t RST = -1) : ST7789_t3(CS, RS, RST) {}
virtual void setRotation(uint8_t m);
};
void ST7789_custom::setRotation(uint8_t m)
{
beginSPITransaction();
writecommand(ST7735_MADCTL);
rotation = m % 4; // can't be higher than 3
switch (rotation) {
case 0:
writedata_last(ST77XX_MADCTL_MX | ST77XX_MADCTL_MY | ST77XX_MADCTL_RGB);
_xstart = _colstart;
_ystart = _rowstart;
_width = _screenWidth;
_height = _screenHeight;
break;
case 1:
writedata_last(ST77XX_MADCTL_MY | ST77XX_MADCTL_MV | ST77XX_MADCTL_RGB);
_xstart = _rowstart;
_ystart = _colstart2;
_height = _screenWidth;
_width = _screenHeight;
break;
case 2:
writedata_last(ST77XX_MADCTL_RGB);
_xstart = _colstart2;
_ystart = _rowstart2;
_width = _screenWidth;
_height = _screenHeight;
break;
case 3:
writedata_last(ST77XX_MADCTL_MX | ST77XX_MADCTL_MV | ST77XX_MADCTL_RGB);
_xstart = _rowstart2;
_ystart = _colstart;
_height = _screenWidth;
_width = _screenHeight;
break;
}
#define ST77XX_MADCTL_RGB 0x00
#define ST77XX_MADCTL_RGB 0x01
Koo thanks!Will let you know.
Quick FYI: there was another thread on this display:
Which mentioned that the display works on the TFT_eSPI library with the ILI9488 setting. They now have an ST7796 settting
and I confirmed it works on it.
So now to figure out what is not working on ours.
#include <ST7796_t3.h> // Hardware-specific library
ST7796_t3 tft = ST7796_t3(TFT_CS, TFT_DC, TFT_RST);
tft.init(320, 480); // initialize a ST7789 chip, 240x240 pixels