RTC sleep and interrupt callback clarification

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: RTC sleep and interrupt callback clarification

Post by pythoncoder » Fri Sep 11, 2015 9:27 am

Fair point.
Peter Hinch
Index to my micropython libraries.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: RTC sleep and interrupt callback clarification

Post by dhylands » Sat Sep 19, 2015 3:04 am

Here's another good article I found on switch bounce including some simple external circuitry you can use to tame it:
http://www.allaboutcircuits.com/technic ... l-with-it/

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: RTC sleep and interrupt callback clarification

Post by pythoncoder » Sat Sep 19, 2015 6:25 am

It's trivial in code if you're running a cooperative scheduler. If the pin state differs from the debounced output state, wait for a period and check again. If they still differ, change the debounced output state and optionally execute a callback. The key point being that during the wait, the processor gets on with other tasks. (I appreciate this is familiar territory to you, Dave ;) )
e.g. https://github.com/peterhinch/Micropyth ... /switch.py
Peter Hinch
Index to my micropython libraries.

Post Reply