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.
Maple_alarm_clock.h@1:aefa1992ce0f, 2011-10-10 (annotated)
- Committer:
- uehara00
- Date:
- Mon Oct 10 11:45:51 2011 +0000
- Revision:
- 1:aefa1992ce0f
- Parent:
- 0:0be38b583cf7
- Child:
- 3:eec13a411e94
Date/time display to LCD, adjust by buttons, alarm, timer, clock-output control. Just an example of RTC funtions, not for a practical use.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| uehara00 | 1:aefa1992ce0f | 1 | //copyright 2011 Uehara Yoshiyuki |
| uehara00 | 1:aefa1992ce0f | 2 | //==================================================================== |
| uehara00 | 1:aefa1992ce0f | 3 | //The author provide the programs without any guarantees or warranty. |
| uehara00 | 1:aefa1992ce0f | 4 | //The author is not responsible for any damage or losses of any kind |
| uehara00 | 1:aefa1992ce0f | 5 | //caused by using or misusing of the programs. |
| uehara00 | 1:aefa1992ce0f | 6 | //The author is under no obligation to provide support, service, |
| uehara00 | 1:aefa1992ce0f | 7 | //corrections, or upgrades to the programs. |
| uehara00 | 1:aefa1992ce0f | 8 | //==================================================================== |
| uehara00 | 0:0be38b583cf7 | 9 | // MAPLE board[MARM01-BASE] |
| uehara00 | 1:aefa1992ce0f | 10 | // alarm clock |
| uehara00 | 0:0be38b583cf7 | 11 | #ifndef MAPLE_ALARM_CLOCK_H_ |
| uehara00 | 0:0be38b583cf7 | 12 | #define MAPLE_ALARM_CLOCK_H_ |
| uehara00 | 0:0be38b583cf7 | 13 | |
| uehara00 | 0:0be38b583cf7 | 14 | // constants |
| uehara00 | 0:0be38b583cf7 | 15 | #define ALARM_CLOCK_REFRESH_RATE 0.1 // 100ms |
| uehara00 | 0:0be38b583cf7 | 16 | |
| uehara00 | 1:aefa1992ce0f | 17 | #define MODE_NORMAL 0 |
| uehara00 | 1:aefa1992ce0f | 18 | #define MODE_ADJUST 1 |
| uehara00 | 1:aefa1992ce0f | 19 | #define MODE_ALARM 2 |
| uehara00 | 1:aefa1992ce0f | 20 | #define MODE_TIMER 3 |
| uehara00 | 1:aefa1992ce0f | 21 | |
| uehara00 | 1:aefa1992ce0f | 22 | #define CURSOR_NORMAL_TIMER_FLAG 0 |
| uehara00 | 1:aefa1992ce0f | 23 | #define CURSOR_NORMAL_ALARM_FLAG 1 |
| uehara00 | 1:aefa1992ce0f | 24 | #define CURSOR_NORMAL_MAX 1 |
| uehara00 | 0:0be38b583cf7 | 25 | |
| uehara00 | 1:aefa1992ce0f | 26 | #define CURSOR_ADJUST_CENTURY 0 |
| uehara00 | 1:aefa1992ce0f | 27 | #define CURSOR_ADJUST_YEAR 1 |
| uehara00 | 1:aefa1992ce0f | 28 | #define CURSOR_ADJUST_MONTH 2 |
| uehara00 | 1:aefa1992ce0f | 29 | #define CURSOR_ADJUST_DAY 3 |
| uehara00 | 1:aefa1992ce0f | 30 | #define CURSOR_ADJUST_HOUR 4 |
| uehara00 | 1:aefa1992ce0f | 31 | #define CURSOR_ADJUST_MINUTE 5 |
| uehara00 | 1:aefa1992ce0f | 32 | #define CURSOR_ADJUST_SECOND 6 |
| uehara00 | 1:aefa1992ce0f | 33 | #define CURSOR_ADJUST_MAX 6 |
| uehara00 | 0:0be38b583cf7 | 34 | |
| uehara00 | 1:aefa1992ce0f | 35 | #define CURSOR_ALARM_DAY_DISABLE 0 |
| uehara00 | 1:aefa1992ce0f | 36 | #define CURSOR_ALARM_DAY 1 |
| uehara00 | 1:aefa1992ce0f | 37 | #define CURSOR_ALARM_WEEKDAY_DISABLE 2 |
| uehara00 | 1:aefa1992ce0f | 38 | #define CURSOR_ALARM_WEEKDAY 3 |
| uehara00 | 1:aefa1992ce0f | 39 | #define CURSOR_ALARM_INTERRUPT 4 |
| uehara00 | 1:aefa1992ce0f | 40 | #define CURSOR_ALARM_FLAG 5 |
| uehara00 | 1:aefa1992ce0f | 41 | #define CURSOR_ALARM_HOUR_DISABLE 6 |
| uehara00 | 1:aefa1992ce0f | 42 | #define CURSOR_ALARM_HOUR 7 |
| uehara00 | 1:aefa1992ce0f | 43 | #define CURSOR_ALARM_MINUTE_DISABLE 8 |
| uehara00 | 1:aefa1992ce0f | 44 | #define CURSOR_ALARM_MINUTE 9 |
| uehara00 | 1:aefa1992ce0f | 45 | #define CURSOR_ALARM_MAX 9 |
| uehara00 | 0:0be38b583cf7 | 46 | |
| uehara00 | 1:aefa1992ce0f | 47 | #define CURSOR_TIMER_SELECT 0 |
| uehara00 | 1:aefa1992ce0f | 48 | #define CURSOR_TIMER_COUNT 1 |
| uehara00 | 1:aefa1992ce0f | 49 | #define CURSOR_CLKOUT_ENABLE 2 |
| uehara00 | 1:aefa1992ce0f | 50 | #define CURSOR_TIMER_PERIODIC 3 |
| uehara00 | 1:aefa1992ce0f | 51 | #define CURSOR_TIMER_ENABLE 4 |
| uehara00 | 1:aefa1992ce0f | 52 | #define CURSOR_TIMER_INTERRUPT 5 |
| uehara00 | 1:aefa1992ce0f | 53 | #define CURSOR_TIMER_FLAG 6 |
| uehara00 | 1:aefa1992ce0f | 54 | #define CURSOR_CLKOUT_FREQUENCY 7 |
| uehara00 | 1:aefa1992ce0f | 55 | #define CURSOR_TIMER_MAX 7 |
| uehara00 | 0:0be38b583cf7 | 56 | |
| uehara00 | 1:aefa1992ce0f | 57 | #define BUTTON_A 0 |
| uehara00 | 1:aefa1992ce0f | 58 | #define BUTTON_B 1 |
| uehara00 | 1:aefa1992ce0f | 59 | #define BUTTON_LEFT 2 |
| uehara00 | 1:aefa1992ce0f | 60 | #define BUTTON_DOWN 3 |
| uehara00 | 1:aefa1992ce0f | 61 | #define BUTTON_RIGHT 4 |
| uehara00 | 1:aefa1992ce0f | 62 | #define BUTTON_UP 5 |
| uehara00 | 1:aefa1992ce0f | 63 | |
| uehara00 | 1:aefa1992ce0f | 64 | #define BUTTON_ON 0 |
| uehara00 | 1:aefa1992ce0f | 65 | #define BUTTON_OFF 1 |
| uehara00 | 1:aefa1992ce0f | 66 | |
| uehara00 | 1:aefa1992ce0f | 67 | #define BUTTON_THRESHOLD 0 // 0 x 100ms |
| uehara00 | 1:aefa1992ce0f | 68 | #define BUTTON_REPEAT 10 // 1s |
| uehara00 | 1:aefa1992ce0f | 69 | #define BUTTON_FAST 40 // 4s |
| uehara00 | 1:aefa1992ce0f | 70 | #define BUTTON_PERIOD_REPEAT 3 // 300ms |
| uehara00 | 1:aefa1992ce0f | 71 | #define BUTTON_PERIOD_FAST 1 // 100ms |
| uehara00 | 1:aefa1992ce0f | 72 | |
| uehara00 | 1:aefa1992ce0f | 73 | #define BUTTON_IDLE 0 // button status not active |
| uehara00 | 1:aefa1992ce0f | 74 | #define BUTTON_BUSY 1 // button status active once and repeat |
| uehara00 | 0:0be38b583cf7 | 75 | |
| uehara00 | 0:0be38b583cf7 | 76 | // prototypes |
| uehara00 | 0:0be38b583cf7 | 77 | void alarm_clock_initialize(); |
| uehara00 | 0:0be38b583cf7 | 78 | void alarm_clock_refresh(); |
| uehara00 | 0:0be38b583cf7 | 79 | |
| uehara00 | 1:aefa1992ce0f | 80 | static void alarm_clock_refresh_display(); |
| uehara00 | 1:aefa1992ce0f | 81 | static void button_check(); |
| uehara00 | 1:aefa1992ce0f | 82 | static void button_on_check(int read_data, int button_numer); |
| uehara00 | 1:aefa1992ce0f | 83 | static bool button_trigger(int button_numer, int repeat_enable, int fast_repeat_enable); |
| uehara00 | 1:aefa1992ce0f | 84 | static void button_exit(); |
| uehara00 | 1:aefa1992ce0f | 85 | static void button_function(); |
| uehara00 | 1:aefa1992ce0f | 86 | static void button_cursor_move(int flag); |
| uehara00 | 1:aefa1992ce0f | 87 | static void button_xxcrement(int flag); |
| uehara00 | 1:aefa1992ce0f | 88 | static void button_xxcrement_normal(int flag); |
| uehara00 | 1:aefa1992ce0f | 89 | static void button_xxcrement_adjust(int flag); |
| uehara00 | 1:aefa1992ce0f | 90 | static void button_xxcrement_adjust_date(int flag); |
| uehara00 | 1:aefa1992ce0f | 91 | static void button_xxcrement_alarm(int flag); |
| uehara00 | 1:aefa1992ce0f | 92 | static void button_xxcrement_timer(int flag); |
| uehara00 | 0:0be38b583cf7 | 93 | |
| uehara00 | 0:0be38b583cf7 | 94 | #endif |