Global variable on serveral pages

Hello,

i try to have a global var lets say on page 0.
The status of the variable is controlled by MCU.

Lets say i am on page 1 and the MCU sends a var update for the page 0 global var.

The status does not change on page 1.

I have timer on page 1 which reads the status of page 0 var and should change something.

In debug mode it works, why does it not work on a real device?
Anybody else knows this issue?

I know, i can go to Nextion “Community” but i have the feeling that it will return a standard message like “Learn how to program” or “See the instruction set” :smiley: haha

So again short problem descritpion:
Page 0 has a global var. Number.
Display is on Page 1 which has a timer to check page0var.val to show the value
MCU change value for global var on Page 0.

Nothing happens.
In debug mode it works. if i am on page 1 and change value with the instruction page0var.val=1 it shows the status of page0 global var but not on a real device.

Hope someone can help :wink:

Thanks,
Alex

Hi, try with this example:

n1.val =p[x].b[yy].val

x = page where is your global var
yy = id of your globar var

1 Like

Hi,
the problem is not inside the HMI, in debug it works.

Problem was my var declaration in my MCU code.
Naming needs to be with pagename in Nextion var declaration (unlike other vars).

1 Like

Very late reply, but what do you mean with the pagename in nextion var declaration. For example I have a var on page “main”. Even if I send this command from my Arduino it 99%+ doesn’t work. If I wait for a long time it sometimes work. I sent the following command: “main.vaStep.val=10”. I also tried it via a library and then it does “p[0].b[16].val=10” but both options never update the variables. However when I create a timer that randomly updates the UI it works fine. Currently my timer is responsible for setting UI properties with a 50ms interval based on the variables. For example:

if(vaStep.val==10){
  b3.pic=5
}
else if(vaStep.val==20)
{
  b4.pic=5
}

It all works perfectly in debug mode though!