I have a piece of code giving me a bit of trouble.
Basically I have a data logging temperature monitor which displays a graph via a web server set up on the arduino. I'm using tinywebserver as it seemed to give me the least headaches while coding everything.
I'm using the Time library in order to pull time from an RTC used to store readings to an SD card but I'd like the web page to display the current time so that when the page refreshes it displays the person viewing it the last time a reading was taken.
Currently my code is displaying the time but the leading 0 is missing from the time displayed such that the time 17:03.02 would display 17:3.2 which is a little odd looking.
Can someone suggest a way of altering my code so that a leading 0 is added to the routine? I guess I could put in an if statement but wondered if anyone had any suggestions.
As ever your helps very much appreciated.
At the minute I'm not willing to change the webserver for anything different as the whole projects sort of locked in although in the future I might. At the time I originally wrote the code, the tinywebserver was the best available library to do what I needed to do which involves producing javascript code etc.
Here's the section of code centred around the ctimeh, ctimem and ctimes. Excuse the webserver code. It's a bit of a mess but the code external to that is the focus here.
Cheers
Andy
boolean index_handler(TinyWebServer& web_server) {
int updateS = (sdUpdateTime / 1000);
int ctimeh = hour();
int ctimem = minute();
int ctimes = second();
send_file_name(web_server, "INDEX.HTM");
web_server << F(" Current Temperature: ") << temperature << "\n";
web_server << F("Degs C - Current Humidity : ") << humidity << "\n";
web_server << F("% - Update Time : ") << updateS <<"\n";
web_server << F("S");
web_server << F("<p>");
web_server << F(" Last Update at - ") << (ctimeh) <<"\n";
web_server << F(":") << (ctimem) <<"\n";
web_server << F(".") << (ctimes) <<"\n";
web_server << F("</p></p></div></body></html>\n");
return true;
}