Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: PCF8583_rtc mbed
main.cpp
00001 #include <mbed.h> 00002 #include "IRremote.h" 00003 #include "PCF8583_rtc.h" 00004 00005 void NixieDisplay(void); 00006 00007 DigitalOut Red(P0_7); 00008 DigitalOut Green(P0_17); 00009 DigitalOut Blue(P0_16); 00010 00011 I2C i2c(P0_10, P0_11); // sda, scl 00012 PCF8583rtc rtc(&i2c, PCF8583_addr_2); 00013 IRremote rc5(P0_0); 00014 00015 // i2c addresses 00016 const int ADDR_8574_1 = 0x70; 00017 const int ADDR_8574_2 = 0x72; 00018 00019 int alarm = OFF; 00020 int setTimer = OFF; 00021 00022 int main() 00023 { 00024 struct DateTime_t dtr; 00025 char hours; 00026 char mins; 00027 00028 Red = Green = Blue = 1; 00029 00030 i2c.frequency(400000); 00031 00032 /* rtc.configureControlReg(0); 00033 dtr = rtc.read(TIME); //Set the clock from scratch 00034 dtr.time.hours = rtc.bin2bcd(8); 00035 dtr.time.minutes = rtc.bin2bcd(22); 00036 rtc.write(TIME, dtr); 00037 wait(.1); 00038 */ 00039 while(1) { 00040 dtr = rtc.read(TIME); 00041 i2c.write(ADDR_8574_1, &dtr.time.hours, 1); 00042 i2c.write(ADDR_8574_2, &dtr.time.minutes, 1); 00043 i2c.stop(); 00044 00045 if (rc5.readclear(0) != 0xff) { 00046 if(rc5.read(2) != 0xff && rc5.read(3) != 0xff) { 00047 hours = ((dtr.time.hours >> 4) * 10) + (dtr.time.hours & 0x0f); 00048 mins = ((dtr.time.minutes >> 4) * 10) + (dtr.time.minutes & 0x0f); 00049 00050 switch(rc5.read(2)) { 00051 case 0x47: //Up 00052 hours++; 00053 dtr.time.hours = rtc.bin2bcd(hours); 00054 break; 00055 case 0x48: //Down 00056 hours--; 00057 dtr.time.hours = rtc.bin2bcd(hours); 00058 break; 00059 case 0x59: //Left 00060 mins++; 00061 dtr.time.minutes = rtc.bin2bcd(mins); 00062 break; 00063 case 0x5a: //Right 00064 mins--; 00065 dtr.time.minutes = rtc.bin2bcd(mins); 00066 break; 00067 } 00068 00069 rtc.write(TIME, dtr); //Set the current date and time 00070 rc5.clear(); 00071 } 00072 } 00073 00074 wait(.1); 00075 } 00076 }
Generated on Sat Jul 23 2022 14:16:51 by
