Nextion basic display page problem

Hi, I am using nextion 2.4inch display it is basic model with esp32. The only problem I am facing is that, I want to stop nextion to refresh its pages whenever I exit them. for example I have 2 pages: page 0 and page 1, on page 1 I have a slider and button the default position of slider is 50per and by default button is off position, now I turned the button ON and my slider is now on 30per,now when ever I go back to page 0 and come back to page 1 all my components are back to there default position like slider is back to 50per and button is back to off position. How can I stop this ? I cant find anything related to this online

In the Nextion IDE click on your slider. In the list of attributes down the right hand side look for vscope, change it to global. The slider should keep its value when you go away from and return to the page.

Note that doing this uses more memory on the Nextion so for a big project you might run into problems. I would not do it this way, I would save the current value of the slider on the ESP32 and send it to the slider when selecting the page.

See Using Nextion displays with Arduino for more help.

1 Like

hi thanks I figured it out, if I store that value on nextion in variable and then use that variable in preinitialization of page even then more memory will be used ?

If you store it in a variable the variable has to be global otherwise it too will lose its value when you change pages. You are just making things more complicated and using more memory for no improvement. When you compile the Nextion configuration it tells you how much memory you have used, so check that.

thank you for your time.I figured everything out :smiley:

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.