latest version 9/26

Dependencies:   mbed

Committer:
Yamanobe
Date:
Sun Oct 10 04:47:14 2021 +0000
Revision:
0:0d02a451e79d
slave program (at 9/26)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Yamanobe 0:0d02a451e79d 1 #include "EC12E2420801.h"
Yamanobe 0:0d02a451e79d 2
Yamanobe 0:0d02a451e79d 3 Encoder::Encoder(PinName Apulse,PinName Bpulse) : Apulse(Apulse),Bpulse(Bpulse) {
Yamanobe 0:0d02a451e79d 4 Encoder::Apulse.fall(this,&Encoder::Apulse_Down);
Yamanobe 0:0d02a451e79d 5 }
Yamanobe 0:0d02a451e79d 6
Yamanobe 0:0d02a451e79d 7 void Encoder::Apulse_Down() {
Yamanobe 0:0d02a451e79d 8 if(Bpulse) {
Yamanobe 0:0d02a451e79d 9 count--;
Yamanobe 0:0d02a451e79d 10 } else {
Yamanobe 0:0d02a451e79d 11 count++;
Yamanobe 0:0d02a451e79d 12 }
Yamanobe 0:0d02a451e79d 13 }
Yamanobe 0:0d02a451e79d 14
Yamanobe 0:0d02a451e79d 15 bool Encoder::reset(int preset) {
Yamanobe 0:0d02a451e79d 16 count = 0;
Yamanobe 0:0d02a451e79d 17 return true;
Yamanobe 0:0d02a451e79d 18 }
Yamanobe 0:0d02a451e79d 19
Yamanobe 0:0d02a451e79d 20 /****値返す用の関数****/
Yamanobe 0:0d02a451e79d 21 float Encoder::getData(short ch) {
Yamanobe 0:0d02a451e79d 22 switch(ch) {
Yamanobe 0:0d02a451e79d 23 case COUNT:
Yamanobe 0:0d02a451e79d 24 return count; //カウント
Yamanobe 0:0d02a451e79d 25 default:
Yamanobe 0:0d02a451e79d 26 return 0;
Yamanobe 0:0d02a451e79d 27 }
Yamanobe 0:0d02a451e79d 28 }