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-09
- Revision:
- 0:f09cf90def53
- Child:
- 1:a8b9fb95696b
File content as of revision 0:f09cf90def53:
#include "mbed.h"
#include "PCF8583_rtc.h"
void NixieDisplay(void);
//void ChangeTime(void);
DigitalOut Red(P0_7);
DigitalOut Green(P0_17);
DigitalOut Blue(P0_16);
I2C i2c(P0_10, P0_11); // sda, scl
Serial pc(USBTX, USBRX); // tx, rx
Ticker TickerFunc;
PCF8583rtc rtc(&i2c);
// 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 dtBCD;
Red = Green = Blue = 1;
// TickerFunc.attach(&NixieDisplay, 1.0); // The address of the function to be attached and the interval (1 seconds)
i2c.frequency(400000);
while(1) {
rtc.read(TIME);
dtBCD = rtc.GetDateTimeBCD(); //get the date and time in BCD form
i2c.write(ADDR_8574_1, &dtBCD.time.hours, 1);
i2c.write(ADDR_8574_2, &dtBCD.time.minutes, 1);
Blue = !Blue;
wait(.5);
// if(!sw3.read()) { // Change Time
// ChangeTime();
// }
// pc.printf("Magnet = %d\n", magnet.read());
}
}
void NixieDisplay()
{
// i2c.write(ADDR_8574_1, &HoursBCD, 1);
// i2c.write(ADDR_8574_2, &MinsBCD, 1);
Red = !Red;
// time_t seconds = time(NULL);
// struct tm *t = localtime(&seconds);
//
// data = bin2bcd(t.tm_hour);
// i2c.writeite(ADDR_8574_1, &data, 1);
//
// data = bin2bcd(t.tm_min);
// i2c.writeite(ADDR_8574_2, &data, 1);
}
//void ChangeTime() {
// time_t seconds = time(NULL);
// wait(0.1);
// struct tm *t = localtime(&seconds);
//
// while(!sw3.read()) {
// if(!sw2.read()) { //Change Hour
// t.tm_hour += 1;
// } else {
// if(!sw1.read()) { //Change Minute
// t.tm_min += 1;
// }
// }
//
// set_time(mktime(t));
// wait(0.2);
// }
//}