diff --git a/.clang-format b/.clang-format index 1fad350..0227352 100644 --- a/.clang-format +++ b/.clang-format @@ -16,14 +16,14 @@ AlignConsecutiveBitFields: AlignConsecutiveDeclarations: None AlignEscapedNewlines: Right AlignOperands: Align -SortIncludes: false +SortIncludes: true InsertBraces: true # Control statements must have curly brackets AlignTrailingComments: true AllowAllArgumentsOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortEnumsOnASingleLine: true AllowShortBlocksOnASingleLine: Empty -AllowShortCaseLabelsOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: true AllowShortFunctionsOnASingleLine: All AllowShortLambdasOnASingleLine: All AllowShortIfStatementsOnASingleLine: Never diff --git a/lwbtn/src/include/lwbtn/lwbtn.h b/lwbtn/src/include/lwbtn/lwbtn.h index 99ec17a..759a2f9 100644 --- a/lwbtn/src/include/lwbtn/lwbtn.h +++ b/lwbtn/src/include/lwbtn/lwbtn.h @@ -100,7 +100,7 @@ typedef uint8_t (*lwbtn_get_state_fn)(struct lwbtn* lwobj, struct lwbtn_btn* btn * \brief Button/input structure */ typedef struct lwbtn_btn { - uint16_t flags; /*!< Private button flags management */ + uint16_t flags; /*!< Private button flags management */ #if LWBTN_CFG_GET_STATE_MODE != LWBTN_GET_STATE_MODE_CALLBACK || __DOXYGEN__ uint8_t curr_state; /*!< Current button state to be processed. It is used to keep track when application manually sets the button state */ @@ -122,14 +122,14 @@ typedef struct lwbtn_btn { uint8_t cnt; /*!< Number of consecutive clicks detected, respecting maximum timeout between clicks */ } click; /*!< Click event structure */ - void* arg; /*!< User defined custom argument for callback function purpose */ + void* arg; /*!< User defined custom argument for callback function purpose */ #if LWBTN_CFG_TIME_DEBOUNCE_PRESS_DYNAMIC || __DOXYGEN__ - uint16_t time_debounce; /*!< Debounce time in milliseconds */ -#endif /* LWBTN_CFG_TIME_DEBOUNCE_PRESS_DYNAMIC || __DOXYGEN__ */ + uint16_t time_debounce; /*!< Debounce time in milliseconds */ +#endif /* LWBTN_CFG_TIME_DEBOUNCE_PRESS_DYNAMIC || __DOXYGEN__ */ #if LWBTN_CFG_TIME_DEBOUNCE_RELEASE_DYNAMIC || __DOXYGEN__ - uint16_t time_debounce_release; /*!< Debounce time in milliseconds for release event */ -#endif /* LWBTN_CFG_TIME_DEBOUNCE_RELEASE */ + uint16_t time_debounce_release; /*!< Debounce time in milliseconds for release event */ +#endif /* LWBTN_CFG_TIME_DEBOUNCE_RELEASE */ #if LWBTN_CFG_TIME_CLICK_MIN_DYNAMIC || __DOXYGEN__ uint16_t time_click_pressed_min; /*!< Minimum pressed time for valid click event */ #endif /* LWBTN_CFG_TIME_CLICK_MIN_DYNAMIC || __DOXYGEN__ */ @@ -137,23 +137,23 @@ typedef struct lwbtn_btn { uint16_t time_click_pressed_max; /*!< Maximum pressed time for valid click event*/ #endif /* LWBTN_CFG_TIME_CLICK_MAX_DYNAMIC || __DOXYGEN__ */ #if LWBTN_CFG_TIME_CLICK_MULTI_MAX_DYNAMIC || __DOXYGEN__ - uint16_t time_click_multi_max; /*!< Maximum time between 2 clicks to be considered consecutive click */ -#endif /* LWBTN_CFG_TIME_CLICK_MULTI_MAX_DYNAMIC || __DOXYGEN__ */ + uint16_t time_click_multi_max; /*!< Maximum time between 2 clicks to be considered consecutive click */ +#endif /* LWBTN_CFG_TIME_CLICK_MULTI_MAX_DYNAMIC || __DOXYGEN__ */ #if LWBTN_CFG_TIME_KEEPALIVE_PERIOD_DYNAMIC || __DOXYGEN__ - uint16_t time_keepalive_period; /*!< Time in ms for periodic keep alive event */ -#endif /* LWBTN_CFG_TIME_KEEPALIVE_PERIOD_DYNAMIC || __DOXYGEN__ */ + uint16_t time_keepalive_period; /*!< Time in ms for periodic keep alive event */ +#endif /* LWBTN_CFG_TIME_KEEPALIVE_PERIOD_DYNAMIC || __DOXYGEN__ */ #if LWBTN_CFG_CLICK_MAX_CONSECUTIVE_DYNAMIC || __DOXYGEN__ - uint16_t max_consecutive; /*!< Max number of consecutive clicks */ -#endif /* LWBTN_CFG_CLICK_MAX_CONSECUTIVE_DYNAMIC || __DOXYGEN__ */ + uint16_t max_consecutive; /*!< Max number of consecutive clicks */ +#endif /* LWBTN_CFG_CLICK_MAX_CONSECUTIVE_DYNAMIC || __DOXYGEN__ */ } lwbtn_btn_t; /** * \brief LwBTN group structure */ typedef struct lwbtn { - lwbtn_btn_t* btns; /*!< Pointer to buttons array */ - uint16_t btns_cnt; /*!< Number of buttons in array */ - lwbtn_evt_fn evt_fn; /*!< Pointer to event function */ + lwbtn_btn_t* btns; /*!< Pointer to buttons array */ + uint16_t btns_cnt; /*!< Number of buttons in array */ + lwbtn_evt_fn evt_fn; /*!< Pointer to event function */ #if LWBTN_CFG_GET_STATE_MODE != LWBTN_GET_STATE_MODE_MANUAL || __DOXYGEN__ lwbtn_get_state_fn get_state_fn; /*!< Pointer to get state function */ #endif /* LWBTN_CFG_GET_STATE_MODE != LWBTN_GET_STATE_MODE_MANUAL || __DOXYGEN__ */ diff --git a/lwbtn/src/lwbtn/lwbtn.c b/lwbtn/src/lwbtn/lwbtn.c index 69351c5..a3bfdcd 100644 --- a/lwbtn/src/lwbtn/lwbtn.c +++ b/lwbtn/src/lwbtn/lwbtn.c @@ -40,7 +40,7 @@ #define LWBTN_FLAG_ONPRESS_SENT ((uint16_t)0x0001) /*!< Flag indicates that on-press event has been sent */ #define LWBTN_FLAG_MANUAL_STATE \ - ((uint16_t)0x0002) /*!< Flag indicates that user wants to manually set button state. + ((uint16_t)0x0002) /*!< Flag indicates that user wants to manually set button state. Do not call "get_state" function */ #if LWBTN_CFG_TIME_DEBOUNCE_PRESS_DYNAMIC @@ -153,7 +153,7 @@ prv_process_btn(lwbtn_t* lwobj, lwbtn_btn_t* btn, uint32_t mstime) { /* Set keep alive time */ btn->keepalive.last_time = mstime; btn->keepalive.cnt = 0; -#endif /* LWBTN_CFG_USE_KEEPALIVE */ +#endif /* LWBTN_CFG_USE_KEEPALIVE */ btn->time_change = mstime; /* Button state has now changed */ }