Start a new topic

Nextion reading number from Arduino

 Hi,

Ive been messing around with the Nextion display, Im using the libraries that nextion provide too. I have a number window called n0 that just stored the current value of the thsp timer for the period without touch activity. Its off by default but im trying to give the thsp a default value stored in the code of the Arduino at 30seconds. I have it set so that on power up the thsp value will be 30 seconds by default and the value is shown in n0 whereit can be changed by the user. I can change the value and it updates in n0 but that is handled on the nextion device rather than the Arduino for the moment. Right now when i boot up the nextion n0 has a value of 0.

Im trying to read the value and set it too, im using the following to try and get the value but it doesn't appear to work. Ihave the number box declared like so

NexNumber n0 = NexNumber(1, 7, "n0");  //page 1, id 7, name of object: n0

I also have n0 added to the NexTouch *nex_listen_list[]

when i press a button under the popcallback i do the following:

n0.getValue(&mynumber);

although this doesn't seem to work.

Any ideas?


1 Comment

Is there a reason why the Arduino is needed for this to be accomplished

Inside the page0 preinitialize event you could place the line

thsp=30

setting this to 30 as the default for the display

on page1 postinitialize event you could place the line

n0.val=thsp


This is a predetermined value at HMI design time.

You could possibly alter this by sending

SendCommand("thsp=45")

from the Arduino, but is the Arduino really making the decision for this?


You may want to look at the thread problems with thsp=0

http://support.iteadstudio.com/support/discussions/topics/11000005859


It seems once thsp is set, it can not be retracted back to its default setting of 0.

Login or Signup to post a comment