Akafugu / Mbed 2 deprecated vfd_modular_clock_mbed Featured

Dependencies:   DipCortex-EEprom RTC flw mbed

Committer:
Backstrom
Date:
Mon Feb 09 13:40:46 2015 +0000
Revision:
0:f6e68b4ce169
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Backstrom 0:f6e68b4ce169 1 /*
Backstrom 0:f6e68b4ce169 2 * VFD Modular Clock - mbed
Backstrom 0:f6e68b4ce169 3 * (C) 2011-14 Akafugu Corporation
Backstrom 0:f6e68b4ce169 4 *
Backstrom 0:f6e68b4ce169 5 * This program is free software; you can redistribute it and/or modify it under the
Backstrom 0:f6e68b4ce169 6 * terms of the GNU General Public License as published by the Free Software
Backstrom 0:f6e68b4ce169 7 * Foundation; either version 2 of the License, or (at your option) any later
Backstrom 0:f6e68b4ce169 8 * version.
Backstrom 0:f6e68b4ce169 9 *
Backstrom 0:f6e68b4ce169 10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
Backstrom 0:f6e68b4ce169 11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
Backstrom 0:f6e68b4ce169 12 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
Backstrom 0:f6e68b4ce169 13 *
Backstrom 0:f6e68b4ce169 14 */
Backstrom 0:f6e68b4ce169 15
Backstrom 0:f6e68b4ce169 16 #ifndef __RTC_H_
Backstrom 0:f6e68b4ce169 17 #define __RTC_H_
Backstrom 0:f6e68b4ce169 18
Backstrom 0:f6e68b4ce169 19 #include "mbed.h"
Backstrom 0:f6e68b4ce169 20
Backstrom 0:f6e68b4ce169 21 class RTC {
Backstrom 0:f6e68b4ce169 22 protected:
Backstrom 0:f6e68b4ce169 23 struct tm m_tm;
Backstrom 0:f6e68b4ce169 24 time_t m_time;
Backstrom 0:f6e68b4ce169 25 uint8_t m_tenths;
Backstrom 0:f6e68b4ce169 26
Backstrom 0:f6e68b4ce169 27 public:
Backstrom 0:f6e68b4ce169 28 RTC();
Backstrom 0:f6e68b4ce169 29
Backstrom 0:f6e68b4ce169 30 enum RTC_SQW_FREQ { FREQ_1 = 0, FREQ_1024, FREQ_4096, FREQ_8192 };
Backstrom 0:f6e68b4ce169 31
Backstrom 0:f6e68b4ce169 32 virtual void begin();
Backstrom 0:f6e68b4ce169 33
Backstrom 0:f6e68b4ce169 34 void tick();
Backstrom 0:f6e68b4ce169 35 void tenth_tick();
Backstrom 0:f6e68b4ce169 36
Backstrom 0:f6e68b4ce169 37 virtual time_t time();
Backstrom 0:f6e68b4ce169 38 virtual struct tm* getTime();
Backstrom 0:f6e68b4ce169 39 virtual void getTime(uint8_t* hour, uint8_t* min, uint8_t* sec);
Backstrom 0:f6e68b4ce169 40
Backstrom 0:f6e68b4ce169 41 virtual void setTime(time_t t);
Backstrom 0:f6e68b4ce169 42 virtual void setTime(uint8_t hour, uint8_t min, uint8_t sec);
Backstrom 0:f6e68b4ce169 43 virtual void setTime(struct tm* tm);
Backstrom 0:f6e68b4ce169 44
Backstrom 0:f6e68b4ce169 45 virtual void setAlarm(time_t t);
Backstrom 0:f6e68b4ce169 46 virtual void setAlarm(uint8_t hour, uint8_t min, uint8_t sec);
Backstrom 0:f6e68b4ce169 47 virtual struct tm* getAlarm(void);
Backstrom 0:f6e68b4ce169 48 virtual void getAlarm(uint8_t* hour, uint8_t* min, uint8_t* sec);
Backstrom 0:f6e68b4ce169 49 virtual bool checkAlarm(void);
Backstrom 0:f6e68b4ce169 50
Backstrom 0:f6e68b4ce169 51 virtual void SQWEnable(bool enable);
Backstrom 0:f6e68b4ce169 52 virtual void SQWSetFreq(enum RTC_SQW_FREQ freq);
Backstrom 0:f6e68b4ce169 53
Backstrom 0:f6e68b4ce169 54 uint8_t getTenths() { return m_tenths; }
Backstrom 0:f6e68b4ce169 55
Backstrom 0:f6e68b4ce169 56 protected:
Backstrom 0:f6e68b4ce169 57 uint8_t bcd2dec(uint8_t d);
Backstrom 0:f6e68b4ce169 58 uint8_t dec2bcd(uint8_t d);
Backstrom 0:f6e68b4ce169 59 };
Backstrom 0:f6e68b4ce169 60
Backstrom 0:f6e68b4ce169 61 #endif // __RTC_H_