Dennis Smith / Mbed 2 deprecated NixieClock800Max

Dependencies:   PCF8583_rtc mbed

Revision:
0:f09cf90def53
Child:
1:a8b9fb95696b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PCF8583_rtc.h	Sun Feb 09 00:25:21 2014 +0000
@@ -0,0 +1,165 @@
+#include <mbed.h>
+
+#ifndef rtc_included
+#define rtc_included
+
+#define PCF8583_addr        0xA2     // PCF8583 Write address,
+#define Write_addr          0xA2     // PCF8583 Write address,
+#define Read_addr           0xA3     // PCF8583 Read address
+#define SET_DATE_TIME       0x01
+#define GET_DATE_TIME       0x02
+#define SET_ALARM           0x09
+#define GET_ALARM           0x0A
+#define ON                  1
+#define OFF                 0
+
+#ifndef TRUE
+#define TRUE  1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+//Configuration Alarm Control Register
+#define alarm_enable_bit    0x04
+#define alarm_flag          0x02;
+#define timer_hundsek       0x01
+#define timer_seconds       0x02
+#define timer_minutes       0x03
+#define timer_hours         0x04
+#define timer_days          0x05
+#define timer_int_enable    0x08
+#define daily_alarm         0x10
+#define weekday_alarm       0x20
+#define dated_alarm         0x30
+#define timer_alarm_enable  0x40
+#define alarm_int_enable    0x80
+#define timer_alarm_enable  0x40
+#define alarm_int_enable    0x80
+
+// Use the first 2 NVRAM addresses for the century and year bytes.
+#define CENTURY_REG         0x10
+#define YEAR_REG            0x11
+#define USER_REG            0x12
+
+#define TIME                1
+#define ALARM               9
+
+struct Time_t {
+  char fmt_hours;
+  char am_pm_flag;
+  char hours;
+  char minutes;
+  char seconds;
+  char hundreds;
+};
+
+struct Date_t {
+  char day;
+  char month;
+  char year;
+  char century;
+  char weekday;
+};
+
+struct DateTime_t {
+  struct Date_t date;
+  struct Time_t time;
+};
+
+class PCF8583rtc {
+  I2C *_i2c;
+  
+public:
+  //Set these public variables according to your locale, default is Australia English
+  char *ShortDateFormat;
+  char *LongDateFormat;
+  char *ShortTimeFormat;
+  char *LongTimeFormat;
+
+  char DateSeparator;
+  char TimeSeparator;
+
+  char *ShortDayNames[7];
+  char *LongDayNames[7];
+  char *ShortMonthNames[12];
+  char *LongMonthNames[12];
+    
+  PCF8583rtc(I2C *i2c);
+
+  int  bin2bcd(char value);
+  void read(const char address);
+  void write(const char address);
+  void FormatDateTime(char *dest, char *format);
+  bool WriteNVram(char address, char * value, char num);
+  bool ReadNVram(char address, char * dest, char num);
+  struct DateTime_t GetDateTime(void); 
+  struct DateTime_t GetDateTimeBCD(void); 
+private:
+  struct DateTime_t dt;
+
+  char Bcd2Char(char *d, char val, char WantLeadZero);
+  void enableCounting(void);
+  void pauseCounting(void);
+  char readByte(char address);
+  void writeByte(char address, char d);
+  void configureAlarmReg(char alarm);
+  void configureControlReg(char control);
+};
+
+/** PCF8583_rtc class.
+ *
+ * Example:
+ * @code
+ * #include <mbed.h>
+ * #include <PCF8583_rtc.h>
+ *
+ * I2C i2c(P0_10, P0_11);       // sda, scl
+ * PCF8583rtc rtc(&i2c);
+ *
+ * int main() { 
+ *  
+ * rtc.read(TIME);
+ * i2c.write(ADDR_8574_1, &rtc.HoursBCD, 1);   //write hours to display
+ * i2c.write(ADDR_8574_2, &rtc.MinsBCD, 1);    //write minutes to display
+ * }
+ * @endcode
+ */
+ 
+/** Create a PCF8583rtc object using a pointer to the given I2C object.
+ *
+ * @param i2c pointer to an I2C object to which the PCF8583 device is connected.
+ */
+//PCF8583rtc(I2C *i2c);
+
+/** the Read_DateTime function.
+ *
+ * @param address  Determines whether to read the date/time or alarm registers
+ *                 Values are retrieved from the internal datetime structure
+ */
+//void read(const char address);
+
+/** the Write_DateTime function.
+ *
+ * @param address  Determines whether to set the date/time or alarm registers
+ *                 Values are first set into the internal datetime structure prior to calling
+ */
+//void write(const char address);
+ 
+/** the FormatDateTime function.
+ *
+ * @param dest   a pointer to a char array where formatted values are to be placed
+ * @param format a pointer to a string describing how to format the values 
+ */
+//void FormatDateTime(char *dest, char *format);
+
+/** the WriteNVram function.
+ *
+ * @param address  address where value is to be placed
+ * @param value    pointer to char array containing the value(s) to be stored
+ * @param num      the number bytes to store
+ */
+//void WriteNVram(char address, char *value, char num);
+
+#endif
\ No newline at end of file