Start a new topic

Nextion Image Statements

 Wondering if somebody can assist?

I have the Nextion 7 Enhanced model.

On one of my Pages, got the following code to work:

On the timer event to change a picture with values the following:


 

if(n8.val==0)
{
  p1.pic=22
}
if(n8.val==1)
{
  p1.pic=23
}
if(n8.val==2)
{
  p1.pic=24
}
if(n8.val==3)
{
  p1.pic=25
}

This code runs on a timer incrementing by 1 and then loop

This works 100% as long as it is exact values.

To get decimal values, I have to use txt, eg. 22,5

What I would like to do is get the images to change according to the following:

I write it as I see it, yet in Timer code it does not compile.

 

if(n8.val>20; n8.val<21)
{
  p1.pic=22
}
if(n8.val>21; n8.val<22)
{
  p1.pic=23
}
etc, etc, etc.

 Hope someone can assist or shed some light on the issue.


The Nextion Firmware uses Integers, Float is not supported. 


Number-Range: Initial value(-2147483648 to 2147483647)


n8.val is EITHER 20 OR 21 but NEVER 20.5 .... because that's just not implemented ... so, you can't check for "between 2 successive" integers ...


Just multiply your value with 10, and check >200 and <210 ...


Gerry

Thanks for the response Gerry. This will work better than my initial thought of using rounding on Arduino side as a seperate value to drive the images.

From response I still assume I can only == or > and not a statement looking for a value between 2 values.

Eg 205 will use the val > 200 and the next line, if val > 210 will then only change picture once 211 is reached?

Thanks and Regards
Riaan

 

nested if statements are allowed ....

if(n8.val>200)
{
  if(n8.val<206)
  {
    p1.pic=23
  }

}


 Gerry


1 person likes this
Thanks Gerry works like a charm. tested in one of my earlier versions, my latest one I was playing with these now, suddenly doesn't compile,
Error: Index was outside the bounds of the array.
Error: Compile failed! 1 Errors, 0 Warnings,

Thanks again for the prompt assistance
R

 

Login or Signup to post a comment