TFT Refresh Problem
-
- Posts: 15
- Joined: Wed Jun 28, 2023 7:20 am
- Been thanked: 1 time
Re: TFT Refresh Problem
Thank you for helping me publish the photo. The photo shows a problem with displaying values. The display gets messy from time to time.
You do not have the required permissions to view the files attached to this post.
- cicciocb
- Site Admin
- Posts: 2095
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 450 times
- Been thanked: 1385 times
- Contact:
-
- Posts: 15
- Joined: Wed Jun 28, 2023 7:20 am
- Been thanked: 1 time
Re: TFT Refresh Problem
Code: [Local Link Removed for Guests]
'simple GUI example
tft.init 1
tft.fill 0
gui.init 30, black 'reserve memory for 20 GUI objects. clears screen to blac
topcom$=""
znak=0
znak1=0
znak2=0
znak3=0
now$=""
today$=""
total$=""
teraz=0
cale=0
poz=0
'txt = GUI.Textline(70,10,190,40, now$, 4) 'x,y,w,h,text,fontsize
'but1 = GUI.Button(20, 180, 120, 40, "Przycisk",3 ,15 ) 'x,y,w,h,text,fontsize
'gui.setevent but1, TOUCH, but1click 'set touched event, jump to buttonclick
'interrupt 39, but1click 'if using M5stack can't click screen- so use left button
Prg1=GUI.ProgressBar(5,135, 312, 20,teraz,0 ,yellow ,black ,white )
Gui.SetRange Prg1, 0, 2800
Prg2=GUI.ProgressBar(5,160, 312, 20,cale,0 ,green ,black ,white )
Gui.SetRange Prg2, 0, 2800
gui.autorefresh 30'display gui items automatically each 30ms including touch
onmqtt mqtt_msg
wlog mqtt.setup("mqtt://test.mosquitto.org", 1)
wlog mqtt.connect("", "") ' No login / pass required
wlog mqtt.subscribe("MT1407/afore/status") ' subscribe to the topic /AnnexTest
timer0 3000, display1
wait
'but1click:
'gui.rect(0,0,320,240,blue)
'gui.settext txt,"Button Pressed" 'change text line.
'return
mqtt_msg:
now$=""
today$=""
total$=""
'topcom$=mqtt.topic$+"#"+mqtt.message$ '
znak=instr(1,mqtt.message$,"webdata_now_p")
znak1=instr(1,mqtt.message$,"webdata_today_e")
znak2=instr(1,mqtt.message$,"webdata_total_e")
znak3=instr(1,mqtt.message$,"webdata_alarm")
now$=mid$(mqtt.message$,znak-1,(znak1-3)-znak+1)
'wlog now$
today$=mid$(mqtt.message$,znak1-1,(znak2-3)-znak1+1)
'wlog today$
total$=mid$(mqtt.message$,znak2-1,(znak3-3)-znak2+1)
'wlog total$
poz=instr(1,now$,":")
now$=mid$(now$,poz+2,len(now$)-(poz+2))
' wlog now$
poz=0
poz=instr(1,today$,":")
today$=mid$(today$,poz+2,len(today$)-(poz+2))
'wlog today$
poz=instr(1,total$,":")
total$=mid$(total$,poz+2,len(total$)-(poz+2))
' wlog total$
return
'////////////////////////////////////////////////////////////////
display1:
'tft. fill 0
tft.text.color yellow, black
tft.text.font 8
tft.text.size 1
tft.text.pos 10, 20
tft.print now$
tft.text.font 4
tft.text.size 3
tft.text.pos 240,35
tft.print "W"
tft.text.font 4
tft.Text.size 2
tft.text.pos 15,190
tft.print today$
' tft.text.font 6
tft.text.pos 170, 190
tft.print total$
teraz=val(now$)
cale=val(total$)
Gui.SetValue Prg1, teraz
gui.setvalue prg2, cale
GUI.refresh
gui.redraw
return
- cicciocb
- Site Admin
- Posts: 2095
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 450 times
- Been thanked: 1385 times
- Contact:
Re: TFT Refresh Problem
Hi,
this is your program "simplified" and using some external fonts, just to show you how you can easily change the font instead of using the internal one (I saw that you was in trouble because the internal font was missing the "W" letter ).
You was using several methods at the same time (GUI.autorefresh + GUI.refresh + GUI.redraw + tft.print ); too much! .
The best is to use only the GUI and using a single event (reception of data) to update the infos on the TFT with a single GUI.refresh
You must upload the files below in a folder named fonts on your module to make it work.
this is your program "simplified" and using some external fonts, just to show you how you can easily change the font instead of using the internal one (I saw that you was in trouble because the internal font was missing the "W" letter ).
You was using several methods at the same time (GUI.autorefresh + GUI.refresh + GUI.redraw + tft.print ); too much! .
The best is to use only the GUI and using a single event (reception of data) to update the infos on the TFT with a single GUI.refresh
You must upload the files below in a folder named fonts on your module to make it work.
Code: [Local Link Removed for Guests]
'simple GUI example
tft.init 1
tft.fill black
gui.init 30, black 'reserve memory for 30 GUI objects. clears screen to blac
tft.loadfont "/fonts/FreeMonoBold45pt7b.bin", 10 'loads font 10
tft.loadfont "/fonts/FreeSans24pt7b.bin", 11 'loads font 11
topcom$=""
znak=0
znak1=0
znak2=0
znak3=0
now$=""
today$=""
total$=""
teraz=0
cale=0
poz=0
'txt = GUI.Textline(70,10,190,40, now$, 4) 'x,y,w,h,text,fontsize
'but1 = GUI.Button(20, 180, 120, 40, "Przycisk",3 ,15 ) 'x,y,w,h,text,fontsize
'gui.setevent but1, TOUCH, but1click 'set touched event, jump to buttonclick
'interrupt 39, but1click 'if using M5stack can't click screen- so use left button
Prg1=GUI.ProgressBar(5,120, 310, 20,teraz,0 ,yellow ,black ,white )
Gui.SetRange Prg1, 0, 2800
Prg2=GUI.ProgressBar(5,145, 310, 20,cale,0 ,green ,black ,white )
Gui.SetRange Prg2, 0, 2800
Txt1 = GUI.Textline(5,0,310,100, now$, 10, yellow, black, white, ALIGN_MID_MID)
Txt3 = GUI.Textline(5, 180, 160, 60, today$, 11)
Txt4 = GUI.Textline(175, 180, 140, 60, total$, 11)
'gui.autorefresh 100'display gui items automatically each 100ms including touch
onmqtt mqtt_msg
wlog mqtt.setup("mqtt://test.mosquitto.org", 1)
wlog mqtt.connect("", "") ' No login / pass required
wlog mqtt.subscribe("MT1407/afore/status") ' subscribe to the topic /AnnexTest
wait
mqtt_msg:
now$=""
today$=""
total$=""
'topcom$=mqtt.topic$+"#"+mqtt.message$ '
znak=instr(1,mqtt.message$,"webdata_now_p")
znak1=instr(1,mqtt.message$,"webdata_today_e")
znak2=instr(1,mqtt.message$,"webdata_total_e")
znak3=instr(1,mqtt.message$,"webdata_alarm")
now$=mid$(mqtt.message$,znak-1,(znak1-3)-znak+1)
'wlog now$
today$=mid$(mqtt.message$,znak1-1,(znak2-3)-znak1+1)
'wlog today$
total$=mid$(mqtt.message$,znak2-1,(znak3-3)-znak2+1)
'wlog total$
poz=instr(1,now$,":")
now$=mid$(now$,poz+2,len(now$)-(poz+2))
' wlog now$
poz=0
poz=instr(1,today$,":")
today$=mid$(today$,poz+2,len(today$)-(poz+2))
'wlog today$
poz=instr(1,total$,":")
total$=mid$(total$,poz+2,len(total$)-(poz+2))
' wlog total$
gui.settext Txt1, now$ + "W"
gui.settext Txt3, today$
gui.settext Txt4, total$
teraz=val(now$)
cale=val(total$)
Gui.SetValue Prg1, teraz
gui.setvalue prg2, cale
gui.refresh
return
You do not have the required permissions to view the files attached to this post.
-
- Posts: 15
- Joined: Wed Jun 28, 2023 7:20 am
- Been thanked: 1 time
-
- Posts: 15
- Joined: Wed Jun 28, 2023 7:20 am
- Been thanked: 1 time
Re: TFT Refresh Problem
Hello. There is still something wrong with the display. I followed the instructions provided, but after a while the display becomes a mess again
You do not have the required permissions to view the files attached to this post.
- Electroguard
- Posts: 886
- Joined: Mon Feb 08, 2021 6:22 pm
- Has thanked: 285 times
- Been thanked: 329 times
Re: TFT Refresh Problem
The 'mess' is caused by text spaces over-writing and obliterating the borders.
You can show that up for yourself by writing the text using a different colour text background.
To fix it you either need to write shortened text msgs that fit within the borders, or re-write the borders after writing new text msgs.
You can show that up for yourself by writing the text using a different colour text background.
To fix it you either need to write shortened text msgs that fit within the borders, or re-write the borders after writing new text msgs.
-
- Posts: 15
- Joined: Wed Jun 28, 2023 7:20 am
- Been thanked: 1 time
Re: TFT Refresh Problem
And how to eliminate it?
You do not have the required permissions to view the files attached to this post.
-
- Posts: 15
- Joined: Wed Jun 28, 2023 7:20 am
- Been thanked: 1 time
Re: TFT Refresh Problem
It is incomprehensible to me that for some time the display shows the data correctly, and then something starts to break. If he were
An error in the code would show badly after initialization. After all, the command to refresh gui objects is used.
An error in the code would show badly after initialization. After all, the command to refresh gui objects is used.
- Electroguard
- Posts: 886
- Joined: Mon Feb 08, 2021 6:22 pm
- Has thanked: 285 times
- Been thanked: 329 times
Re: TFT Refresh Problem
You do not have the required permissions to view the files attached to this post.