IR remoute control multiple click button
UserButton.h
- Committer:
- docent
- Date:
- 2021-05-07
- Revision:
- 2:7a268df54696
- Parent:
- 0:94d6bf511846
File content as of revision 2:7a268df54696:
//InterruptIn mybutton(USER_BUTTON);//mybutton(PC_14);// Timeout FrameTimeout; Timeout BounceTimeout; uint8_t Debounce=0; uint8_t cnt=0; uint8_t NewButtonMode=0; //------------------ void FrameTimeout_isr() { NewButtonMode=cnt; cnt=0; } //--------------------- void BounceTimeout_isr() { Debounce=0; } //------------ void pressed() { if(Debounce==0){ Debounce=1; cnt++; //*pind_cnt=cnt; FrameTimeout.detach(); FrameTimeout.attach(FrameTimeout_isr,1.0); BounceTimeout.attach(BounceTimeout_isr,0.2); } } //----------------------------------- void ButtonIni(InterruptIn *button) { Debounce=0; cnt=0; NewButtonMode=0; button->fall(&pressed); } //---------------------------- void WhatButtonMode(uint8_t *Pmode) { if(NewButtonMode){ *Pmode=NewButtonMode; NewButtonMode=0; } }