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.
rotary_inc_sp.hpp
00001 #ifndef ROTARY_INC_H 00002 #define ROTARY_INC_H 00003 #include "mbed.h" 00004 #include "portSet.hpp" 00005 #ifndef M_PI 00006 #define M_PI 3.14159265358979 00007 #endif 00008 00009 /*ロータリーエンコーダーを使う。 00010 *速度計測は、タイヤの円周とロリコンの分解能を指定した場合に有効になる。 00011 *RotaryInc(PinName pinA, PinName pinB,double circumference,int Resolution,int mode = 0);//速度計測有効 00012 *RotaryInc(PinName pinA, PinName pinB,int mode = 0);//速度計測無効 00013 */ 00014 //RotaryInc rotary(PA_1,PA_3,2 * 50.8 * M_PI,200); 00015 00016 class RotaryInc{ 00017 public: 00018 RotaryInc(PinName user_a, PinName user_b,double circumference,int resolution,int mode = 0);//速度計測有効 00019 RotaryInc(PinName user_a, PinName user_b,int mode = 0);//速度計測無効 00020 RotaryInc(Port port,double circumference,int resolution,int mode = 0); 00021 RotaryInc(); 00022 ~RotaryInc(); 00023 long long get(); 00024 double getSpeed(); 00025 void reset(); 00026 int diff(); 00027 void specinit(PinName user_a, PinName user_b,double circumference,int resolution,int mode); 00028 private: 00029 InterruptIn *pin_a_,*pin_b_; 00030 Timer timer_; 00031 long long pulse_; 00032 long long last_[20]; 00033 long long prev_; 00034 int count_; 00035 int mode_; 00036 int resolution_; 00037 double now_; 00038 double sum_; 00039 double pre_t_[20]; 00040 double speed_; 00041 double circumference_; 00042 bool measur_; 00043 bool start_frag_; 00044 bool flag_; 00045 void init(PinName,PinName); 00046 void riseA(void); 00047 void riseB(void); 00048 void fallA(void); 00049 void fallB(void); 00050 void calcu(void); 00051 void zero(void); 00052 }; 00053 00054 #endif /* ROTARY_INC_H */
Generated on Sat Oct 15 2022 07:52:33 by
1.7.2