Author Topic: Multifunction button and low power sleep  (Read 1173 times)

gregcope

  • Full Member
  • ***
  • Posts: 172
  • Country: gb
Multifunction button and low power sleep
« on: May 05, 2015, 05:45:45 PM »
Hi all

Any advice on using interupts to wake from sleep AND multifunction buttons?

Examples I have found seem to count time and debounce, returning the sort of button press.  However I have not seen any examples used in conjunction with low power sleep libs.

I want a button that wakes from sleep and depending on how it is pressed, runs functions that reconfigure the runtime.

Eg
Short press - ACK
Long press - flip mode
Really long press - enter setup mode

Thought / ideas welcome

TomWS

  • Hero Member
  • *****
  • Posts: 1891
Re: Multifunction button and low power sleep
« Reply #1 on: May 05, 2015, 06:48:52 PM »
Hi all

Any advice on using interupts to wake from sleep AND multifunction buttons?

Examples I have found seem to count time and debounce, returning the sort of button press.  However I have not seen any examples used in conjunction with low power sleep libs.

I want a button that wakes from sleep and depending on how it is pressed, runs functions that reconfigure the runtime.

Eg
Short press - ACK
Long press - flip mode
Really long press - enter setup mode

Thought / ideas welcome
Waking from a pinChangeInt(errupt) is easy, debounce logic can occur after you wakeup (disable the pinChange interrupt as soon as you get the first one, that way you won't get extra interrupts as the switch bounces).

Test with a really noisy switch (like those really cheesy ones that feel like there's sand inside when you press it)!  Tough to discriminate a short press with these, but, if they occur between large intervals then it's relatively easy. (ie, 'any' press is a short press if it doesn't meet the long press requirements)

Tom (just flipping out ideas)




gregcope

  • Full Member
  • ***
  • Posts: 172
  • Country: gb
Re: Multifunction button and low power sleep
« Reply #2 on: May 06, 2015, 12:29:20 AM »
Thanks Tom.

Will need to search for a cheesy switch :-)