So I'm using the NTP on the arduino. I'm going to only ping the NTP once a day to truth up the clock. however the rest of the time I want just to use incrementing the minute and hour via ints.
I'm using a TFT display..so here is my issue.
The getLocaltime of the NTP seems to return a struct of characters. Which I'm able to push out to the screen every miniute. What I'd like to do is be able to get the NTP once a day and then just use the ESP32 clock to increment the minutes every 60000ms and then the hour when the min goes from 59 to 00....
I'm new to C and am not sure how to take the char to int and then increment it and then back to char to send to the display.
any help appreciated.
I think I determined an answer which seems to beworking OK. timeHour and timeMin are set from the NTP library in a previous Setup area.
if (currentMillis - timeMillisincrement > 60000){
timeMillisincrement = currentMillis;
int hh,mm;
sscanf(timeHour, "%02d", &hh);
sscanf(timeMin, "%02d", &mm);
if(mm == 59){
mm = 0;
if(hh == 23){
hh = 0;
}else{
hh = hh + 1;
}
}else{
mm = mm + 1;
}
sprintf(timeHour,"%02d",hh);
sprintf(timeMin,"%02d",mm);
gslc_ElemSetTxtStr(&m_gui, m_pElemOutTxt1_3, timeHour);
gslc_ElemSetTxtStr(&m_gui, m_pElemOutTxt5, timeMin);
RTC_Millis
class from RTClib. – Edgar Bonet Dec 24 '20 at 10:13char
is an 8-bit integer. Though, I admit, the name is a bit confusing. – Gerben Dec 24 '20 at 15:31