インクリメント方式エンコーダ用ライブラリ
Dependents: RobotControl_Sample2022 sotsuken_mecha
初期化 IncEncoder name(pinA,pinB,分解能); 分解能 : x2_resolution x4_resolution
リセット name.reset();
Diff: IncEncoder.h
- Revision:
- 0:c40c29a063c0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IncEncoder.h Fri Jul 01 06:56:51 2022 +0000 @@ -0,0 +1,34 @@ +#ifndef MBED_INCENCODER_H +#define MBED_INCENCODER_H + +#include "mbed.h" + +class IncEncoder{ +public: + typedef enum Encoding { + x2_Resolution, + x4_Resolution + } Encoding; + + IncEncoder(PinName ENC_A,PinName ENC_B,Encoding encoding); + + int IncEncoder::GetIncPulses(); + + void IncEncoder::reset(); + + void IncEncoder::A_RISE(); + + void IncEncoder::A_FALL(); + + void IncEncoder::B_RISE(); + + void IncEncoder::B_FALL(); + +private: + int pulses; + + InterruptIn ENC_A_; + InterruptIn ENC_B_; +}; + +#endif \ No newline at end of file