⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
Hdhdh Ddjek
Offline
Last seen:13 hours 33 min ago
加入:2020-06-03 14:15
Long press button

How do I implement a long press button event?

I currently have the following and coming from an arduino environment I would normally use millis() to time the button presses.

static void user_app_button_press_cb(void) { uint8_t next_btn_event = 0; // Read button state if(GPIO_GetPinStatus(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN)) { app_sleep_env.custs1_btn_state = CUSTS1_BTN_STATE_RELEASED; next_btn_event = WKUPCT_PIN_POLARITY_LOW; } else { app_sleep_env.custs1_btn_state = CUSTS1_BTN_STATE_PRESSED; next_btn_event = WKUPCT_PIN_POLARITY_HIGH; } // Update button characteristic struct custs1_val_ntf_ind_req *req = KE_MSG_ALLOC_DYN(CUSTS1_VAL_NTF_REQ, prf_get_task_from_id(TASK_ID_CUSTS1), TASK_APP, custs1_val_ntf_ind_req, DEF_SVC1_BUTTON_STATE_CHAR_LEN); req->conidx = app_env->conidx; req->notification = true; req->handle = SVC1_IDX_BUTTON_STATE_VAL; req->length = DEF_SVC1_BUTTON_STATE_CHAR_LEN; req->value[0] = app_sleep_env.custs1_btn_state; ke_msg_send(req); // Configure next button event user_app_set_button_event(next_btn_event); }

Keywords:
Device:
PM_Dialog
Offline
Last seen:7小时11分钟前
工作人员
加入:2018-02-08 11:03
Hi Hdhdh Ddjek,

Hi Hdhdh Ddjek,

Thanks for your question. Do you want to get a callback triggered upon the button release? Do you need this button to wake up the device when is sleep mode? If yes, take a look at the ble_app_sleepmode example of the SKD and check app_button_enable() function. This example uses the wake-up controller to configure a wake-up pin.

Probably you might check out some past forum threads regarding the long press button:

https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-da1458x-bt42-%E2%80%93-software/button-long-press-detection

https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bluetooth-low-energy-42-%E2%80%93-software/button-press-time

Please let me know if you need further support on this/

Thanks, PM_Dialog

Hdhdh Ddjek
Offline
Last seen:13 hours 33 min ago
加入:2020-06-03 14:15
the above didnt help, so what

the above didnt help, so what I would like is the button state to only show a 01 in the app when the 3 secs have elapsed.

PM_Dialog
Offline
Last seen:7小时11分钟前
工作人员
加入:2018-02-08 11:03
Hi There,

Hi There,

Can you please share your implementation?

Thanks, PM_Dialog