Basic Encoder Library for Sparkfun's Hall- Effect Encoder Kit Part# ROB-12629
Dependents: ESP8266_pid_redbot_webserver 4180_lab4_project dotbot ShadowDistance ... more
HALLFX_ENCODER.cpp
00001 #include "HALLFX_ENCODER.h" 00002 00003 HALLFX_ENCODER::HALLFX_ENCODER(PinName enc_in): _enc_in(enc_in){ 00004 _enc_in.mode(PullUp); 00005 // Invoke interrupt on both falling and rising edges 00006 _enc_in.fall(this, &HALLFX_ENCODER::callback); 00007 _enc_in.rise(this, &HALLFX_ENCODER::callback); 00008 } 00009 00010 long HALLFX_ENCODER::read(){ 00011 return count; 00012 } 00013 00014 void HALLFX_ENCODER::reset(){ 00015 count = 0; 00016 } 00017 00018 void HALLFX_ENCODER::callback(){ 00019 count++; 00020 }
Generated on Fri Jul 15 2022 23:54:49 by
1.7.2