Start a new topic

Value EVENTS

So much like the push and pop events in the arduino library, I have added Value Events.  (currently supports unsigned long data).  I will extend this to support strings.


Since this is not yet supported in the Nextion IDE I have to create the commands using several print commands.

 

printh 72
  // new command for Value Events
printh 01
  // Page Number
printh 0a
  // Object Number
printh 02
  // Event Type (Value)
print CoolW.val
  // Component Value
printh 0
  // Termination ( will be used for strings)
printh FF FF FF // Command termination

 

From the Arduino code you do the following:

  

unsigned long MySliderVal;
NexSlider MySlider     = NexSlider(1, 10, "MySlider", &(MySliderVal); 
MySlider.attachValue(MyValueCallback, &MySlider);
void MyValueCallback(void *ptr) 
{
   Serial.print("Name: ");
   Serial.print(((NexText *)ptr)->getObjName());
   Serial.print(" Value: ");
   Serial.println(*((unsigned long *)(((NexText *)ptr)->getObjValue())));
}

 So in this example when you move the slider, the display will automatically send the command using the print statements.  Then the arduino will get the event and call the MyValueCallback function, and the object will automatically have the value of the slider.  No more need to get the push event, and then use the get command to figure out what the value is at.


The arduino code is under git hub:

bspranger/ITEADLIB_Arduino_Nextion


**********************************************

Nextion Can you make this a standard command?  IE.  Implement Value events so we do not have to use the Print commands. 


7 people like this idea

Dear Bspranger,


As you see, we are trying to  optimize the Nextion editor and the Nextion library ,we will consider your advice . 


Thanks for your attention.  

 


1 person likes this

I am now reviewing all of the Feature Requests, this will take some time, patience please.

- I would caution making the Editor output Arduino only, there are many many other mcus in play.

Further work on the Arduino Library will be carried forward


Login or Signup to post a comment