my new gear...

Dependencies:   mbed

Committer:
yootee
Date:
Sat Oct 15 07:52:25 2022 +0000
Revision:
22:394337a4205a
Parent:
2:e7b09385d197
upgrade

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yootee 0:1456b6f84c75 1 #ifndef ROTARY_INC_H
yootee 0:1456b6f84c75 2 #define ROTARY_INC_H
yootee 0:1456b6f84c75 3 #include "mbed.h"
yootee 22:394337a4205a 4 #include "portSet.hpp"
yootee 0:1456b6f84c75 5 #ifndef M_PI
yootee 0:1456b6f84c75 6 #define M_PI 3.14159265358979
yootee 0:1456b6f84c75 7 #endif
yootee 0:1456b6f84c75 8
yootee 0:1456b6f84c75 9 /*ロータリーエンコーダーを使う。
yootee 0:1456b6f84c75 10 *速度計測は、タイヤの円周とロリコンの分解能を指定した場合に有効になる。
yootee 0:1456b6f84c75 11 *RotaryInc(PinName pinA, PinName pinB,double circumference,int Resolution,int mode = 0);//速度計測有効
yootee 0:1456b6f84c75 12 *RotaryInc(PinName pinA, PinName pinB,int mode = 0);//速度計測無効
yootee 0:1456b6f84c75 13 */
yootee 0:1456b6f84c75 14 //RotaryInc rotary(PA_1,PA_3,2 * 50.8 * M_PI,200);
yootee 0:1456b6f84c75 15
yootee 0:1456b6f84c75 16 class RotaryInc{
yootee 0:1456b6f84c75 17 public:
yootee 0:1456b6f84c75 18 RotaryInc(PinName user_a, PinName user_b,double circumference,int resolution,int mode = 0);//速度計測有効
yootee 0:1456b6f84c75 19 RotaryInc(PinName user_a, PinName user_b,int mode = 0);//速度計測無効
yootee 22:394337a4205a 20 RotaryInc(Port port,double circumference,int resolution,int mode = 0);
yootee 0:1456b6f84c75 21 RotaryInc();
yootee 0:1456b6f84c75 22 ~RotaryInc();
yootee 0:1456b6f84c75 23 long long get();
yootee 0:1456b6f84c75 24 double getSpeed();
yootee 0:1456b6f84c75 25 void reset();
yootee 0:1456b6f84c75 26 int diff();
yootee 0:1456b6f84c75 27 void specinit(PinName user_a, PinName user_b,double circumference,int resolution,int mode);
yootee 0:1456b6f84c75 28 private:
yootee 0:1456b6f84c75 29 InterruptIn *pin_a_,*pin_b_;
yootee 0:1456b6f84c75 30 Timer timer_;
yootee 0:1456b6f84c75 31 long long pulse_;
yootee 0:1456b6f84c75 32 long long last_[20];
yootee 0:1456b6f84c75 33 long long prev_;
yootee 0:1456b6f84c75 34 int count_;
yootee 0:1456b6f84c75 35 int mode_;
yootee 0:1456b6f84c75 36 int resolution_;
yootee 0:1456b6f84c75 37 double now_;
yootee 0:1456b6f84c75 38 double sum_;
yootee 0:1456b6f84c75 39 double pre_t_[20];
yootee 0:1456b6f84c75 40 double speed_;
yootee 0:1456b6f84c75 41 double circumference_;
yootee 0:1456b6f84c75 42 bool measur_;
yootee 0:1456b6f84c75 43 bool start_frag_;
yootee 0:1456b6f84c75 44 bool flag_;
yootee 0:1456b6f84c75 45 void init(PinName,PinName);
yootee 0:1456b6f84c75 46 void riseA(void);
yootee 0:1456b6f84c75 47 void riseB(void);
yootee 0:1456b6f84c75 48 void fallA(void);
yootee 0:1456b6f84c75 49 void fallB(void);
yootee 0:1456b6f84c75 50 void calcu(void);
yootee 0:1456b6f84c75 51 void zero(void);
yootee 0:1456b6f84c75 52 };
yootee 0:1456b6f84c75 53
yootee 0:1456b6f84c75 54 #endif /* ROTARY_INC_H */