Mbed Clock application using an NTP connection to get internet time and a terminal interface to send commands

Dependencies:   4DGL-uLCD-SE EthernetInterface NTPClient mbed-rtos mbed SDFileSystem wavfile

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Clock.h Source File

Clock.h

00001 #include "mbed.h"
00002 #include "rtos.h"
00003 #include "NTPClient.h"
00004 
00005 // AM/PM
00006 const int AM = 0;
00007 const int PM = 12;
00008 
00009 // Timezones
00010 const int PST = -8;
00011 const int MST = -7;
00012 const int CST = -6;
00013 const int EST = -5;
00014 const int UTC = 0;
00015 
00016 class Clock {
00017 public:
00018     Clock();
00019     void setAlarmThread(Thread *aThread);
00020     
00021     void setTime(int hour, int minute, int period);
00022     void setTimezone(int timezone);
00023     
00024     int syncTime();
00025     
00026     void setAlarm(int hour, int minute, int period);
00027     void setTimer(int hours, int minutes);
00028     void deleteAlarm();
00029     bool alarmSet();
00030     
00031     time_t getTime();
00032     int getTimezone();
00033     
00034 
00035 private:
00036     int timezone;
00037     bool aSet;
00038     Ticker alarmTicker;
00039     Thread *alarmThread;
00040     
00041     void signalAlarm();
00042 };