Start a new topic

Nextion and Boolean Operators

 Hello,

if (var.val >= 10 && var.val <= 20){}   // true if a is between 10 and 20

How do I do this with the Nextion?

Greeting and thanks
Andreas


edit:

 if (var.val >= 10 && var.val <= 20){}   // true if var.val is between 10 and 20

Greeting and thanks
Andreas

use nested if statements instead of one ...

 

yes but this is a very simple example... in real life it makes the code unmanageable and poor...
right now i moved code to arduino.. can't imagine usefulness of enhanced version without that sorry

 

by default, Nextion displays offer a HMI concept by design. Even a small STM is used for underlaying work, even a standard gLCD panel is part of, the Nextion neither offer all STM available things to outside nor is it a standalone Arduino replacement nor is it a replacement for any simple gLCD out. It is what it is, a HMI concept. A Human Machine Interface.

so, it is nothing bad to use Nextions as Displays, and Arduinos as mcu ...


and sorry, but imagination is nothing you can learn, either you have, or just not ...


:-)

Usefulness of the Enhanced version comes when ...

 - one desires an extra 4608 SRAM (3.5" and up)

 - one desires the Digital IO

 - one desires the RTC Nextion side

 - one desires extra 12MB- 16MB of addition Flash

 - one desires the extra 60MHz (3.5" and up)


But can't imagine how to nest an if statement, sorry.

   Arguing that such is too difficult is beyond logic, not too hard at all.

  

if (var.val>=10)
{
  if(var.val<=20)
  {
    // execute when condition true
  }
}

 

Nextion Editor auto-formats indentations, code becomes very readable.


Nextion Editor also has Component touch event checkbox for Send Component ID

 - no reason to have any code Nextion side.


Sorry don't want to give a flame nextion is so lovely piece of hardware.. I understand what you are saying but we are not talking about fancy functions or anything else the if statement is one of the primary constructs of any programming language. Your example is over simple I can provide tons of more complex things that your display could do in a more powerful manner.. Without need to tell that only need is imagination. I hope you change idea and implement at least this kind of operator. This would be not a plus but a minus less. Many thanks and best regards
Sorry just for completeness & & is easy || is more tricky. Every line of code exposes programmers to errors and bug especially in conditional evaluations.

Nextion is a lovely piece of work.  Indeed.

But. Nextion Instruction Set is not a programming language.


So when we boil down the STM32 Cortex M0 that drives Nextion

and realize the entire Nextion Instruction Set is in < 4608 bytes

and one doesn't want to encroach on the 3584 bytes promised

to the user for their user side HMI usage ...


Now most here are MCU programmers

 - it should be somewhat clear just how tightly packed Nextion is.

It should also be somewhat clear how many would not be able to

accomplish Nextion design in their own STM32 8K Cortext M0


And this is kind of what we love about our beloved Nextions

 - it accomplishes our GUI, gives us lots of coding space

   allowing us to think about the things we would do rather than

   having to mess with GUI on the MCU side.

- but we would all take issue if 

  - our little 3854 Bytes was reduced to 2560 Bytes and our HMI

    designs broke, just because of a unnecessary command/feature.


Nextion is based in integer math and non-complex evaluation

   (stated in the Nextion Instruction Set)

This actually matches very close to an MCU instruction set

   push to register, do a compare, pop from registers, branch

Much of this is indeed acceptable to the community.


But with or without a complex evaluation

 - the Nextion will continue to be able to do complex things.

This I have indeed proven on less of a Nextion Instruction Set

  

The discussions about in Free Chat is that, for discussions.

As a Feature Request, I am not sure it came up yet.


Considering the sheer size of the Nextion Community

 - it gives an idea of how much of a difficulty a missing && || has been


Boolean Arithmetic & | << >> was requested

 - very few upvoted the request and still made it into v0.48

So who knows.


I am curious of your complex ideas of Nextion capabilities

//  Scenario:

//    if((n0.val>9 && n0.val<24) || (n1.val>9 && n1.val<24) ||

//        (n0.val>9 && n2.val<24) || (n3.val>9 && n3.val<24))  {

//       doblahblablah

//    }


picture check_range Touch Release Event   

sys0=0
if(n0.val>9)
{
  if(n0.val<24)
  {
    sys0=1
  }
}
if(n1.val>9)
{
  if(n1.val<24)
  {
    sys0=1
  }
}
if(n2.val>9)
{
  if(n2.val<24)
  {
    sys0=1
  }
}
if(n3.val>9)
{
  if(n3.val<24)
  {
    sys0=1
  }
}

 

then

 

click check_range,0
if(sys0!=0)
{
   click doblahblablah,0
}

 

 


Login or Signup to post a comment