Efficient updating of progress bar value

I’ve done a few Nextion-based projects but would not consider myself an expert. Now I have a project where I will need to update the position value of a progress bar about once every 30ms. It seems to me that sending progbar1.val=xxx to the display every 30ms is quite inefficient as the display has to lookup progbar1 to determine its ID every time.

So I experimented with sending b[n].val=xxx and that seems to work fine. I assume that this bypasses the component name lookup and, of course, it is fewer characters to send via the serial interface. But is it actually more efficient (fewer display clock cycles)? Or is there a better way? Is it even necessary/desirable/good coding practice?

Grateful for any advice.

Well I put together a test rig today and somewhat surprisingly it makes no difference whether I use progbar1.val=xxx or b[n].val=xxx to update the progress bar. Similar results with updating a text field. Eventually, at around 1 update every 10ms, there is no further improvement in actual refresh rate, so I suppose at that point something in the display is limiting but it does not seem to be the processor. It looks like the delay from sending an update to it being displayed is around 7ms. Perfectly adequate!

Worth stating that I am using the Intelligent 5" display, which has the faster processor. Initially I was driving the serial I/O at 115200 baud but changing to 512000 baud made no difference. Even at 115200 baud the serialisation delay for the update message is inconsequential: only around 1ms.

On that basis I will probably revert to using the progbar1.val=xxx method, even though it offends my sense of what constitutes efficient code because it seems that component ID numbers change somewhat arbitrarily and that could produce some very odd bugs!

This was a useful exercise for me and I hope the results might be helpful for others.

1 Like

Have a look at the reparse mode where you take control of the serial port and you can then just send a delimited data to the display , you then process that on the display no need to use libraries and send progbar1.val=xxx or b[n].val=xxx you just send the values eg %,43,66,99,9,45… CRC (% header) you then parse the data on the display knowing the position of the value you want and update any or all the values on the page also giving the objects a meaninful value instead of progbar1 eg pb1 also helps .

1 Like

Thanks Paul. I looked at reparse mode briefly but didn’t make any meaningful progress with it at the time. As it happens, for my current application the standard methods are perfectly satisfactory but I really should try to understand reparse mode. I will put a bit more effort in!