Start a new topic

return to last page

ok, I have to say - 3 pages. all 3 have timer to go on 4th page

on the 4 is a dual stat button. Now, here I need to put a timer to return in last page;

if I was on page 2,after 2 sec that go to button on 4, then need to return back on 2, also for  others pages.
  that to not make more pages, who take more space...
No enhanced display.
 Thank you !

Perhaps a programming technique involving the use of variables.

Before jumping to page3, set sys2=(page#)

Then on page3 put the code to return in the button event code



page 0





page 1





page 2


  I cannot make it to work this.
if press S1 button, then move on page 2 to send another command and back to S1, S2 (or on S3,4 page)

and this return, can be made it if no activity on page 2 after x seconds?


tell me what each of the four buttons are suppose to do, what the purpose/function is

- I see that each button sends 00 0x where x was the button number

why the timer?

What task are you trying to complete - I will try to help.

The example I gave above was would function more like a Back Button in a browser and return to the page that called it.  But the 2 second timers end up driving the logic as they are interrupting and executing their code/commands.

OK Patrick, thank you for reply and your time !

  so, page 0 touch button S1 to send 00 01 to select an serial device; 

then, the timer is to forward on page 2 where  I need to push the button for that serial device.

again the same for S2, 3 and S4 button, where button from page 2 make the same thing, but for different devices, hope you get it.

 now, if I am on page 1, push S3, then timer move me on page 2 . here, i give command (push) and if I do nothing on that page for 3-6 seconds will be perfect to return me on last page of action (page 1 in that case).
   the timer in page 2 is there because I don't know how to move back..

So if I understand you have 4 serial devices  Two on each page (s1/s2 page 0) (s3/s4 page 1)

each serial device will receive the same command from the dual state on page 2

then return to the page that called page2.

Do you intend to


- show page 0 for two seconds

- show page 1 for two seconds

goto start

where if button pushed before timer times out

- goto page 2 : issue command,

- return to calling page (where page0/page1/page0/page1 cycle continues) ?

I am not sure why the page cycles:  If I had 4 buttons on a page, I could push the button and have the commands issued from that button, there would be no need to cycle.

can more than one serial be selected at the same time? (If so we use a dual state button)

If only one serial can be selected at a time - we configure routine as a radio button

If timer on page 2 is only because of trying to return to "calling page" then we can lose the timer.

Understanding why the timer loop is important.

If we are cycling through the serial devices, where each is on for x seconds, then that can be programmed to be automatic and have that from the one page as well.

It seems like a lot of clicks for the user in very rapid succession.

Or perhaps

for the button on page 2, it needs to know which button was pressed.

It is simple enough to send which button was pushed before arriving at page 2

(Is there a reason the button on page 2 is a dual state?)

One more, then I wait for your answers

button s1 sends an 01

button s2 sends an 02

button s3 sends an 03

button s4 sends an 04

dual-state button sends 00 70 3F? - there is an error there

In the loop the MCU will receive 01 when button s1 is pressed, but if possible to not receive the remaining from bt0 if the dualstate is not pressed.

Separating the one command into two segments makes more coding required on your MCU

1) to deal with setting up the serial the button was pushed from

2) dealing with whether or not the dual-state button is pressed or not

This possibly could be simplified by wrapping it into just one command that the MCU deals with based on the s1 button having been pressed ...

So if I understand more - I will be able to help you accomplish it.

1 person likes this

sorry for late answer, i need it to go in town..

 Patrick, I give an simple example with what I need, but on a page is more buttons, not only 2. 

If you have time to see my project from HERE , look on video from 0.40 sec to 1.45 sec.

from 0.40s you can see I select a page, with many buttons, this is for a radio band, each button for a specific frequency in that band.

 On min 1.20 sec at video I push an mechanic button for transmission to air (red LED light then) on frequency selected with Nextion buttons. Now, I make an electronic circuit to replace the mechanic button with the button like from page 2 in my example.

On others pages, it is another groups of radio frequency bands, for that I need to return precisely on latest group of working frequency,  not on other bands..

 If if more complicated , don't lose your time, I made a button like on page 2 for each bands (page) and problem is solved, but space is a little limited  I think.

 BTW, how we can see the free space remain on Nextion display?

to answer the free space remaining question first:

In the Status Bar of the Nextion Editor, your model shows, followed by size followed by FLASH:

The example HMI you gave was for the 3.5" Model with 16MB Flash

When you compile your project at the end it states something like:

Compile Successful! 0 Errors, 0 Warnings,File Size:109768

Subtract your File Size from your Flash Size.

16MB is 16,777,216. (though not sure 16MB Flash is exactly 16MB - should be close within a few KB)

I saw your project from the other thread - looking good.

Okay: So see the HMI attached that I modified

Removed any Page PreInitialize, PostInitialize, Touch Press and Touch Release Events

removed  not used va0 from all three pages

Timer on page 0 waits 2 seconds then moves to page 1

Timer on page 1 waits 2 seconds then moves to page 0

When buttons s1/s2/s3/s4 is pressed

Pressed Event is printh 30 xx // where x is button number sent to MCU

When buttons s1/s2/s3/s4 is released

sys2=x // where x is the page to return to

page 2 // jumps to page 2

Timer on page 2 set for 5 seconds will return to calling page if nothing happens

Timer Event Code:



page 0





page 1



Dual State Relase Event

sends printh 00 70 3F to the MCU and then returns to calling page



page 0





page 1



Hope this is of help.


2 people like this

 Thank you Patrick, for your time , kindness and great help !

now I have to work on hardware  :)

Mr. Patrick,

I used code with one of my project, i am facing a problem that all values on that page restarts from zero.

why, could you please light of it and what i have to do to make all functions continues.


Page Preinitialize

Page as per HMI design

Page Postinialize

If you are needing some value to persist, you must make use or Pre and Post

- when the page changes, the old is dumped, but after Pre and the new page.

When a page is not current, it is not in memory.

Nextion SRAM is 8K to 20K of which is shared with firmware

HMI portion is 3584 Bytes in Basic Models, and up to 8192 Bytes in Enhanced

Login or Signup to post a comment