Debounce_Library
antirrebote.cpp
- Committer:
- Tom_87
- Date:
- 2018-05-03
- Revision:
- 0:16d62113f1d5
- Child:
- 1:8db2c2a203d9
- Child:
- 2:d1e2599de47c
File content as of revision 0:16d62113f1d5:
#include "antirrebote.h" enum{PULS_NA, PULS_FLC1, PULS_A, PULS_FLC2}; AntReb::~AntReb(){ } AntReb::AntReb(){ e_PULS = PULS_NA; } void AntReb::setPin(DigitalIn pin) { P_PULS =pin.read(); } pinEstado_t AntReb::antiRebote(){ pinEstado_t StateOut; switch(e_PULS){ default: case PULS_NA: StateOut = APAGADO; if(P_PULS == 0) { e_PULS = PULS_FLC1; } break; case PULS_FLC1: StateOut = APAGADO; if(P_PULS == 0) { e_PULS = PULS_A; StateOut= ENCENDIDO; }else if(P_PULS == 1) { e_PULS = PULS_NA; } break; case PULS_A: StateOut =APAGADO; if(P_PULS == 1) { e_PULS = PULS_FLC2; } break; case PULS_FLC2: StateOut = APAGADO; if(P_PULS == 0) { e_PULS = PULS_A; }else if(P_PULS == 1) { e_PULS = PULS_NA; } break; } return StateOut; }