latest version 9/26

Dependencies:   mbed

EC12E2420801.cpp

Committer:
Yamanobe
Date:
2021-10-10
Revision:
0:0d02a451e79d

File content as of revision 0:0d02a451e79d:

#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;
    }
}