Gemphet8 ; 8-polyphonic synthesizer control application
Dependencies: MIDI REnc button mbed
btn2/btn2.cpp@12:dc6208de53cc, 2014-12-13 (annotated)
- Committer:
- ChuckTimber
- Date:
- Sat Dec 13 10:51:48 2014 +0000
- Revision:
- 12:dc6208de53cc
- Parent:
- 11:e6a47dc75120
Gemphet8 2014/11/29 version.
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 | } |