Closed PeterBowater closed 1 year ago
Realised I ought to add why I was having trouble with myNex.currentPageId, using the same code above, replacing the writeStr/writeNum values with:
myNex.currentPageId
Results in a 0 every time.
Also after some further experimentation:
currentPage = myNex.readNumber("dp"); if(currentPage != lastCurrentPage){ myNex.writeStr("gearposition.txt", String(currentPage)); myNex.writeNum("pageNum.val", currentPage); lastCurrentPage = currentPage; }
Results in alternating -1 and actual page number. Is -1 a default return if undefined/not completed yet?
Try this first NOTE: As these commands are using the Serial port to read and write, it is more preferred not to run them in the loop() without delay(); or some other method of not running them with the frequency of the loop and use them only when it is needed. Using them in a loop, a delay in the loop can be noticed, especially when reading from the Serial. A Serial buffer overflow can also be caused. Also NOTE: (from the Nextion Editor Guide)
https://github.com/Seithan/EasyNextionLibrary#function-documentation
Hi!
Hope you can help, I've been working on a digital dash project and came across your library which makes things WAAAY cleaner for my use.
Firstly, a quick summary of the hardware/software:
Firstly, I was having trouble getting the currentPage value, and when trying to get it using the global dp variable it was REALLY slow, so abandoned that and went looking for a different solution.
My idea was to trigger a function by getting the Nextion to send a hex string as documented such as :
printh 23 02 54 01
as per:
01 for page 1, 02 for page 2 on the button touch release event. That appears to work fine in the Nextion simulator/debug, and sometimes it works OK when changing page, the Arduino picks it up and will set the global Arduino Int to the current page, which I push out to the Nextion for testing inside the loop().
Sketch as an example:
I've reduced the code to a minimum above (and have tried this here as well) with the same results, it doesn't always update the page number, I'll sometimes end up with page three showing '1' or '2', page one showing '2' or '3' etc.
Am I doing something wrong? Any ideas?
Thanks very much!
Peter.