Use the in built C time.h library to power a clock and output on dispBoB

Dependencies:   dispBoB mbed PCA9635

Committer:
d_worrall
Date:
Mon Jul 11 13:58:55 2011 +0000
Revision:
2:354aed06a948
Parent:
1:fa8d0331a3cc
version (I forget)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
d_worrall 2:354aed06a948 1 #include "mbed.h"
d_worrall 2:354aed06a948 2 #include "dispBoB.h"
d_worrall 2:354aed06a948 3
d_worrall 2:354aed06a948 4 dispBoB db(p28, p27, p26); //instantiate dispBoB object
d_worrall 2:354aed06a948 5
d_worrall 2:354aed06a948 6 int main() {
d_worrall 2:354aed06a948 7 db.init();
d_worrall 2:354aed06a948 8 set_time(1309776930); //set UNIX timestamp - it's Mon, 04 Jul 2011 10:55:30 GMT where I am
d_worrall 2:354aed06a948 9
d_worrall 2:354aed06a948 10 while(1){ //loop forever
d_worrall 2:354aed06a948 11 time_t rawtime = time(NULL); //update to instantaneous time
d_worrall 2:354aed06a948 12
d_worrall 2:354aed06a948 13 char buffer[32]; //create a local char array object called buffer
d_worrall 2:354aed06a948 14 strftime(buffer, 32, "%H.%M.%S\n", localtime(&rawtime)); //store string formatted time
d_worrall 2:354aed06a948 15
d_worrall 2:354aed06a948 16 db.locate(0); //position cursor to initial position on screen
d_worrall 2:354aed06a948 17 db.printf("%s", buffer); //print buffer to dispBoB
d_worrall 2:354aed06a948 18 }
d_worrall 1:fa8d0331a3cc 19 }