Dennis Smith / Mbed 2 deprecated NixieClock800Max

Dependencies:   PCF8583_rtc mbed

Revision:
2:4184f92440a1
Parent:
1:a8b9fb95696b
Child:
3:07c00c82338c
--- a/main.cpp	Thu Feb 13 21:46:08 2014 +0000
+++ b/main.cpp	Sun Feb 23 21:28:26 2014 +0000
@@ -1,5 +1,5 @@
 #include <mbed.h>
-//#include "IRremote.h"
+#include "IRremote.h"
 #include "PCF8583_rtc.h"
 
 void NixieDisplay(void);
@@ -9,8 +9,8 @@
 DigitalOut Blue(P0_16);
 
 I2C i2c(P0_10, P0_11);       // sda, scl
-PCF8583rtc rtc(&i2c, PCF8583_addr);
-//IRremote rc5(P0_0);
+PCF8583rtc rtc(&i2c, PCF8583_addr_2);
+IRremote rc5(P0_0);
 
 // i2c addresses
 const int ADDR_8574_1 = 0x70;
@@ -21,50 +21,30 @@
 
 int main()
 {
-    struct DateTime_t dtw;
     struct DateTime_t dtr;
     char   hours;
     char   mins;
-    char   tmp[8] = {1, 2, 3, 4, 5, 6, 7, 8};
-    char   tmp1[8];
-    
+
     Red = Green = Blue = 1;
 
     i2c.frequency(400000);
     
-    dtw = rtc.read(TIME);
-    dtw.time.hours = rtc.bin2bcd(6);
-    dtw.time.minutes = rtc.bin2bcd(38);
-    rtc.write(TIME, dtw);
+//    dtr = rtc.read(TIME);     //Set the clock from scratch
+//    dtr.time.hours = rtc.bin2bcd(9);
+//    dtr.time.minutes = rtc.bin2bcd(18);
+//    rtc.write(TIME, dtr);
+//    wait(.1);
 
     while(1) {
-        for(int x = 0; x < 7; x++) {
-            tmp[x] = rtc.bin2bcd(rand());
-        }
-        rtc.WriteNVram(USER_REG, tmp, 8);
-        wait(1);
-        rtc.ReadNVram(USER_REG, tmp1, 8);
-      
-        for(int x = 0; x < 7; x++) {
-            Blue = !Blue;
-            if(tmp[x] != tmp1[x]) {
-                i2c.write(ADDR_8574_1, tmp, 1);
-                tmp1[0] = 0;
-                i2c.write(ADDR_8574_2, tmp1, 1);
-            }
-        }
-    }
-    
-/*
-    while(1) {
         dtr = rtc.read(TIME);
         i2c.write(ADDR_8574_1, &dtr.time.hours, 1);
         i2c.write(ADDR_8574_2, &dtr.time.minutes, 1);
-       
+        i2c.stop();
+        
         if (rc5.readclear(0) != 0xff) {
             if(rc5.read(2) != 0xff && rc5.read(3) != 0xff) {
-                hours = (dtr.time.hours & 0xf0) + (dtr.time.hours & 0x0f);
-                mins  = (dtr.time.minutes & 0xf0) + (dtr.time.minutes & 0x0f);
+                hours = ((dtr.time.hours >> 4) * 10) + (dtr.time.hours & 0x0f);
+                mins  = ((dtr.time.minutes >> 4) * 10) + (dtr.time.minutes & 0x0f);
             
                 switch(rc5.read(2)) {
                 case 0x47:  //Up
@@ -90,7 +70,6 @@
             }
         }
         
-        wait(.5);
+        wait(.1);
     }
-*/
 }