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

Dependencies:   dispBoB mbed PCA9635

Committer:
d_worrall
Date:
Fri Jul 08 14:50:50 2011 +0000
Revision:
1:fa8d0331a3cc
Child:
2:354aed06a948
version1

Who changed what in which revision?

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