Cannot convert 'NexNumber' to 'double' in assignment

Hello @ScruffR

Good day, I’m working with a “Particle electron” and a HMI “Nextion”, I’m trying to enter a numeric value “Setpoint”, but when I compile the following message is shown:
cannot convert ‘NexNumber’ to ‘double’ in assignment

In this section I register my variable that is n6:

void b0PopCallback(void *ptr);
void n6PopCallback(void *ptr);
void b1PopCallback(void *ptr);
void b2PopCallback(void *ptr);
void n7PopCallback(void *ptr);
void b3PopCallback(void *ptr);
void b4PopCallback(void *ptr);

NexNumber n0 = NexNumber(0, 10, "n0");
NexNumber n1 = NexNumber(0, 11, "n1");
NexNumber n2 = NexNumber(0, 12, "n2");
NexNumber n4 = NexNumber(0, 13, "n4");
NexNumber n5 = NexNumber(0, 14, "n5");
NexButton b0 = NexButton(0, 15, "b0");

NexNumber n6 = NexNumber(5, 12, "n6");
NexButton b1 = NexButton(5, 8, "b1");
NexButton b2 = NexButton(5, 9, "b2");

NexNumber n7 = NexNumber(5, 13, "n7");
NexButton b3 = NexButton(5, 10, "b3");
NexButton b4 = NexButton(5, 11, "b4");

char buffer[100] = {0};

NexTouch *nex_listen_list[] = 
{
    &n0,
    &n1,
    &n2,
    &n4,
    &n5,
    &b0,
    &n6,
    &b1,
    &b2,
    &n7,
    &b3,
    &b4,
    NULL
};
// BINARY INPUTS
void n6PopCallback(void *ptr)
{
    dbSerialPrintln("n6PopCallback");
    n6.setValue(3);
}

void b1PopCallback(void *ptr)
{
    uint32_t number;
    
    dbSerialPrintln("b1PopCallback");

    n6.getValue(&number);
    
    number += 1;
    
    n6.setValue(number);
}

void b2PopCallback(void *ptr)
{
    uint32_t number;
    
    dbSerialPrintln("b2PopCallback");

    n6.getValue(&number);
    
    number -= 1;
    
    n6.setValue(number);
}

            /* Setpoint glycol differential */

void n7PopCallback(void *ptr)
{
    dbSerialPrintln("n7PopCallback");
    n7.setValue(3);
}

void b3PopCallback(void *ptr)
{
    uint32_t number;
    
    dbSerialPrintln("b3PopCallback");

    n7.getValue(&number);
    
    number += 1;
    
    n7.setValue(number);
}

void b4PopCallback(void *ptr)
{
    uint32_t number;
    
    dbSerialPrintln("b4PopCallback");

    n7.getValue(&number);
    
    number -= 1;
    
    n7.setValue(number);
}

plus everything else that my project takes.

and in this section is where I want to take the value that I enter from my HMI:

void updateSystemVariables(){

    VAL_PRODUCT_TEMP = analogRead(IN_PRODUCT_TEMP);
    // ***** invalid mapping range - just for testing
    VAL_PRODUCT_TEMP = map(VAL_PRODUCT_TEMP, 0.0, 4095.0, -10.0, 50.0);

    delay(5);
    VAL_PRODUCT_SP = n6;
    /* VAL_PRODUCT_SP = analogRead(IN_PRODUCT_TEMP_SP); */
    // ***** invalid mapping range - just for testing
    /* VAL_PRODUCT_SP = map(VAL_PRODUCT_SP, 0.0, 4095.0, -10.0, 50.0); */

    delay(5);
    VAL_GLYCOL_TEMP = analogRead(IN_GLYCOL_TEMP);
    // ***** invalid mapping range - just for testing
    VAL_GLYCOL_TEMP = map(VAL_GLYCOL_TEMP, 0.0, 4095.0, -10.0, 50.0);

    delay(5);
    VAL_GLYCOL_DIFF = n7;
    /* VAL_GLYCOL_DIFF = analogRead(IN_GLYCOL_DIFF); */
    /* VAL_GLYCOL_DIFF = map(VAL_GLYCOL_DIFF, 0.0, 4095.0, -10.0, 10.0); */

    VAL_GLYCOL_SP = VAL_PRODUCT_SP + VAL_GLYCOL_DIFF;
    if(VAL_GLYCOL_SP > 50){
        VAL_GLYCOL_SP = 50;
    }
    if(VAL_GLYCOL_SP < -10){
        VAL_GLYCOL_SP = -10;
    }
}

I can not find how I can put the value or convert that value to be able to take it in my code.

thanks

Would be good to know which line featureing n6 throws that error.

BTW, instead of assigning the objects like this

NexNumber n0 = NexNumber(0, 10, "n0");

you should rather directly instantiate them like this

NexNumber n0(0, 10, "n0");

If you are using Web IDE please share link to a SHARE THIS REVISION copy of your project.
Having the HMI file for your display would also help.

1 Like

@ScruffR

okay, I will be try NexNumber n6(5, 12, “n6”);


I attached an image to show the error
Thanks

Since you are doing this

NexNumber n6 = NexNumber(5, 12, "n6");

n6 is an object not a numeric value and AFAIK there is no assignment operator overload (operator=) nor a cast operator overload which would allow an assignment towards a numeric data type.

However, you should be able to do this

  uint32_t n;
  n6.getValue(&n);
  VAL_PRODUCT_SP = n;