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

Dependencies:   dispBoB mbed PCA9635

simpleClock.cpp

Committer:
d_worrall
Date:
2011-07-11
Revision:
2:354aed06a948
Parent:
1:fa8d0331a3cc

File content as of revision 2:354aed06a948:

#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
    }
}