Bayley Wang
/
foc-ed_in_the_bot_compact
robot
PwmIn/PwmIn.h
- Committer:
- bwang
- Date:
- 2017-04-06
- Revision:
- 92:a9dac72d8cac
- Parent:
- 78:b8df106126a7
- Child:
- 151:5bbb15351798
File content as of revision 92:a9dac72d8cac:
#ifndef __PWMIN_H #define __PWMIN_H #include "mbed.h" class PwmIn { public: PwmIn(PinName pin, int usec_min, int usec_max, int usec_crazy_low, int usec_crazy_hi); bool get_enabled(); float get_throttle(); public: void block() {blocked = true;} int state() {return dig_in->read();} int get_usecs() {return usecs;} private: void handle_rise(); void handle_fall(); private: InterruptIn* int_in; DigitalIn* dig_in; Timer timer; int usec_min, usec_max, usec_crazy_low, usec_crazy_hi; private: bool enabled; bool blocked; bool risen; int usecs; }; #endif