Unofficial Nextion/TJC User Forum

I am having issues setting RTC data into a string

I am waiting on my 10.1" Intelligent series screen to arrive. In the meantime, I am attempting to build my interface.

The problem that I am trying to solve is adding RTC data to t1.txt, for example, 4/18/2021 - 11:26:00. However only 4/18/2021 - shows in t1.txt. Do I need the screen to get RTC data? Or will the ide generate the RTC data from my computer?

I have one timer: tm0 and two variables: covRTC and timeString

my timer event consists of:

cov rtc1,timeString.txt,0
timeString.txt+="/"
cov rtc2,covRTC.txt,0
timeString.txt+=covRTC.txt
timeString.txt+="/"
cov rtc0,covRTC.txt,0
timeString.txt+=covRTC.txt
timeString.txt+="-"
cov rtc3,covRTC.txt,0
timeString.txt+=covRTC.txt
timeString.txt+=":"
cov rtc4,covRTC.txt,0
timeString.txt+=covRTC.txt
timeString.txt+=":"
cov rtc5,covRTC.txt,0
timeString.txt+=covRTC.txt
t1.txt=timeString.txt

I adjusted the xcen and the txt_maxl of textString. I also changed cov to covx. Everything seems to work as expected. Updated event code:

covx rtc1,timeString.txt,0,0
timeString.txt+="/"
covx rtc2,covRTC.txt,0,0
timeString.txt+=covRTC.txt
timeString.txt+="/"
covx rtc0,covRTC.txt,0,0
timeString.txt+=covRTC.txt
timeString.txt+="-"
covx rtc3,covRTC.txt,0,0
timeString.txt+=covRTC.txt
timeString.txt+=":"
covx rtc4,covRTC.txt,0,0
timeString.txt+=covRTC.txt
timeString.txt+=":"
covx rtc5,covRTC.txt,0,0
timeString.txt+=covRTC.txt
t1.txt=timeString.txt

have you watched this video??

1 Like

I’ve watched a bunch of cheap controls nextion videos. Good channel.

hey guys im very new to this and ive followed all the steps as best as i could but i cant seem to have any luck.

Error:Invalid Variables:timeString.txt( Double click to jump to code)
Error:Invalid Variables:timeString.txt( Double click to jump to code)
Error:Invalid Variables:covRTC.txt( Double click to jump to code)
Error:Invalid Variables:timeString.txt( Double click to jump to code)
Error:Invalid Variables:timeString.txt( Double click to jump to code)
Error:Invalid Variables:covRTC.txt( Double click to jump to code)
Error:Invalid Variables:timeString.txt( Double click to jump to code)
Error:Invalid Variables:timeString.txt( Double click to jump to code)
Error:Invalid Variables:covRTC.txt( Double click to jump to code)
Error:Invalid Variables:timeString.txt( Double click to jump to code)
Error:Invalid Variables:timeString.txt( Double click to jump to code)
Error:Invalid Variables:covRTC.txt( Double click to jump to code)
Error:Invalid Variables:timeString.txt( Double click to jump to code)
Error:Invalid Variables:timeString.txt( Double click to jump to code)
Error:Invalid Variables:covRTC.txt( Double click to jump to code)
Error:Invalid Variables:timeString.txt( Double click to jump to code)
Error:Invalid Variables:timeString.txt( Double click to jump to code)
Error:Compile failed! 17 Errors, 0 Warnings,

What happens when you doubleclick on the error text?

It seems that the variables timeString and covRTC can‘t be seen by your timer code. Are these two added as variable components to the same page as the timer ? Are they set to be text (and not numeric) variables ?

I can’t watch this video anymore, would you mind posting it again?

Looks from the error messages like all these variables aren’t text but numeric variables and/or these aren’t placed on the same page as the code.

https://drive.google.com/file/d/1PXQpDTSjk-U6jKVlKZ4PkPib3ApJAda2/view?usp=sharing

thanks for the feedback guys i still am having no luck. I’ve included a link where you can access the file if you want to tinker around with it. cheers

@Fjodor posted the reason for your errors in post #8. Number variables don’t have a .txt attribute. Text variables don’t have a .val attribute. Covx errors can easily be fixed by following the documentation for the command. Cov and Covx translate between txt and number.

thanks guys I’ve fixed the issue!!
my next question is when the time is displayed it looks like 6:5:45. How can i make it 06:05:45?
sorry I’m such a noob at this

//FECHA Y HORA

covx rtc3,va0.txt,2,0

covx rtc4,va1.txt,2,0

covx rtc5,va2.txt,2,0

va0.txt=va0.txt+":"+va1.txt+":"+va2.txt

covx rtc2,va1.txt,2,0

covx rtc1,va2.txt,2,0

covx rtc0,va3.txt,4,0

va1.txt=va1.txt+"/"+va2.txt+"/"+va3.txt

va4.txt=va1.txt+" "+va0.txt

if(va4.txt!=t4.txt)

{

t4.txt=va1.txt+" "+va0.txt

}


This forum is in no way affiliated with NEXTION®, ITEAD STUDIO®, TJC®, or anyone else really. All product names, logos, and brands are property of their respective owners. All company, product, and service names used in this website are for identification purposes only. Use of these names, logos, and brands does not imply endorsement from the respective rights holder(s).