Yoshiyuki Uehara / Mbed 2 deprecated Maple

Dependencies:   mbed

Maple_alarm_clock.h

Committer:
uehara00
Date:
2011-10-10
Revision:
1:aefa1992ce0f
Parent:
0:0be38b583cf7
Child:
3:eec13a411e94

File content as of revision 1:aefa1992ce0f:

//copyright 2011 Uehara Yoshiyuki
//====================================================================
//The author provide the programs without any guarantees or warranty.
//The author is not responsible for any damage or losses of any kind 
//caused by using or misusing of the programs.
//The author is under no obligation to provide support, service, 
//corrections, or upgrades to the programs.
//====================================================================
// MAPLE board[MARM01-BASE]
// alarm clock
#ifndef MAPLE_ALARM_CLOCK_H_
#define MAPLE_ALARM_CLOCK_H_

// constants
#define ALARM_CLOCK_REFRESH_RATE    0.1 // 100ms

#define MODE_NORMAL 0
#define MODE_ADJUST 1
#define MODE_ALARM  2
#define MODE_TIMER  3

#define CURSOR_NORMAL_TIMER_FLAG    0
#define CURSOR_NORMAL_ALARM_FLAG    1
#define CURSOR_NORMAL_MAX           1

#define CURSOR_ADJUST_CENTURY   0
#define CURSOR_ADJUST_YEAR      1
#define CURSOR_ADJUST_MONTH     2
#define CURSOR_ADJUST_DAY       3
#define CURSOR_ADJUST_HOUR      4
#define CURSOR_ADJUST_MINUTE    5
#define CURSOR_ADJUST_SECOND    6
#define CURSOR_ADJUST_MAX       6

#define CURSOR_ALARM_DAY_DISABLE        0
#define CURSOR_ALARM_DAY                1
#define CURSOR_ALARM_WEEKDAY_DISABLE    2
#define CURSOR_ALARM_WEEKDAY            3
#define CURSOR_ALARM_INTERRUPT          4
#define CURSOR_ALARM_FLAG               5
#define CURSOR_ALARM_HOUR_DISABLE       6
#define CURSOR_ALARM_HOUR               7
#define CURSOR_ALARM_MINUTE_DISABLE     8
#define CURSOR_ALARM_MINUTE             9
#define CURSOR_ALARM_MAX                9

#define CURSOR_TIMER_SELECT     0
#define CURSOR_TIMER_COUNT      1
#define CURSOR_CLKOUT_ENABLE    2
#define CURSOR_TIMER_PERIODIC   3
#define CURSOR_TIMER_ENABLE     4
#define CURSOR_TIMER_INTERRUPT  5
#define CURSOR_TIMER_FLAG       6
#define CURSOR_CLKOUT_FREQUENCY 7
#define CURSOR_TIMER_MAX        7

#define BUTTON_A       0
#define BUTTON_B       1
#define BUTTON_LEFT    2
#define BUTTON_DOWN    3
#define BUTTON_RIGHT   4
#define BUTTON_UP      5

#define BUTTON_ON      0
#define BUTTON_OFF     1

#define BUTTON_THRESHOLD        0   // 0 x 100ms
#define BUTTON_REPEAT           10  // 1s
#define BUTTON_FAST             40  // 4s
#define BUTTON_PERIOD_REPEAT    3   // 300ms
#define BUTTON_PERIOD_FAST      1   // 100ms

#define BUTTON_IDLE 0   // button status not active
#define BUTTON_BUSY 1   // button status active once and repeat

// prototypes
void alarm_clock_initialize();
void alarm_clock_refresh();

static void alarm_clock_refresh_display();
static void button_check();
static void button_on_check(int read_data, int button_numer);
static bool button_trigger(int button_numer, int repeat_enable, int fast_repeat_enable);
static void button_exit();
static void button_function();
static void button_cursor_move(int flag);
static void button_xxcrement(int flag);
static void button_xxcrement_normal(int flag);
static void button_xxcrement_adjust(int flag);
static void button_xxcrement_adjust_date(int flag);
static void button_xxcrement_alarm(int flag);
static void button_xxcrement_timer(int flag);

#endif