Page 1 of 1
Difference between Short Pushed and Long Pushed for button
Posted: Mon May 11, 2015 3:29 pm
by sj-agora
Hi Td Next Team,
I'm working on the TD1208 with some buttons and i want to know the real difference between :
1 - SHORT_PUSHED
2 - LONG_PUSHED
and between
3- SHORT_RELEASED
4 - LONG_RELEASED
Thanks

Re: Difference between Short Pushed and Long Pushed for butt
Posted: Mon May 11, 2015 3:49 pm
by lcheminade
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.
Re: Difference between Short Pushed and Long Pushed for butt
Posted: Mon May 11, 2015 5:01 pm
by sj-agora
Hi Loïc,
Thanks for your answer !
So the event of short, long etc... depends of the duration time of the push or the relase ?
But if i generate multiple events with multiple quick push, what happends ? can i put a sort of "delay" between 2 button interrupt ?
Re: Difference between Short Pushed and Long Pushed for butt
Posted: Tue May 12, 2015 7:31 am
by lcheminade
Hi,
Yes the short, long, etc events depend on how long you push the button and when you release it.
As I said if you do multiple quick push (<350ms between pushes) you will get the double/triple/multiple clic events instead of usual event push/release events.
Please keep in mind that all these events are NOT generated in interrupt and already include a 40ms deboucing. The only thing you need to do is make sure the TD_TOOLS_SWITCH_Process function is called in UserLoop in order to deal witch each events as soon as they occur.
Of course if you have a huge delay or a Sigfox transmission inside your UserLoop and the button is pushed you could miss some push events as they are computed using a timer (you will only get your latest event). But you will not miss the release event since it's computed on TD_TOOLS_SWITCH_Process call.
Best is to try with a tfp_printf for each event and you will quickly understand how this behaves!
Regards.
Re: Difference between Short Pushed and Long Pushed for butt
Posted: Thu Jun 11, 2015 8:00 am
by Capture
Thank you for the explanantion about the push buttons i want to set the short push period for 3s and long push period for 5 s in order to do like that ,how do i have to set the parameters for short push period because in the library function i did not see any information concerning the short push interval settings
#define LONG_PUSH_TIME 5 //seconds
// Push button initialization
SwitchId = TD_TOOLS_SWITCH_Init(BUTTON_PORT,BUTTON_BIT, gpioModeInputPull, true, true,
LONG_PUSH_TIME,-1,-1);