Nextion Display Problem with attachPop

Hello,

I am currently working on a Nextion Display with an Arduino Due. I want to keep track of the current page on the display, therefore I want to update the variable pageNum every time the swtichPage button is pressed.

header:

#ifndef _DISPLAY_h
#define _DISPLAY_h

#include "Nextion.h"

class CDisplay {
public:
  CDisplay();
  void init();
  void process();
  void switchPagePopCallback(void * ptr);
  NexTouch *nex_listen_list[];

private:
  uint16_t Voltage;
  NexText t_Vol;
  NexButton switchPage;
  char voltString[];
  uint8_t pageNum;
};

#endif

cpp:

#include "Display.h"

CDisplay::CDisplay():
  t_Vol(0,2,"t_Vol"),
  switchPage(0,3,"switchPage"){
  int Voltage = 0;
  char voltString[]=" V";
  uint8_t pageNum=1;
}

void CDisplay::switchPagePopCallback(void *ptr){
  pageNum= 2;
}

void CDisplay::init(){
  Serial3.begin(9600);
  nexInit();

  NexTouch *nex_listen_list[]{
    &switchPage,
    NULL
  };
  switchPage.attachPop(switchPagePopCallback,&switchPage);
}

void CDisplay::process(){
  char tbuff[10];
  char tbuff2[10];
  utoa(Voltage/10,tbuff,10);
  utoa(Voltage-(Voltage/10)*10,tbuff2,10);
  strcat(tbuff,".");
  strcat(tbuff,tbuff2);
  strcat(tbuff,voltString);
  t_Vol.setText(tbuff);
}

Main:

#include <Arduino.h>
#include "Display.h"

CDisplay Display;

void setup() {
  // put your setup code here, to run once:
  Display.init();
}

void loop() {
  // put your main code here, to run repeatedly:
  Display.process();
}

When compiling this error occures:

exit status 1
no matching function for call to ‘NexButton::attachPop(, NexButton*)’

If I programm the code in one file (w/o a seperate display class) everything works fine…

I would be very grateful for any kind of advice!

jamalbear:
I would be very grateful for any kind of advice!

Don't use non static member functions for callbacks, they only accept plain (or static) functions.