Use the in built C time.h library to power a clock and output on dispBoB
Dependencies: dispBoB mbed PCA9635
Diff: simpleClock.cpp
- Revision:
- 1:fa8d0331a3cc
- Child:
- 2:354aed06a948
diff -r 0b0043f97268 -r fa8d0331a3cc simpleClock.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/simpleClock.cpp Fri Jul 08 14:50:50 2011 +0000 @@ -0,0 +1,18 @@ +#include "mbed.h" +#include "dispBoB.h" + +dispBoB db(p28, p27, p26); //instantiate dispBoB object + +int main() { + set_time(1309776930); //set UNIX timestamp - it's Mon, 04 Jul 2011 10:55:30 GMT where I am + + while(1){ //loop forever + time_t rawtime = time(NULL); //update to instantaneous time + + char buffer[32]; //create a local char array object called buffer + strftime(buffer, 32, "%H.%M.%S\n", localtime(&rawtime)); //store string formatted time + + db.locate(0); //position cursor to initial position on screen + db.printf("%s", buffer); //print buffer to dispBoB + } +} \ No newline at end of file