![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
sampleProgram
Dependencies: QEI accelerator bit_test cyclic_io cyclic_var cylinder event_var limit mbed mecanum motor_drive pid pid_encoder rs422_put sbdbt servo
Fork of 17robo_fuzi by
Diff: varEvent.h
- Revision:
- 50:e4e1f38d1bd5
- Child:
- 51:70d45b959d6b
diff -r b041c815c063 -r e4e1f38d1bd5 varEvent.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/varEvent.h Wed Sep 13 02:17:38 2017 +0000 @@ -0,0 +1,29 @@ +class varEvent { + +public: + void input(int inputState) { + valState = ((valState<<1)|inputState)&3; + if(valState == 1) { + riseState = 1; + fallState = 0; + } else if(valState == 2){ + riseState = 0; + fallState = 1; + } else { + riseState = 0; + fallState = 0; + } + } + + int getRiseState(){ + return riseState; + } + + int getFallState(){ + return fallState; + } + +private: + int inputState, valState; + int riseState, fallState; +}; \ No newline at end of file