diff options
author | Dmitry Mikhirev | 2013-01-03 00:43:07 +0400 |
---|---|---|
committer | Dmitry Mikhirev | 2013-01-03 00:43:07 +0400 |
commit | c80f8b7c4ee3618a85310dce44ecf19187809a87 (patch) | |
tree | 6a8bd8efc5bd31ba302f667696b86ae8e1e7517c | |
parent | aadb62d5a2b69914cd2cdeb91e275d106f5fa90c (diff) | |
download | brainuino-c80f8b7c4ee3618a85310dce44ecf19187809a87.tar.gz brainuino-c80f8b7c4ee3618a85310dce44ecf19187809a87.tar.bz2 brainuino-c80f8b7c4ee3618a85310dce44ecf19187809a87.tar.xz brainuino-c80f8b7c4ee3618a85310dce44ecf19187809a87.zip |
fix displaying time
-rw-r--r-- | brainuino.ino | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/brainuino.ino b/brainuino.ino index 80993c8..a30d02b 100644 --- a/brainuino.ino +++ b/brainuino.ino @@ -251,8 +251,12 @@ void printTime() { // displaying time passed after starting timer char timestr[33]; + char integer[10]; + char fractional[2]; - sprintf(timestr, "%u.%u", time/1000, (time%1000)/100); + sprintf(integer, "%u", time/1000); + sprintf(fractional, "%u", time%1000/100); + sprintf(timestr, "%s.%s", integer, fractional); lcd.setCursor(8, 1); uprint(timestr, &lcd); } @@ -264,11 +268,15 @@ void printPreciseTime() { // or that it was not started yet char timestr[33]; + char integer[10]; + char fractional[4]; // if timer was started if (startTime > 0) { time = millis()-startTime; - sprintf(timestr, "%u.%u", time/1000, time%1000); + sprintf(integer, "%u", time/1000); + sprintf(fractional, "%03u", time%1000); + sprintf(timestr, "%s.%s", integer, fractional); } // if it was not else |