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: EthernetNetIf NTPClient_NetServices TextLCD mbed
Revision 1:7c1d3790f08d, committed 2011-04-27
- Comitter:
- jf1vrr
- Date:
- Wed Apr 27 11:03:21 2011 +0000
- Parent:
- 0:50e7bcac5eb9
- Commit message:
- Rev. 0.01B Add time justify function, sec LED
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 50e7bcac5eb9 -r 7c1d3790f08d main.cpp
--- a/main.cpp Tue Apr 26 07:53:06 2011 +0000
+++ b/main.cpp Wed Apr 27 11:03:21 2011 +0000
@@ -1,6 +1,11 @@
-/*This is the clock which used highly quality RTC module RT8564NB.
+/*
+This is the clock which used highly quality RTC module RT8564NB.
This module is I2C controllable. At the time of poweron/reset, the start
-time received from ntp server.
+time received from ntp server.
+
+Revision History:
+Rev. 0.01A 2011/04/26 New
+Rev. 0.01B 2011/04/27 Add time justify function, sec LED
*/
#include "mbed.h"
#include "TextLCD.h"
@@ -31,6 +36,10 @@
EthernetNetIf eth;
NTPClient ntp;
I2C i2c(p9, p10);
+DigitalOut sec_led(LED1);
+DigitalOut test_led(LED2);
+InterruptIn just_button(p15);
+
int offset_JAPAN = 32400;
char year, month, day, week;
@@ -63,8 +72,29 @@
return value;
}
+
+void time_just()
+{
+ char _min, _hour;
+ test_led = !test_led;
+ _min = rtc_read(MINUTES);
+ if (_min >= 0x30) {
+ _hour = rtc_read(HOURS);
+ if (_hour == 0x23)
+ _hour = 0x00;
+ else if ((_hour & 0x0F) == 0x09)
+ _hour = (_hour & 0xF0) + 0x10;
+ else
+ _hour = _hour + 0x01;
+ rtc_write(HOURS, _hour);
+ }
+ rtc_write(MINUTES, 0x00);
+ rtc_write(SECONDS, 0x00);
+}
int main() {
+ just_button.rise(&time_just);
+
lcd.cls();
lcd.printf("RTC8564NB CLOCK" );
wait(2.0);
@@ -145,6 +175,8 @@
((hour >> 4) & 0x03) + 0x30, (hour & 0x0F) + 0x30,
(minute >> 4) + 0x30, (minute & 0x0F) + 0x30,
(sec >> 4) + 0x30, (sec & 0x0F) + 0x30 );
- wait(1.0);
+
+ sec_led = !sec_led;
+ wait(0.5);
}
}