Start a new topic

change color of font depending on value

 

Hi

Is there anyway to change the txt font color depending on a given value of the txt ?
For example, I want to display a temperature. When the temp is positive the color of the txt is green but when the temperature is negative then the color of the temperature txt goes red.


The start solution for you.

http://wiki.iteadstudio.com/Nextion_Instruction_Set#Classification_II:_GUI_Designing_Command

XSTR x, y, w, h, fontid, font color, back color, xcenter, ycenter, stand, string.

Paste this instruction input area and see what it does when you change the value.

XSTR 191,37,101,31,0,2016, WHITE, 1,1,1,389, t1.txt

XSTR 0,0,100,30,0, RED, 2016,1,1,1,99: 25 t0.txt




1 person likes this
I get a "invalid variable " error when I run this command from the instruction input area
this is what I'm running
t0.txt="25"
xstr 405,166,40,36,1,RED,0,1,1,0, t0.txt

I also tried it like this
xstr 405,166,40,36,1,RED,0,1,1,0, 25


but still the same

xstr x,y,w,h,fontid,fontcolor,backcolor,xcenter,ycenter,sta,string

xstr 191,37,101,31,0,2016,WHITE,1,1,1,389,t1.txt

xstr 191,37,101,31,0,GREEN,WHITE,1,1,1,389,t1.txt

Beware! no space!

2016==GREEN and 389== Value


xstr 405,166,40,36,1,RED,0,1,1,0,t0.txt

in this is missing [front or backcoler] AND the value

 

the [, 99: 25 t0.tx] is a fault of mine. which remains standing.

99:25 I wanted to see if could also appear (unfortunately!) must be [,99, t0.txt]

Greeting Vic

 Thanks for taking the time to help out. This worked for me

xstr 405,166,40,36,1,RED,0,1,1,0,28,t0.txt


1 person likes this
How Can I send this command from the arduino to the nextion display?

xstr 405,166,40,36,1,RED,0,1,1,0,28,t0.txt
I tried using the nextion library and specificaly the command
myNextion.sendCommand("xstr 405,205,47,36,2,GREEN,0,1,1,0,28,t0.txt");
but nothing happens
If I send the same command "xstr 405,166,40,36,1,RED,0,1,1,0,28,t0.txt" over a serial connection or with ther simulator it works.



 

Login or Signup to post a comment