|
Post by andromeda92 on Jul 21, 2019 17:27:43 GMT -8
Hi,
how to display text on multiple events without doing a clear and a swap so that the text is displayed in one go
for example in my case I want to display text when an event appears, using esp8266 which connects to a server I want to display:
cmd_text (...) connection start after ...
wifi connected ... end connection etc.
thanks for your help
|
|
|
Post by tftlcdcyg on Jul 21, 2019 21:56:07 GMT -8
Try something like this:
int displayinfo=0; long previousMillis = 0; long interval =5000;
unsigned long currentMillis = millis(); if(currentMillis - previousMillis > interval) { previousMillis = currentMillis; displayinfo=displayinfo+1; if(displayinfo>=3){displayinfo=0;} }
if(displayinfo==0){GD.cmd_text(GD.w / 2, 25, 26, OPT_CENTER, "Connection start after...");} if(displayinfo==1){GD.cmd_text(GD.w / 2, 25, 26, OPT_CENTER, "Wifi connected");} if(displayinfo==2){GD.cmd_text(GD.w / 2, 25, 26, OPT_CENTER, "End connection");}
|
|
|
Post by andromeda92 on Jul 22, 2019 6:28:07 GMT -8
yes but if on the loop i put GD.Clear(), and at bottom the loop i put GD.swap(), in your case only one line is displayed with a different message, I want the message to appear in a different line and that the three message remains display to simulate a progress of actions for example GD.cmd_text(10,10,28,0,"Connection start after..."); (after one event) GD.cmd_text(10,40,28,0, "Wifi connected"); ... the line of cmd_text is different. the problem is GD.clear() because it clear the screen, and it's not possible to put GD.swap() only without GD.Clear().
may be it's possible with copy text to memory (memorywrite and copy) ?
|
|
|
Post by tftlcdcyg on Jul 22, 2019 6:36:42 GMT -8
Ok, try this:
if(displayinfo==0){ GD.cmd_text(GD.w / 2, 10, 28, OPT_CENTER, "Connection start after..."); } if(displayinfo==1){ GD.cmd_text(GD.w / 2, 10, 28, OPT_CENTER, "Connection start after..."); GD.cmd_text(GD.w / 2, 30, 28, OPT_CENTER, "Wifi connected"); } if(displayinfo==2){ GD.cmd_text(GD.w / 2, 10, 28, OPT_CENTER, "Connection start after..."); GD.cmd_text(GD.w / 2, 30, 28, OPT_CENTER, "Wifi connected"); GD.cmd_text(GD.w / 2, 50, 28, OPT_CENTER, "End connection"); } Instead of:
if(displayinfo==0){GD.cmd_text(GD.w / 2, 25, 26, OPT_CENTER, "Connection start after...");} if(displayinfo==1){GD.cmd_text(GD.w / 2, 25, 26, OPT_CENTER, "Wifi connected");} if(displayinfo==2){GD.cmd_text(GD.w / 2, 25, 26, OPT_CENTER, "End connection");}
|
|
|
Post by andromeda92 on Jul 22, 2019 12:24:09 GMT -8
yes indeed this solution works, I think it's the only possible solution. thank you so much
|
|
|
Post by leejsmith on Nov 5, 2019 12:37:52 GMT -8
yes indeed this solution works, I think it's the only possible solution. thank you so much I know this is old, but I just did something similar to this and wanted to share. if you do the if (value = 1) will only display at that time so you will have to draw each line of text for each value increase the no of lines drawn each time as per the original post . so if you do this if(displayinfo==0){ GD.cmd_text(GD.w / 2, 10, 28, OPT_CENTER, "Connection start after..."); // this will only display when it = 0 and then stop when it's > 0 } if(displayinfo>0){ GD.cmd_text(GD.w / 2, 10, 28, OPT_CENTER, "Connection start after..."); // this will display after the value is 1 and continue to display both lines GD.cmd_text(GD.w / 2, 30, 28, OPT_CENTER, "Wifi connected"); } if(displayinfo>1){ GD.cmd_text(GD.w / 2, 50, 28, OPT_CENTER, "End connection"); // this will display when the value is 2 and after and the previous text will still be shown. } you can keep adding new lines of text one line as a time. for my code I added a millis() command so I could time it better.
|
|
|
Post by andromeda92 on Nov 26, 2019 5:04:01 GMT -8
yes indeed it works as you say, it's better. thank you.
|
|