|
fremoclock
1_3A01
FREMO Clock - Software for UTG
|
Push button debouncing module for Atmel AVR. More...
Go to the source code of this file.
Macros | |
| #define | BUTTON_PRESSED 0 |
| Button pressed. More... | |
| #define | BUTTON_REPEAT 1 |
| Button autorepeat. More... | |
| #define | BUTTON_SERVED 7 |
| Button handled. More... | |
Enumerations | |
| enum | button_t { BUTTON_ENTER = 0, BUTTON_BACK = 1, BUTTON_UP = 2, BUTTON_DOWN = 3, NUM_BUTTONS = 4 } |
| Enum for buttons used. More... | |
Functions | |
| static bool | PushButtonSingleShotAction (button_t ucButton) |
| Test if button is pressed. More... | |
| void | PushButtonInit (void) |
| Initialization of module. More... | |
| static uint8_t | PushButtonReadStatus (button_t buttonIdx) |
| Read status bits for the button. More... | |
| static void | PushButtonSetStatusServed (button_t ucButton) |
| Set that button has already been handled. More... | |
| bool | PushButtonSingleShotEnter (void) |
| Test if button enter is pressed. More... | |
| bool | PushButtonSingleShotBack (void) |
| Test if button back is pressed. More... | |
| bool | PushButtonSingleShotUp (void) |
| Test if button up is pressed. More... | |
| bool | PushButtonSingleShotDown (void) |
| Test if button down is pressed. More... | |
| uint8_t | PushButtonGetUpDownValue (uint8_t ucbut, uint8_t ucmin, uint8_t ucmax) |
| Get selection value by up and down button. More... | |
| static void | PushButtonPressed (button_t ucButton) |
| Used by PushButtonInterrupt during interrupt service when button is down. More... | |
| static void | PushButtonRelease (button_t ucButton) |
| Used by PushButtonInterrupt during interrupt service when button is up. More... | |
| void | PushButtonInterrupt (void) |
| Called by timer interrupt every 10ms. More... | |
Variables | |
| static const uint16_t | BUTTON_PRESSED_VALUE = 5 |
| time in 10ms for button recognized as pressed More... | |
| static const uint16_t | BUTTON_REPEAT_VALUE = 50 |
| time in 10ms for button recognized as repeated More... | |
| static const uint16_t | UP_DOWN_WAIT = 250 |
| Value to wait in milliseconds. More... | |
| static volatile uint16_t | uiButtonDebounce [NUM_BUTTONS] |
| Incremented every 10 mS as long as button is pushed. More... | |
| static volatile uint8_t | ucButtonStatus [NUM_BUTTONS] |
| Status of the Buttons. More... | |
Push button debouncing module for Atmel AVR.
Supplies debouncing for push buttons incl. autorepeat.
History:
Definition in file PushButton.c.
| #define BUTTON_PRESSED 0 |
Button pressed.
Definition at line 61 of file PushButton.c.
| #define BUTTON_REPEAT 1 |
Button autorepeat.
Definition at line 64 of file PushButton.c.
| #define BUTTON_SERVED 7 |
Button handled.
Definition at line 67 of file PushButton.c.
| enum button_t |
Enum for buttons used.
Used as indices in arrays uiButtonDebounce and ucButtonStatus.
Definition at line 37 of file PushButton.c.
| uint8_t PushButtonGetUpDownValue | ( | uint8_t | ucbut, |
| uint8_t | ucmin, | ||
| uint8_t | ucmax | ||
| ) |
Get selection value by up and down button.
| ucbut | current value |
| ucmin | minimal allowed value |
| ucmax | amximal allowd value |
Definition at line 217 of file PushButton.c.

| void PushButtonInit | ( | void | ) |
Initialization of module.
Call once in main after start.
Definition at line 92 of file PushButton.c.
| void PushButtonInterrupt | ( | void | ) |
Called by timer interrupt every 10ms.
Runs with global interrupts disabled. Read the ports used by push buttons and increment uiButtonDebounce when pressed. Update ucButtonStatus when uiButtonDebounce reaches BUTTON_PRESSED_VALUE or BUTTON_REPEAT_VALUE.
Definition at line 292 of file PushButton.c.

|
inlinestatic |
Used by PushButtonInterrupt during interrupt service when button is down.
Runs with global interrupts disabled.
Definition at line 261 of file PushButton.c.
|
static |
Read status bits for the button.
The read is done with interrupts disabled.
| buttonIdx | the button (BUTTON_ENTER, BUTTON_BACK, BUTTON_UP, ...) |
Definition at line 116 of file PushButton.c.
|
inlinestatic |
Used by PushButtonInterrupt during interrupt service when button is up.
Runs with global interrupts disabled.
Definition at line 278 of file PushButton.c.
|
static |
Set that button has already been handled.
Sets BUTTON_SERVED bit in ucButtonStatus. This is done with interrupts disabled.
Definition at line 130 of file PushButton.c.
|
static |
Test if button is pressed.
| ucButton | the button (BUTTON_ENTER, BUTTON_BACK, BUTTON_UP, ...) |
Definition at line 192 of file PushButton.c.

| bool PushButtonSingleShotBack | ( | void | ) |
Test if button back is pressed.
Definition at line 158 of file PushButton.c.

| bool PushButtonSingleShotDown | ( | void | ) |
Test if button down is pressed.
Definition at line 180 of file PushButton.c.

| bool PushButtonSingleShotEnter | ( | void | ) |
Test if button enter is pressed.
Definition at line 147 of file PushButton.c.

| bool PushButtonSingleShotUp | ( | void | ) |
Test if button up is pressed.
Definition at line 169 of file PushButton.c.

|
static |
time in 10ms for button recognized as pressed
Definition at line 46 of file PushButton.c.
|
static |
time in 10ms for button recognized as repeated
Definition at line 49 of file PushButton.c.
|
static |
Status of the Buttons.
Used as set (bit array) of BUTTON_PRESSED, BUTTON_REPEAT, BUTTON_SERVED. Accessed by PushButtonInterrupt, PushButtonReadStatus and PushButtonSetStatusServed.
Definition at line 83 of file PushButton.c.
|
static |
Incremented every 10 mS as long as button is pushed.
Only used in PushButtonInterrupt()
Definition at line 75 of file PushButton.c.
|
static |
Value to wait in milliseconds.
Definition at line 52 of file PushButton.c.