CubeMon-Vue-Demo-STM32F407VGT6U
|
digital inputs with falling/rising edge, short press, long press and double press detection More...
Go to the source code of this file.
Data Structures | |
struct | digitalInputInitData |
digital input initialization structure More... | |
Typedefs | |
typedef enum digInputs | digInputs |
typedef GPIO_PinState(* | input_get_hw_state) (digInputs input) |
typedef enum digitalInputActions | digitalInputActions |
possible input actions | |
typedef enum digitalInputHWType | digitalInputHWType |
possible input HW types | |
typedef enum digitalInputSWType | digitalInputSWType |
possible input SW types | |
typedef struct digitalInputInitData | digitalInputInitData |
digital input initialization structure | |
typedef enum digitalInputDateTypes | digitalInputDateTypes |
digital input data | |
Enumerations | |
enum | digInputs { DI_NONE , DI_BUTTON , DI_1 , DI_2 , DI_NONE } |
enum | digitalInputActions { INPUT_ACT_FALLING_EDGE , INPUT_ACT_RISING_EDGE , INPUT_ACT_SHORT_PRESS , INPUT_ACT_LONG_PRESS , INPUT_ACT_DOUBLE_PRESS , INPUT_ACT_NONE } |
possible input actions More... | |
enum | digitalInputHWType { INPUT_HW_ACTIVE_HIGH , INPUT_HW_ACTIVE_LOW } |
possible input HW types More... | |
enum | digitalInputSWType { INPUT_SW_ON_OFF_INPUT , INPUT_SW_BUTTON } |
possible input SW types More... | |
enum | digitalInputDateTypes { INPUT_DAT_CURR , INPUT_DAT_DEBOUNCED , INPUT_DAT_RISING_EDGE , INPUT_DAT_FALLING_EDGE , INPUT_DAT_SHORT_PRESS , INPUT_DAT_LONG_PRESS , INPUT_DAT_DOUBLE_PRESS } |
digital input data More... | |
Functions | |
retStatus | input_get (uint32_t input, uint16_t data, int32_t *value) |
Standardized getter function for digital input library. More... | |
retStatus | input_set (uint32_t input, uint16_t data, int32_t value) |
Standardized setter function for digital input library. More... | |
retStatus | input_init (digInputs input_name, digitalInputInitData digital_input_init_data) |
Digital input initialization function. More... | |
retStatus | input_get_init_data (digInputs input_name, digitalInputInitData *digital_input_init_data) |
Return input initialization data. More... | |
retStatus | input_ack_action (digInputs input_name, digitalInputActions action) |
Acknowledge digital input action. More... | |
uint8_t | input_get_action (digInputs input_name, digitalInputActions action) |
uint8_t | input_is_short_press (digInputs input_name) |
Checks if the input detected short press. After reading out the value, you need to clean the action flag with input_ack_action() or input_set() More... | |
uint8_t | input_is_long_press (digInputs input_name) |
Checks if the input detected long press. More... | |
dioStates | input_state_now (digInputs input_name) |
Return the input state read from HW at the moment the function is called. More... | |
dioStates | input_logical_state_debounced (digInputs input_name) |
Return the input debounced logical state. More... | |
void | input_handle (void) |
Handles digital input logic. Call every 1ms. More... | |
__weak GPIO_PinState | input_get_hw_HAL (digInputs input_name) |
Get HW input state. In case you want to implement it differently (f.e. not using HAL) More... | |
digital inputs with falling/rising edge, short press, long press and double press detection
Both active/low input types can be used. The detection of presses can be deactivated if the inputs is a toggle switch. For the tactile input types, the double press detection can be deactived as well.
A support for a direct manipulation of the input state with CUBE MX Monitoring tool is build in. If you want to use it, define flag ALLOW_CUBEMX_OVERWRITE in you project.
To use this library define flag LIB_DI in the lib_config.h file and create an enum in init.h file with the inputs you would like to use. You then have to initialize each input with input_init() function.
If the library is not used (LIB_DI is not defined as symbol) this dummy enum will be created to prevent compilation errors
enum digInputs |
enum digitalInputActions |
possible input actions
digital input data
Enumerator | |
---|---|
INPUT_DAT_CURR | input current logical value (not debounced), reading directly from HW |
INPUT_DAT_DEBOUNCED | input debounced logical value |
INPUT_DAT_RISING_EDGE | logical rising edge detected for INPUT_HW_ACTIVE_HIGH this will be set if the input goes from "0" to "1" for INPUT_HW_ACTIVE_LOW this will be set if the input goes from "1" to "0" it must be cleaned: with /ref input_set function and set value "0" or with /ref input_ack_action with argument /ref INPUT_ACT_RISING_EDGE |
INPUT_DAT_FALLING_EDGE | logical falling edge detected for INPUT_HW_ACTIVE_HIGH this will be set if the input goes from "1" to "0" for INPUT_HW_ACTIVE_LOW this will be set if the input goes from "0" to "1" it must be cleaned: with /ref input_set function and set value "0" or with /ref input_ack_action with argument /ref INPUT_ACT_FALLING_EDGE |
INPUT_DAT_SHORT_PRESS | input short press status read status with input_get, clean only the short press status with input_set and value "0" it must be cleaned: with /ref input_set function and set value "0" or with /ref input_ack_action with argument /ref INPUT_ACT_SHORT_PRESS |
INPUT_DAT_LONG_PRESS | input long press status read status with input_get, clean only the long press status with input_set and value "0" it must be cleaned: with /ref input_set function and set value "0" or with /ref input_ack_action with argument /ref INPUT_ACT_LONG_PRESS |
INPUT_DAT_DOUBLE_PRESS | input double press status read status with input_get, clean only the double press status with input_set and value "0" it must be cleaned: with /ref input_set function and set value "0" or with /ref input_ack_action with argument /ref INPUT_ACT_DOUBLE_PRESS |
enum digitalInputHWType |
enum digitalInputSWType |
possible input SW types
retStatus input_ack_action | ( | digInputs | input_name, |
digitalInputActions | action | ||
) |
Acknowledge digital input action.
Digital input action digitalInputActions needs to be manually cleared before they are evaluated again.
[in] | input_name | input identification, defined by digInputs |
[out] | action | action to be cleared |
retStatus input_get | ( | uint32_t | input, |
uint16_t | data, | ||
int32_t * | value | ||
) |
Standardized getter function for digital input library.
[in] | input | is the input name defined by digInputs |
[in] | data | data for /p input that can be read out of the module, available data digitalInputDateTypes |
[out] | value | getter output |
uint32_t
and uint16_t
to keep the standard function prototype __weak GPIO_PinState input_get_hw_HAL | ( | digInputs | input_name | ) |
Get HW input state. In case you want to implement it differently (f.e. not using HAL)
[in] | input_name | input identification, defined by digInputs |
GPIO_PinState
(from the HAL library) retStatus input_get_init_data | ( | digInputs | input_name, |
digitalInputInitData * | digital_input_init_data | ||
) |
Return input initialization data.
In case you want to re-initialize some values but keep the rest as it was
[in] | input_name | input identification, defined by digInputs |
[out] | digital_input_init_data | input initialization data digitalInputInitData |
void input_handle | ( | void | ) |
Handles digital input logic. Call every 1ms.
retStatus input_init | ( | digInputs | input_name, |
digitalInputInitData | digital_input_init_data | ||
) |
Digital input initialization function.
[in] | input_name | input identification, defined by digInputs |
[in] | digital_input_init_data | input initialization data digitalInputInitData |
uint8_t input_is_long_press | ( | digInputs | input_name | ) |
Checks if the input detected long press.
[in] | input_name | input identification, defined by digInputs |
uint8_t input_is_short_press | ( | digInputs | input_name | ) |
Checks if the input detected short press. After reading out the value, you need to clean the action flag with input_ack_action() or input_set()
[in] | input_name | input identification, defined by digInputs |
Return the input debounced logical state.
Debounced input logical state is evaluated using the initialization data.
[in] | input_name | input identification, defined by digInputs |
retStatus input_set | ( | uint32_t | input, |
uint16_t | data, | ||
int32_t | value | ||
) |
Standardized setter function for digital input library.
[in] | input | input identification, defined by digInputs |
[in] | data | data for /p input that can be read out of the module, available data digitalInputDateTypes |
[in] | value | value to be set |
You can not set values that are read from HW or calculated from the HW value: INPUT_DAT_CURR and INPUT_DAT_DEBOUNCED
input
and /p data types are changed to uint32_t
and uint16_t
to keep the standard function prototype Return the input state read from HW at the moment the function is called.
[in] | input_name | input identification, defined by digInputs |