Kazushi Yamanobe
/
R-ciliatable_4
latest version 9/26
Diff: EC12E2420801.cpp
- Revision:
- 0:0d02a451e79d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EC12E2420801.cpp Sun Oct 10 04:47:14 2021 +0000 @@ -0,0 +1,28 @@ +#include "EC12E2420801.h" + +Encoder::Encoder(PinName Apulse,PinName Bpulse) : Apulse(Apulse),Bpulse(Bpulse) { + Encoder::Apulse.fall(this,&Encoder::Apulse_Down); +} + +void Encoder::Apulse_Down() { + if(Bpulse) { + count--; + } else { + count++; + } +} + +bool Encoder::reset(int preset) { + count = 0; + return true; +} + +/****値返す用の関数****/ +float Encoder::getData(short ch) { + switch(ch) { + case COUNT: + return count; //カウント + default: + return 0; + } +} \ No newline at end of file