prenticedavid / MCUFRIEND_kbv

MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Other
363 stars 181 forks source link

SSD1963 on ArduinoMega2560, display output is mirrored #251

Closed Dinnstach closed 7 months ago

Dinnstach commented 7 months ago

I connected a 7 inch display with SSD1963 controller to an ArduinoMega 2560. The examples graphictest_kbv.ino and Fontsimple.ino work but the text output is mirrored in every orientation. I used _tft.begin(0x1963);__. All examples with UTFT Library don't work for me. What can I do?

Dinnstach commented 7 months ago

I found the following solution: In MCUFRIEND_kbv.cpp

void MCUFRIEND_kbv::setRotation(uint8_t r)
{
uint16_t GS, SS_v, ORG, REV = _lcd_rev;
uint8_t val, d[3];
rotation = r & 3;           // just perform the operation ourselves on the protected variables
_width = (rotation & 1) ? HEIGHT : WIDTH;
_height = (rotation & 1) ? WIDTH : HEIGHT;
switch (rotation) {
case 0:                    //PORTRAIT:
    val = 0x08;             //MY=0, MX=1, MV=0, ML=0, BGR=1 (previously 48)
    break;
case 1:                    //LANDSCAPE: 90 degrees
    val = 0x88;             //MY=0, MX=0, MV=1, ML=0, BGR=1 (previously 28)
    break;
case 2:                    //PORTRAIT_REV: 180 degrees
    val = 0xD8;             //MY=1, MX=0, MV=0, ML=1, BGR=1 (previously 98)
    break;
case 3:                    //LANDSCAPE_REV: 270 degrees
    val = 0x78;             //MY=1, MX=1, MV=1, ML=1, BGR=1 (previously F8)
    break;
}

...