M5STACK TFT mirrored horizontally

Here we can discuss about the problem found
Post Reply
Kabron
Posts: 2
Joined: Sun Aug 29, 2021 9:53 am

M5STACK TFT mirrored horizontally

Post by Kabron »

FW Annex32 WiFi 1.41 beta 5
I tested with M5 fire, but I guess it concerns all models.

Code: [Local Link Removed for Guests]

gui.init 20, black  'reserve memory for 20 GUI objects. clears screen to black

txt = GUI.Textline(10,50,190,20, "Text Line Here", 2)  'x,y,w,h,text,fontsize

but = GUI.Button(20, 200, 100, 20, "BUTTON!",2 ) 'x,y,w,h,text,fontsize
Kabron
Posts: 2
Joined: Sun Aug 29, 2021 9:53 am

Re: M5STACK TFT mirrored horizontally

Post by Kabron »

OK now with esp32_release_1.43.5
Jan Volk
Posts: 71
Joined: Wed Mar 03, 2021 1:35 pm
Been thanked: 23 times

Re: M5STACK TFT mirrored horizontally

Post by Jan Volk »

Hi Kabron

Tested with version 1.43.5 and black screen result.
Now tested with the entire example from my manual and works perfectly.
I don't have a touch screen on my M5stack black.
If I make the choice in Config Options M5stack then an inverted screen and with M5stack #2 a normal screen.

' simple GUI example.
gui.init 20, black ' spare memory for 20 GUI objects makes the screen black.
txt = GUI.Textline(10, 50, 190, 20, "Text Line Here", 2) ' x, y, w, h, text, fontsize.
but = GUI.Button(20, 200, 100, 20, "BUTTON!", 2) ' x, y, w, h, text, fontsize.
gui.setevent but, TOUCH, buttonclick ' set touched event, jump to buttonclick.
interrupt 39, buttonclick ' if using M5stack can't click screen, so use the left button.
gui.autorefresh 30, 1' gui items automatically every 30ms including touch.
wait
button click:
gui.settext txt, "Button Pressed" ' change line of text.
return
User avatar
Electroguard
Posts: 836
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 268 times
Been thanked: 317 times

Re: M5STACK TFT mirrored horizontally

Post by Electroguard »

I have been testing dynamic layouts on different TFT screens and sizes - including M5stack - and it seems that the Annex Config setting is absolute whereas the TFT.init setting is relative to the Config setting.

So in practice I found the display orientation can be changed simply by using an appropriate TFT.ini setting at the top of the script, as in this snippet:

Code: [Local Link Removed for Guests]

M5stack=2                         '0 for touch buttons only, 1 for M5stack hardware buttons only, 2 for both
'touch.calib: reboot              'uncomment to run once and re-calibrate after changing screen orientation      
Xres=320: Yres=240                'TFT screen size 
'Xres=480: Yres=320               'TFT screen size for 4"
orientation=1                     '0=Portrait, 1=Landscape, 2=Portrait reversed, 3=Landscape reversed
background=blue
tft.init orientation
gui.init 25, background 
Not all of the variables are necessary for orientation, for instance the M5stack value is just used as a flag to enable/disable GUI touchbuttons and or hardware buttons.
GUI objects depend on the existing TFT configuration, so may require an appropriate TFT.init added at top of script to set the required orientation
(and any orientation change should be followed by touchscreen calibration, of course).
User avatar
cicciocb
Site Admin
Posts: 1900
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 407 times
Been thanked: 1269 times
Contact:

Re: M5STACK TFT mirrored horizontally

Post by cicciocb »

HI all,
just to clarify :

- The display model must be selected in the config page and cannot be changes
- The orientation is set in the config page BUT can be also changed in the code
Post Reply