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
- Committer:
- dennyem
- Date:
- 2014-02-13
- Revision:
- 1:a8b9fb95696b
- Parent:
- 0:f09cf90def53
- Child:
- 2:4184f92440a1
File content as of revision 1:a8b9fb95696b:
#include <mbed.h>
//#include "IRremote.h"
#include "PCF8583_rtc.h"
void NixieDisplay(void);
DigitalOut Red(P0_7);
DigitalOut Green(P0_17);
DigitalOut Blue(P0_16);
I2C i2c(P0_10, P0_11); // sda, scl
PCF8583rtc rtc(&i2c, PCF8583_addr);
//IRremote rc5(P0_0);
// i2c addresses
const int ADDR_8574_1 = 0x70;
const int ADDR_8574_2 = 0x72;
int alarm = OFF;
int setTimer = OFF;
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);
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);
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);
switch(rc5.read(2)) {
case 0x47: //Up
hours++;
dtr.time.hours = rtc.bin2bcd(hours);
break;
case 0x48: //Down
hours--;
dtr.time.hours = rtc.bin2bcd(hours);
break;
case 0x59: //Left
mins++;
dtr.time.minutes = rtc.bin2bcd(mins);
break;
case 0x5a: //Right
mins--;
dtr.time.minutes = rtc.bin2bcd(mins);
break;
}
rtc.write(TIME, dtr); //Set the current date and time
rc5.clear();
}
}
wait(.5);
}
*/
}