Updating Slider Progress Bar

I have a project where I have five screens with separate progress bars on
each of the screens.
I really would like to just have the Nextion to stand alone and be able to
move each slider to a different position and have it stay where I put it.
I have already build a compass / dual temperature display for my truck.
I can use a arduino but would like to just use the Nextion stand alone
if possible.
New member.
Thanks in advance for any help!
olf20 / Bob

Assign EEProm addresses to store the values. When a page is opened, retrieve the value from the EEProm and assign it to the slider. Whenever the slider changes value, write it to the EEProm. I also store the value in a variable.

Page Preinitialize Event:
repo h0.val,72 // EEProm address: 72-75

Slider Touch Move:
wepo h0.val,72 // EEProm address: 72-75
cov h0.val,vaSpd_Axis.txt,0

Slider Touch Release Event:
wepo h0.val,72 // EEProm address: 72-75
cov h0.val,vaSpd_Axis.txt,0
// Send value to mcu.
print “o” // Ascii 111
print vaSpd_Axis.txt
printh FF // Custom end send string I use.

1 Like

Welcome @olf20!

Not sure if you want to remember the position when you change pages or when you turn it off.

In the first case it‘s sufficient to make the sliders global (attribute vscope).
In the second case @elf is right, you need the EEPROM. However, there are a couple things to note here:

  • EEPROM is only available with Enhanced and Intelligent series displays.
  • EEPROM has a finite lifetime; 100k writes in the case of Nextion I think. If they use flash (which has a typical lifetime of 100k writes) to emulate an EEPROM it could effectively much lower, in the range of ~10k writes. Is is due to the fact that flash can‘t erase a single byte. It has to erase a whole bunch of them, called page. So each time you modify a byte in a page the entire page will be erased and rewritten.
    Long story short: minimize your writes!

Because of the last point I‘d strongly suggest to not trigger writes from the Touch Move event! That code will be executed dozens of times during a movement, only limited by how fast Nextion can run the code. Which also means that the EEPROM will be overwritten dozens of times during that movement. Having the write instruction within the Touch Release event should work just fine and causes only a single write per slider movement.

Kind regards,

1 Like

I agree, the Touch Move code is redundant and shouldn’t be used.

Thanks so much for the help. I knew about eeprom writes and at this time won’t use it.
I did get it working. I had thought previously that I had the sliders set to global, but did not.
One last question;
Where is the list of commands for the Nextions???
Thanks again for your help!!
olf20 / Bob

Glad to hear the global thing worked!

You can find the list of commands when searching for “Nextion Instruction Set”. It brings you to this page: Instruction Set - Nextion

Kind regards,

1 Like