Start a new topic

PopCallback not occuring

I am sure this is a stupid mistake but I have spent hours trying to find my stupid mistake.

When I tap n0 on page0 I am not seeing the component ID come across the dbserial.


Then settemp hotspot on page2 work fine and I don't see the difference here.

 

//nextion's listen list
NexTouch *nex_listen_list[] =
{
  &n1,
  &settemp,
  NULL
};


//callback functions
void n1PopCallback(void *ptr=NULL)
{
  Serial.println("n1PopCallback");
  OnTempEditPage=true;
}

void settempPopCallback(void *ptr=NULL)
{
  Serial.println("settempPopCallback");
  OnTempEditPage=false;
}

void setup() {
  // put your setup code here, to run once:
  nexInit();
  Serial.println("nexinit");
  
  n1.attachPop(n1PopCallback); 
  //Serial.println("Temperature.attachPop");
  settemp.attachPop(settempPopCallback);
  //Serial.println("settemp.attachPop");
  counter=millis();  //for testing until temp sensor


}

void loop() {
  // put your main code here, to run repeatedly:
  
  if (millis()-counter>2000)  //for testing until temp sensor
  {
    counter=millis();
    CurrentTemperature++;
    TempChanged=true;
  }
  nexLoop(nex_listen_list);
  if (TempChanged)
  {
    n0.setValue(CurrentTemperature);
    n1.setValue(CurrentTemperature);
    TempChanged=false;
  }
}

 

hmi
(533 KB)

in the above post the second sentence should read

"When I tap n1 on page0 I am not seeing the component ID come across the dbserial."

I also failed to include the following code at the top of the code above...

 

#include "Nextion.h"
long unsigned int counter=0;
uint32_t CurrentTemperature = 99;
uint32_t number = 0;
bool OnTempEditPage=false;
bool TempChanged=false;

//define all nextion elements used by arduino code
NexNumber n1 = NexNumber(0,1,"n1");
NexNumber n0 = NexNumber(2,9,"n0");
NexHotspot settemp = NexHotspot(2,3,"settemp");

 

Please confirm code above

 - Variable declarations missing

 - #includes missing.

such code would not compile

Confirm the Version of the Iteadlib Arduino Nextion Libraries used.

Perhaps share your solution for those that follow

As assumed in the initial post it was a stupid mistake. After scrapping the entire Arduino code and restarting I realized that  

NexNumber n1 = NexNumber(0,1,"n1");

 should have read

 

NexNumber n1 = NexNumber(0,2,"n1");

 

Login or Signup to post a comment