This is an automated email from the ASF dual-hosted git repository. jerzy pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit c400a05b07ff9158e2aaede4f47341613e9bca7d Author: Jerzy Kasenberg <[email protected]> AuthorDate: Thu Dec 10 10:11:02 2020 +0100 util/button: Defunct tick based times in syscfg Several time interval values were using ticks as units. Default values for those were defined with expressions involving OS_TICKS_PER_SEC that clearly indicated that times were meant to be expressed in real time instead of build specific ticks. This introduces button time syscfg values defined in ms, and defunct old tick-based value. Resulting code should stay the same since computation will be done during compilation as before. --- hw/util/button/src/button.c | 18 +++++++++--------- hw/util/button/syscfg.yml | 32 ++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/hw/util/button/src/button.c b/hw/util/button/src/button.c index 2744b1c..005afb3 100644 --- a/hw/util/button/src/button.c +++ b/hw/util/button/src/button.c @@ -370,14 +370,14 @@ button_exec_fsm(button_t *button, int action) do_pressed: #if MYNEWT_VAL(BUTTON_USE_LONG) if (button->mode & BUTTON_FLG_LONG) { - os_callout_reset(callout, MYNEWT_VAL(BUTTON_LONGHOLD_TICKS)); + os_callout_reset(callout, os_time_ms_to_ticks32(MYNEWT_VAL(BUTTON_LONGHOLD_TIME_MS))); #if MYNEWT_VAL(BUTTON_USE_REPEAT) } else if (button->mode & BUTTON_FLG_REPEATING) { - os_callout_reset(callout, MYNEWT_VAL(BUTTON_REPEAT_FIRST_TICKS)); + os_callout_reset(callout, os_time_ms_to_ticks32(MYNEWT_VAL(BUTTON_REPEAT_FIRST_TIME_MS))); #endif } #elif MYNEWT_VAL(BUTTON_USE_REPEAT) - os_callout_reset(callout, MYNEWT_VAL(BUTTON_REPEAT_FIRST_TICKS)); + os_callout_reset(callout, os_time_ms_to_ticks32(MYNEWT_VAL(BUTTON_REPEAT_FIRST_TIME_MS))); #endif button->state = BUTTON_FLG_PRESSED; #if MYNEWT_VAL(BUTTON_EMIT_STATE_CHANGED) @@ -391,23 +391,23 @@ button_exec_fsm(button_t *button, int action) #if MYNEWT_VAL(BUTTON_USE_DOUBLE) to_wait_dblpressed: - os_callout_reset(callout, MYNEWT_VAL(BUTTON_DBLCLICK_TICKS)); + os_callout_reset(callout, os_time_ms_to_ticks32(MYNEWT_VAL(BUTTON_DBLCLICK_TIMEOUT_MS))); button->fsm_state = _BUTTON_FSM_WAIT_DBLPRESSED; return; do_dblpressed: #if MYNEWT_VAL(BUTTON_USE_LONG) if (button->mode & BUTTON_FLG_LONG) { - os_callout_reset(callout, MYNEWT_VAL(BUTTON_LONGHOLD_TICKS)); + os_callout_reset(callout, os_time_ms_to_ticks32(MYNEWT_VAL(BUTTON_LONGHOLD_TIME_MS))); #if MYNEWT_VAL(BUTTON_USE_REPEAT) } else if (button->mode & BUTTON_FLG_REPEATING) { - os_callout_reset(callout, MYNEWT_VAL(BUTTON_REPEAT_FIRST_TICKS)); + os_callout_reset(callout, os_time_ms_to_ticks32(MYNEWT_VAL(BUTTON_REPEAT_FIRST_TIME_MS))); #endif } else { os_callout_stop(callout); } #elif MYNEWT_VAL(BUTTON_USE_REPEAT) - os_callout_reset(callout, MYNEWT_VAL(BUTTON_REPEAT_FIRST_TICKS)); + os_callout_reset(callout, os_time_ms_to_ticks32(MYNEWT_VAL(BUTTON_REPEAT_FIRST_TIME_MS))); #else os_callout_stop(callout); #endif @@ -423,7 +423,7 @@ button_exec_fsm(button_t *button, int action) do_longpress: #if MYNEWT_VAL(BUTTON_USE_REPEAT) if (button->mode & BUTTON_FLG_REPEATING) - os_callout_reset(callout, MYNEWT_VAL(BUTTON_REPEAT_FIRST_TICKS)); + os_callout_reset(callout, os_time_ms_to_ticks32(MYNEWT_VAL(BUTTON_REPEAT_FIRST_TIME_MS))); #endif button->state |= BUTTON_FLG_LONG; #if MYNEWT_VAL(BUTTON_EMIT_STATE_CHANGED) @@ -435,7 +435,7 @@ button_exec_fsm(button_t *button, int action) #if MYNEWT_VAL(BUTTON_USE_REPEAT) do_repeat: - os_callout_reset(callout, MYNEWT_VAL(BUTTON_REPEAT_TICKS)); + os_callout_reset(callout, os_time_ms_to_ticks32(MYNEWT_VAL(BUTTON_REPEAT_TIME_MS))); #if MYNEWT_VAL(BUTTON_EMIT_ACTION) #if MYNEWT_VAL(BUTTON_USE_EMULATION) diff --git a/hw/util/button/syscfg.yml b/hw/util/button/syscfg.yml index 5e0f4ca..e523300 100644 --- a/hw/util/button/syscfg.yml +++ b/hw/util/button/syscfg.yml @@ -19,24 +19,40 @@ syscfg.defs: BUTTON_DBLCLICK_TICKS: + description: Use BUTTON_DBLCLICK_TIMEOUT_MS instead. + defunct: 1 + value: + BUTTON_LONGHOLD_TICKS: + description: Use BUTTON_LONGHOLD_TIME_MS instead. + defunct: 1 + value: + BUTTON_REPEAT_FIRST_TICKS: + description: Use BUTTON_REPEAT_FIRST_TIME_MS instead. + defunct: 1 + value: + BUTTON_REPEAT_TICKS: + description: Use BUTTON_REPEAT_TIME_MS instead. + defunct: 1 + value: + BUTTON_DBLCLICK_TIMEOUT_MS: description: > - Maximum time in wich a second click should be performed + Maximum time in which a second click should be performed to consider it a double click. This will also introduce a delay for generating the single click event. - value: '(OS_TICKS_PER_SEC / 4)' - BUTTON_LONGHOLD_TICKS: + value: 250 + BUTTON_LONGHOLD_TIME_MS: description: > Minimum time to wait with the button pressed to consider it a long hold (long press, long click, long double click). - value: '(OS_TICKS_PER_SEC)' - BUTTON_REPEAT_FIRST_TICKS: + value: 1000 + BUTTON_REPEAT_FIRST_TIME_MS: description: > Time to wait before generating the first repeated action. - value: '(OS_TICKS_PER_SEC)' - BUTTON_REPEAT_TICKS: + value: 1000 + BUTTON_REPEAT_TIME_MS: description: > Time to wait before generating consecutive repeated action. - value: '(OS_TICKS_PER_SEC)' + value: 1000 BUTTON_EVENT_MAX: description: > Maximum number of pending button event. (about 20bytes/event)
