Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
encoder.h
00001 #ifndef ENCODER_H 00002 #define ENCODER_H 00003 #include "mbed.h" 00004 class Encoder { 00005 public: 00006 volatile int pulses; 00007 Encoder(PinName channelA, PinName channelB); 00008 00009 //Reset the encoder 00010 void reset(void); 00011 00012 //Gets pulses by directly querying the encoder. 00013 operator int() { 00014 return pulses; 00015 } 00016 00017 00018 // Reset both encoders 00019 void resetEncoders(); 00020 00021 // Returns the average number of pulses across both encoders since last reset. Unit is encoder pulses; intended for straight driving only. 00022 int getEncoderDistance(bool left); 00023 00024 private: 00025 InterruptIn channelA_; 00026 InterruptIn channelB_; 00027 int prevState_; 00028 int currState_; 00029 00030 void encode(void); 00031 }; 00032 00033 00034 00035 extern Encoder leftEncoder; 00036 extern Encoder rightEncoder; 00037 00038 00039 #endif
Generated on Thu Jul 14 2022 05:30:38 by
