Gemphet8 ; 8-polyphonic synthesizer control application
Dependencies: MIDI REnc button mbed
btn2/btn2.cpp@11:e6a47dc75120, 2014-11-27 (annotated)
- Committer:
- ChuckTimber
- Date:
- Thu Nov 27 06:47:43 2014 +0000
- Revision:
- 11:e6a47dc75120
Gem8 application 1st launched.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ChuckTimber | 11:e6a47dc75120 | 1 | /** |
ChuckTimber | 11:e6a47dc75120 | 2 | * @file btn2.cpp |
ChuckTimber | 11:e6a47dc75120 | 3 | * Project button long press handling sample |
ChuckTimber | 11:e6a47dc75120 | 4 | * @brief button long press handling class |
ChuckTimber | 11:e6a47dc75120 | 5 | * @version 1.00 |
ChuckTimber | 11:e6a47dc75120 | 6 | * @author Chuck Timber |
ChuckTimber | 11:e6a47dc75120 | 7 | * @date 09/08/2014 |
ChuckTimber | 11:e6a47dc75120 | 8 | */ |
ChuckTimber | 11:e6a47dc75120 | 9 | |
ChuckTimber | 11:e6a47dc75120 | 10 | #include "btn2.h" |
ChuckTimber | 11:e6a47dc75120 | 11 | |
ChuckTimber | 11:e6a47dc75120 | 12 | BTN2::BTN2(PinName pin) : _btn(pin) |
ChuckTimber | 11:e6a47dc75120 | 13 | { |
ChuckTimber | 11:e6a47dc75120 | 14 | _tick.attach(this, &BTN2::check_btn_pressed, 0.08); |
ChuckTimber | 11:e6a47dc75120 | 15 | } |
ChuckTimber | 11:e6a47dc75120 | 16 | |
ChuckTimber | 11:e6a47dc75120 | 17 | void BTN2::check_btn_pressed(void) |
ChuckTimber | 11:e6a47dc75120 | 18 | { |
ChuckTimber | 11:e6a47dc75120 | 19 | static int bcnt; |
ChuckTimber | 11:e6a47dc75120 | 20 | |
ChuckTimber | 11:e6a47dc75120 | 21 | if(_btn.CMD & _btn.STAT) { |
ChuckTimber | 11:e6a47dc75120 | 22 | if (++bcnt > 15) |
ChuckTimber | 11:e6a47dc75120 | 23 | CMD2 = 2; |
ChuckTimber | 11:e6a47dc75120 | 24 | } else if (_btn.CMD & !_btn.STAT) { |
ChuckTimber | 11:e6a47dc75120 | 25 | if ((bcnt > 0)&&(bcnt<=15)) |
ChuckTimber | 11:e6a47dc75120 | 26 | CMD2 = 1; |
ChuckTimber | 11:e6a47dc75120 | 27 | _btn.CMD = 0; |
ChuckTimber | 11:e6a47dc75120 | 28 | bcnt = 0; |
ChuckTimber | 11:e6a47dc75120 | 29 | } else if (!_btn.CMD) { |
ChuckTimber | 11:e6a47dc75120 | 30 | CMD2 = 0; |
ChuckTimber | 11:e6a47dc75120 | 31 | } |
ChuckTimber | 11:e6a47dc75120 | 32 | } |