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.
Encoder.h
- Committer:
- ryosukenanoda
- Date:
- 2020-12-30
- Revision:
- 0:82c1b12a0041
- Child:
- 1:c44f4aa7a45d
File content as of revision 0:82c1b12a0041:
#include "mbed.h"
#define PI 3.14159265359
#define RESOLUTION_COUNT 16.0
#define GEAR_RAITO 43.7
class Encoder {
public:
Encoder(PinName pin_A, PinName pin_B);
float get_raito();
private:
Timer timer;
int last_time;
int max_time;
float dt_to_raito;
float raito;
void did_rise();
void update_raito(int dt); //dt microsec
float direction();
protected:
InterruptIn _pin_A;
DigitalIn _pin_B;
};