libpynq (release 5EWC0-2023 version 0.2.1 of 2023-09-01 11:02)
|
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 (SWB_BTN0..SWB_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 (SWB_SW0..SWB_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 218 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 110 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 141 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 177 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 198 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 167 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 172 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 84 of file buttons.c.