libpynq (release 5EWC0-2023 version 0.2.3 of 2023-10-06 18:15)
|
Macros | |
#define | BUTTON_NOT_PUSHED 0 |
#define | BUTTON_PUSHED 1 |
#define | SWITCH_OFF 0 |
#define | SWITCH_ON 1 |
Enumerations | |
enum | button_index_t { BUTTON0 , BUTTON1 , BUTTON2 , BUTTON3 , NUM_BUTTONS } |
enum | switches_index_t { SWITCH0 , SWITCH1 , NUM_SWITCHES } |
Functions | |
void | switches_init (void) |
void | switches_destroy (void) |
void | buttons_init (void) |
void | buttons_destroy (void) |
int | get_button_state (const int button) |
int | wait_until_button_state (const int button, const int state) |
int | sleep_msec_button_pushed (const int button, const int msec) |
void | sleep_msec_buttons_pushed (int button_states[], const int ms) |
int | wait_until_button_pushed (const int button) |
int | wait_until_button_released (const int button) |
int | wait_until_any_button_pushed (void) |
int | wait_until_any_button_released (void) |
int | get_switch_state (const int switch_num) |
Wrappers to simplify the use of buttons.
An example of how to use this library.
Buttons can also be used through GPIO (see gpio.h and pinmap.h). Note that GPIO numbering (IO_BTN0..IO_BTN3) is then used instead of 0..NUM_BUTTONS-1 (BUTTON0..BUTTON3). GPIO return values are GPIO_LEVEL_LOW/HIGH instead of BUTTON_(NOT_)PUSHED.
Switches can also be used through GPIO (see gpio.h and pinmap.h). Note that GPIO numbering (IO_SW0..IO_SW1) is then used instead of 0..NUM_SWITCHES-1 (SWITCH0..SWITCH1). GPIO return values are GPIO_LEVEL_LOW/HIGH instead of SWITCH_ON/OFF.
enum button_index_t |
enum switches_index_t |
void buttons_init | ( | void | ) |
int get_button_state | ( | const int | button | ) |
Return the state of the button (BUTTON_(NOT_)PUSHED).
button | The button the state of which is returned. |
Definition at line 71 of file buttons.c.
int get_switch_state | ( | const int | switch_num | ) |
Definition at line 217 of file buttons.c.
int sleep_msec_button_pushed | ( | const int | button, |
const int | msec | ||
) |
Check if the given button is pushed in msec milliseconds. The function does NOT return early.
button | The button of which the state is monitored. |
msec | The number of milliseconds to wait. |
Definition at line 109 of file buttons.c.
void sleep_msec_buttons_pushed | ( | int | button_states[], |
const int | ms | ||
) |
Check if any button is pushed in msec milliseconds. The function does NOT return early.
button_states | The array of button states that are updated with BUTTON_PUSHED or BUTTON_NOT_PUSHED. |
Definition at line 140 of file buttons.c.
void switches_init | ( | void | ) |
int wait_until_any_button_pushed | ( | void | ) |
Wait until any button is not pushed (which may be immediately).
Definition at line 176 of file buttons.c.
int wait_until_any_button_released | ( | void | ) |
Wait until the given button is not pushed (which may be immediately).
Definition at line 197 of file buttons.c.
int wait_until_button_pushed | ( | const int | button | ) |
Wait until the given button is pushed (which may be immediately).
button | The button of which the state is monitored. |
Definition at line 166 of file buttons.c.
int wait_until_button_released | ( | const int | button | ) |
Wait until the given button is not pushed (which may be immediately).
button | The button of which the state is monitored. |
Definition at line 171 of file buttons.c.
int wait_until_button_state | ( | const int | button, |
const int | state | ||
) |
Wait until the given button is in state (which may be immediately).
button | The button of which the state is monitored. |
state | The state that is waited for. Must be BUTTON_PUSHED or BUTTON_NOT_PUSHED. |
Definition at line 83 of file buttons.c.