ST7789_t3.h Inverted TFT mirror effect

jean

Well-known member
Hello everyone,
I'm using a Teensy 4.0 with a 240 x 240 px TFT display. I have:

#include <Adafruit_GFX.h>
#include <ST7735_t3.h>
#include <ST7789_t3.h>

No display issues; everything works perfectly.

But how do I create a mirror effect?
Like when I write or draw on a piece of paper and look at it in a mirror. I didn’t see anything in ST7789_t3.
How do I go about achieving this effect?

Here's what I want to do

Jean
 

Attachments

  • rendu_voulu.jpg
    rendu_voulu.jpg
    4.2 KB · Views: 7
Last edited:
In the ST7789_t3.cpp file you will see the function setRotation
Code:
void  ST7789_t3::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;
  }


  _rot = m;
  endSPITransaction();
//  Serial.printf("Set rotation %d start(%d %d) row: %d, col: %d\n", m, _xstart, _ystart, _rowstart, _colstart);
  setClipRect();
  setOrigin();
   
    cursor_x = 0;
    cursor_y = 0;
}
You will see that it is updating the ST7735_MADCTL register, depending on rotation. In here you will see that it sets
the value like for case 0: ST77XX_MADCTL_MX | ST77XX_MADCTL_MY | ST77XX_MADCTL_RGB

The values for the settings like: ST77XX_MADCTL_MY is defined directly in this file, The registers are defined in the
ST7735_t3.h file.

What these different settings MX, MY... are defined in the ST7789 reference manual:
You can download from several places. The one I just looked up:
You will find these values shown in several places, like page: 167(RDDST) 215(MADCTL)
 
Last edited:
Dans le fichier ST7789_t3.cpp, vous trouverez la fonction setRotation.
Code:
void ST7789_t3::setRotation(uint8_t m)
{
  débutSPITransaction();
  writecommand(ST7735_MADCTL);
  rotation = m % 4; // ne peut pas être supérieur à 3
  commutateur (rotation) {
   cas 0 :
     écriredata_last(ST77XX_MADCTL_MX | ST77XX_MADCTL_MY | ST77XX_MADCTL_RGB);


     _xstart = _colstart;
     _ystart = _rowstart;
     _largeur = _largeurécran;
     _hauteur = _hauteurécran;
     casser;
   cas 1 :
     écriredata_last(ST77XX_MADCTL_MY | ST77XX_MADCTL_MV | ST77XX_MADCTL_RGB);


     _xstart = _rowstart;
     _ystart = _colstart2;
     _hauteur = _largeurécran;
     _largeur = _hauteurécran;
     casser;
  cas 2 :
     écriredata_last(ST77XX_MADCTL_RGB);
     _xstart = _colstart2;
     _ystart = _rowstart2;
     _largeur = _largeurécran;
     _hauteur = _hauteurécran;
     casser;


   cas 3 :
     écriredata_last(ST77XX_MADCTL_MX | ST77XX_MADCTL_MV | ST77XX_MADCTL_RGB);
     _xstart = _rowstart2;
     _ystart = _colstart;
     _hauteur = _largeurécran;
     _largeur = _hauteurécran;
     casser;
  }


  _rot = m;
  endSPITransaction();
// Serial.printf("Définir la rotation %d départ (%d %d) ligne : %d, colonne : %d\n", m, _xstart, _ystart, _rowstart, _colstart);
  définirClipRect();
  définirOrigine();
 
    curseur_x = 0 ;
    curseur_y = 0 ;
}
Vous constaterez que le registre ST7735_MADCTL est mis à jour en fonction de la rotation. Vous verrez ici qu'il configure
la valeur comme pour le cas 0 : ST77XX_MADCTL_MX | ST77XX_MADCTL_MY | ST77XX_MADCTL_RGB

Les valeurs des paramètres tels que : ST77XX_MADCTL_MY sont définies directement dans ce fichier. Les registres sont définis dans le
Fichier ST7735_t3.h.

Que sont définis ces différents réglages MX, MY... dans le manuel de référence du ST7789 ?
Vous pouvez télécharger le fichier à partir de plusieurs sites. Celui que je viens de consulter :
Vous trouverez ces valeurs affichées à plusieurs endroits, comme page : 167(RDDST) 215(MADCTL)
Bonsoir KurtE, merci beaucoup. J'étais un peu incertain de la marche à suivre, mais j'ai trouvé. J'ai augmenté les case de 4 à 7 et j'ai tenu compte des marges pour centre correctement.
 
Translation (by translate.google.com):

Good evening, KurtE. Thank you very much. I was a bit unsure of how to proceed, but I figured it out. I increased the number of cells from 4 to 7 and took the margins into account to center everything correctly.
 
Back
Top