Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-src by
Diff: common/InterruptIn.cpp
- Revision:
- 636:21ce76d41a4f
- Parent:
- 212:34d62c0b2af6
--- a/common/InterruptIn.cpp Wed Sep 30 17:00:09 2015 +0100 +++ b/common/InterruptIn.cpp Sun Feb 21 07:27:08 2016 +0000 @@ -17,6 +17,9 @@ #if DEVICE_INTERRUPTIN +static int button_buf[5] = {0}; +static int inc = 0; + namespace mbed { InterruptIn::InterruptIn(PinName pin) : gpio(), @@ -76,7 +79,18 @@ #ifdef MBED_OPERATORS InterruptIn::operator int() { - return read(); + + button_buf[inc++] = read(); + if (inc == 5) inc = 0; + if (button_buf[0] == button_buf[1] && + button_buf[1] == button_buf[2] && + button_buf[2] == button_buf[3] && + button_buf[3] == button_buf[4]){ + + return button_buf[0]; + } else { + return 1; + } } #endif