by lcheminade Mon May 11, 2015 3:49 pm
Hi,
The td_tool_switch API allow you to trigger some flags on specific buttons events.
When the button is first push a SHORT_PUSHED event is issued. Then if you keep pushing the button you will get the LONG_PUSHED, VERY_LONG_PUSHED and eventually EXTRA_LONG_PUSHED events. Timing for those events can be configured using the TD_TOOLS_SWITCH_Init or TD_TOOLS_SWITCH_SetPushTime functions.
Then when you release the button the release event corresponding to your last push event is issued (ie SHORT_PUSHED -> SHORT_RELEASED ; LONG_PUSHED -> LONG_RELEASED, etc...).
For example, assuming switch_id was initialized using TD_TOOLS_SWITCH_Init:
#define LONG_PUSH_TIME 3 //seconds
TD_TOOLS_SWITCH_Init(gpioPortB, 11, gpioModeInputPull, true, true,LONG_PUSH_TIME, -1 , -1);
If you push the button at t= 0 and release it at t = 2s you will get:
SHORT_PUSHED (t = 0)
SHORT_RELEASED (t = 2)
If you push the button at t= 0 and release it at t = 5s you will get:
SHORT_PUSHED (t = 0)
LONG_PUSHED (t = 3)
LONG_RELEASED (t = 5)
Note that if you push and release the button quickly you will generate double, triple and multiple click events instead of usual events.
Regards.