Start a new topic

Write 0.01 to nextion

I have an Arduino mega linked to a nextion screen.

I'm trying to write 2.34 to NexNumber, but just writing 2

I use n2.setValue (bar)

can you help?

1 Comment

I don't like using the modulo as it does have some inaccuracies.  BUT long way that will work

Could be a shorter way.


with numeric va0 for whole numbers and numeric va1 for fractional portions

and string va2 for string whole numbers and string va3 for string fractional part

add a hotspot an in Touch Press Event add 


va1.val=va0.val%100

va0.val=va0.val/100

cov va0.val,va2.txt,0

cov va1.val,va3.txt,2

t0.txt=va2.txt+"."+va3.txt


change width and height of hotspot to be small and out of the way where no one thinks to click

multiply your value by 100 before sending:


va0.val=234;

click m0,1


Or you probably could do the conversion in your MCU so 2.34 becomes text "2.34" and send

t0.txt="2.34"


HMI
(7.95 KB)

1 person likes this
Login or Signup to post a comment