Go Down

Topic: Nextion switch colour (Read 38 times) previous topic - next topic

manolomao

Hy guys, can you help me??I've a problem: arduino send a message 1 to nextion and nextion must to switch the color of the dispaly, until the message will be 1. When it will be 0, the display must to be white.
I hope i was clear.
Thanks.

Seithan

Hello,

Unfortunately, more information is needed.
For example: where do you send the message? Is it stored in a variable? When does the value change?

Supposing the message in one in a numeric variable called "va0", then a timer that will detect when the value of the variable changes.

This is the code for the timer
This is a simple code for the timer
Code: [Select]

if(va0.val==0)
{
page0.bco=0
}
else if(va0.val==1)
{
page0.bco=65535
}


But in this simple code, the screen color will change every time the timer runs and would turn to the same color and a flickering would occur. Despite that, changing something when it is not needed is not right. This is the enhanced version:

Code: [Select]

if(va0.val==0&&lastVa0.val!=va0.val)
{
  page0.bco=0
  lastVa0.val=va0.val
}else if(va0.val==1&&lastVa0.val!=va0.val)
{
  page0.bco=65535
  lastVa0.val=va0.val
}


This however, for this to work, ther needs to be a second variable, lastVa0, which is made in order not to have to change every time the timer runs without having a change of the message.

If you have any other questions, do not hesitate to make a post!

Best regards,
Seithan


P.S. You might should have made a different topic with the name of the problem you are facing, in order for other people to notice much more easily in the future.
UBUNTU:
"I am what I am, because of who we all are", compassion, kindness and humanity that connect us together by sharing  ourselves with others and caring for those around us.

ballscrewbob

@manolomao

TOPIC SPLIT
PLEASE DO NOT HIJACK / NECRO POST !


Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.



It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google (who would have thunk it ! ) or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Go Up