![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
my new gear...
sensor/rotary_inc_sp.hpp
- Committer:
- yootee
- Date:
- 22 months ago
- Revision:
- 22:394337a4205a
- Parent:
- 2:e7b09385d197
File content as of revision 22:394337a4205a:
#ifndef ROTARY_INC_H #define ROTARY_INC_H #include "mbed.h" #include "portSet.hpp" #ifndef M_PI #define M_PI 3.14159265358979 #endif /*ロータリーエンコーダーを使う。 *速度計測は、タイヤの円周とロリコンの分解能を指定した場合に有効になる。 *RotaryInc(PinName pinA, PinName pinB,double circumference,int Resolution,int mode = 0);//速度計測有効 *RotaryInc(PinName pinA, PinName pinB,int mode = 0);//速度計測無効 */ //RotaryInc rotary(PA_1,PA_3,2 * 50.8 * M_PI,200); class RotaryInc{ public: RotaryInc(PinName user_a, PinName user_b,double circumference,int resolution,int mode = 0);//速度計測有効 RotaryInc(PinName user_a, PinName user_b,int mode = 0);//速度計測無効 RotaryInc(Port port,double circumference,int resolution,int mode = 0); RotaryInc(); ~RotaryInc(); long long get(); double getSpeed(); void reset(); int diff(); void specinit(PinName user_a, PinName user_b,double circumference,int resolution,int mode); private: InterruptIn *pin_a_,*pin_b_; Timer timer_; long long pulse_; long long last_[20]; long long prev_; int count_; int mode_; int resolution_; double now_; double sum_; double pre_t_[20]; double speed_; double circumference_; bool measur_; bool start_frag_; bool flag_; void init(PinName,PinName); void riseA(void); void riseB(void); void fallA(void); void fallB(void); void calcu(void); void zero(void); }; #endif /* ROTARY_INC_H */