basic Quadrature Encoder Library
Dependents: ESP8266_pid_mtrPos_webserver_SDcard_v2 ESP8266_pid_mtrSpeed_Webserver_SDcard ESP8266_pid_spd_and_pos_webserver_SDcard pid_encoder_speed_demo ... more
QEI.cpp
- Committer:
- electromotivated
- Date:
- 2015-11-23
- Revision:
- 0:50aae578cb89
File content as of revision 0:50aae578cb89:
#include "QEI.h" QEI::QEI(PinName encA, PinName encB): _encA(encA), _encB(encB){ _encA.mode(PullUp); _encA.rise(this, &QEI::callback); _encB.mode(PullUp); } long QEI::read(){ return count; } void QEI::reset(){ count = 0; } void QEI::callback(){ if(_encB) count--; // CCW count else count++; // CW count }