Use the in built C time.h library to power a clock and output on dispBoB
Dependencies: dispBoB mbed PCA9635
Diff: simpleClock.cpp
- Revision:
- 2:354aed06a948
- Parent:
- 1:fa8d0331a3cc
--- a/simpleClock.cpp Fri Jul 08 14:50:50 2011 +0000 +++ b/simpleClock.cpp Mon Jul 11 13:58:55 2011 +0000 @@ -1,18 +1,19 @@ -#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 - } +#include "mbed.h" +#include "dispBoB.h" + +dispBoB db(p28, p27, p26); //instantiate dispBoB object + +int main() { + db.init(); + 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