How to configure iot_button_get_repeat() to only return total presses
Posted: Fri Sep 17, 2021 1:46 am
Hi,
I am using the button_iot library and having an issue where the iot_button_get_repeat() function is working fine but it called the callback after every press, so if i press four times i get callbacks after 2, 3 and 4. I would prefer for it to only return the total number of presses? Is that possible? I want to select a file based on the number of presses.
Code below:
static void button_audio_play_repeat_cb(void *arg)
{
audio_btn_pressed_times = iot_button_get_repeat(g_btns[4]);
ESP_LOGI(TAG, "Audio Play Button pressed: %d times", audio_btn_pressed_times);
if (strcmp(localfiles[audio_btn_pressed_times], "") != 0) {audio_play(localfiles[audio_btn_pressed_times]);}
}
Any suggestions are welcome.
Best
Mark
I am using the button_iot library and having an issue where the iot_button_get_repeat() function is working fine but it called the callback after every press, so if i press four times i get callbacks after 2, 3 and 4. I would prefer for it to only return the total number of presses? Is that possible? I want to select a file based on the number of presses.
Code below:
static void button_audio_play_repeat_cb(void *arg)
{
audio_btn_pressed_times = iot_button_get_repeat(g_btns[4]);
ESP_LOGI(TAG, "Audio Play Button pressed: %d times", audio_btn_pressed_times);
if (strcmp(localfiles[audio_btn_pressed_times], "") != 0) {audio_play(localfiles[audio_btn_pressed_times]);}
}
Any suggestions are welcome.
Best
Mark