IR remoute control multiple click button
UserButton.h@2:7a268df54696, 2021-05-07 (annotated)
- Committer:
- docent
- Date:
- Fri May 07 15:38:48 2021 +0000
- Revision:
- 2:7a268df54696
- Parent:
- 0:94d6bf511846
corrections
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
docent | 2:7a268df54696 | 1 | //InterruptIn mybutton(USER_BUTTON);//mybutton(PC_14);// |
docent | 0:94d6bf511846 | 2 | |
docent | 0:94d6bf511846 | 3 | Timeout FrameTimeout; |
docent | 0:94d6bf511846 | 4 | Timeout BounceTimeout; |
docent | 0:94d6bf511846 | 5 | |
docent | 0:94d6bf511846 | 6 | uint8_t Debounce=0; |
docent | 2:7a268df54696 | 7 | uint8_t cnt=0; |
docent | 2:7a268df54696 | 8 | uint8_t NewButtonMode=0; |
docent | 0:94d6bf511846 | 9 | |
docent | 0:94d6bf511846 | 10 | //------------------ |
docent | 0:94d6bf511846 | 11 | void FrameTimeout_isr() |
docent | 0:94d6bf511846 | 12 | { |
docent | 2:7a268df54696 | 13 | NewButtonMode=cnt; |
docent | 0:94d6bf511846 | 14 | cnt=0; |
docent | 0:94d6bf511846 | 15 | } |
docent | 0:94d6bf511846 | 16 | |
docent | 0:94d6bf511846 | 17 | //--------------------- |
docent | 0:94d6bf511846 | 18 | void BounceTimeout_isr() |
docent | 0:94d6bf511846 | 19 | { |
docent | 0:94d6bf511846 | 20 | Debounce=0; |
docent | 0:94d6bf511846 | 21 | |
docent | 0:94d6bf511846 | 22 | } |
docent | 0:94d6bf511846 | 23 | |
docent | 0:94d6bf511846 | 24 | //------------ |
docent | 0:94d6bf511846 | 25 | void pressed() |
docent | 0:94d6bf511846 | 26 | { |
docent | 0:94d6bf511846 | 27 | if(Debounce==0){ |
docent | 0:94d6bf511846 | 28 | Debounce=1; |
docent | 0:94d6bf511846 | 29 | cnt++; |
docent | 2:7a268df54696 | 30 | //*pind_cnt=cnt; |
docent | 0:94d6bf511846 | 31 | FrameTimeout.detach(); |
docent | 0:94d6bf511846 | 32 | FrameTimeout.attach(FrameTimeout_isr,1.0); |
docent | 0:94d6bf511846 | 33 | BounceTimeout.attach(BounceTimeout_isr,0.2); |
docent | 0:94d6bf511846 | 34 | } |
docent | 0:94d6bf511846 | 35 | } |
docent | 0:94d6bf511846 | 36 | |
docent | 0:94d6bf511846 | 37 | //----------------------------------- |
docent | 2:7a268df54696 | 38 | void ButtonIni(InterruptIn *button) |
docent | 0:94d6bf511846 | 39 | { |
docent | 2:7a268df54696 | 40 | Debounce=0; |
docent | 2:7a268df54696 | 41 | cnt=0; |
docent | 2:7a268df54696 | 42 | NewButtonMode=0; |
docent | 2:7a268df54696 | 43 | button->fall(&pressed); |
docent | 0:94d6bf511846 | 44 | } |
docent | 0:94d6bf511846 | 45 | |
docent | 2:7a268df54696 | 46 | //---------------------------- |
docent | 2:7a268df54696 | 47 | void WhatButtonMode(uint8_t *Pmode) |
docent | 2:7a268df54696 | 48 | { |
docent | 2:7a268df54696 | 49 | if(NewButtonMode){ |
docent | 2:7a268df54696 | 50 | *Pmode=NewButtonMode; |
docent | 2:7a268df54696 | 51 | NewButtonMode=0; |
docent | 2:7a268df54696 | 52 | } |
docent | 2:7a268df54696 | 53 | } |
docent | 0:94d6bf511846 | 54 |