Page 1 of 1

M5STACK TFT mirrored horizontally

Posted: Sun Aug 29, 2021 10:07 am
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

Re: M5STACK TFT mirrored horizontally

Posted: Sun Aug 29, 2021 10:34 am
by Kabron
OK now with esp32_release_1.43.5

Re: M5STACK TFT mirrored horizontally

Posted: Sun Aug 29, 2021 5:10 pm
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

Re: M5STACK TFT mirrored horizontally

Posted: Sun Aug 29, 2021 5:47 pm
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).

Re: M5STACK TFT mirrored horizontally

Posted: Mon Aug 30, 2021 3:29 pm
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