For Rotaryencoder and Motor
Diff: Rotaryencoder.hpp
- Revision:
- 0:b1487fd792c9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Rotaryencoder.hpp Sat Jul 16 06:38:44 2022 +0000 @@ -0,0 +1,30 @@ +#ifndef Rorikon_H +#define Rorikon_H +#include "mbed.h" +#define pi 3.1415926535897932384626 + +class Rotary{ +public: + Rotary(PinName pinA, PinName pinB, double diameter, double resolusion, double deltat); + double pulse_get(); + double theta_get(); + double speed_get(); + double angularspd_get(); + void reset(); + ~Rotary(); +private: + InterruptIn *pin_A; + InterruptIn *pin_B; + double pulse[2]; + double theta[2]; + double cir; + double res; + double dt; + double spd; + double anguspd; + void riseA(void); + void fallA(void); + void riseB(void); + void fallB(void); +}; +#endif \ No newline at end of file