Author Topic: Prefered method for button gesture detection?  (Read 833 times)

0 Members and 1 Guest are viewing this topic.

Offline jnzTopic starter

  • Frequent Contributor
  • **
  • Posts: 593
Prefered method for button gesture detection?
« on: September 27, 2016, 05:54:23 pm »
I have a few momentary switches and want to detect the states the user could press: single click / short press, double click, long press, hold, and maybe a wierd one like tic-toc (short press followed by a long press).

I'm currently in an RTOS where if I really wanted to I could block this thread, it currently runs at 100ms intervals, but I may need to bump that up to 10-50ms.

Had two thoughts, one I could store an array of the states over the time interval I have like [OFF][ON][OFF][ON][OFF][OFF][OFF][OFF][OFF][ON][ON].  And also thought that I could split this up into something like switch3.pressed=1 switch3.released=1 switch3.idledOut=0.   I could also ignore that I'm in a fixed interval and just record the system time and try and evaluate if I'm in a first press or not.

Figure there is a good solution for this that you guys might like. Thoughts?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf