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:
- 2021-03-07
- Revision:
- 3:cf7ae37c6930
- Parent:
- 1:c44f4aa7a45d
File content as of revision 3:cf7ae37c6930:
#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();
float get_rotation();
private:
Timer timer;
Timeout stop_checker;
int last_time;
int max_time;
float to_raito; //TODO: rename
float raito;
int total_count;
void did_rise();
void update_raito(int dt); //dt microsec
float direction();
void check_stop();
protected:
InterruptIn _pin_A;
DigitalIn _pin_B;
};