Start a new topic
Implemented

"If" conditions + Comparison operators (== != < >) in Nextion Editor

Is it possible to write some simple conditions in User Code for Touch Press Events ?

For instance I would like to prevent the user from adjusting the brightness down to 0, otherwise the display becomes completely dark.

For the moment I have this User Code for Touch Press Event of a button:

dim=dim-10

I would like to change it to something like this:

if dim>10: dim=dim-10

or

if dim==0: dim=10

or something similar.




7 people like this idea

Maybe a syntax like in Arduino would be better, like this:

if (dim>10) dim=dim-10

 


2 people like this

I know how to use comparison operators in if conditions. But it doesn't work when I use txt object in if condition.

The "IF" function has been implemented in Nextion Editor v0.28. Thank you @ITEAD.

See this thread:

http://support.iteadstudio.com/support/discussions/topics/1000064594


I doubt it ever will because the text could be anything. And it would require a string function like strcmp. With that said try adding " around your values.

We are listening to the voice of customers. :)

I am now reviewing all of the Feature Requests, this will take some time, patience please.

The if function has been improved dramatically.

Hi


How can I compare txt value using if?


When i write like this code it doesn't work. 

if(t0.txt>=10000)
{
page big
}
if(t0.txt<10000)
{
page small
}

  

but when i write this code it works correctly.

if(t0.txt==10000)
{
page big
}

 

Where can I find this whole code?
Also code for Arduino UNO?

Best regards

Per

@Per

I forgot to mention this page where you will find a lot of Arduino code from Chris Sipes : 

http://support.iteadstudio.com/support/discussions/topics/1000061568


Use of simple conditional statements like "if & else" will make the programming of Nextion module more creative!

 

@Per

ITEAD is updating the Arduino library, and new examples are available in the 'examples' directory on 

https://github.com/itead/ITEADLIB_Arduino_Nextion


Login or Signup to post a comment