my new gear...

Dependencies:   mbed

Committer:
yootee
Date:
Fri Feb 25 05:20:11 2022 +0000
Revision:
0:1456b6f84c75
my_custom

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