Six crescent shaped legs

Dependencies:   mbed

Encoder.cpp

Committer:
sim642
Date:
2016-03-29
Revision:
2:cf0147952fb9
Child:
8:c3af2a1c206c

File content as of revision 2:cf0147952fb9:

#include "Encoder.hpp"

Encoder::Encoder(PinName encAPin, PinName encBPin) : encA(encAPin), encB(encBPin), intA(encAPin), intB(encBPin)
{
    intA.rise(this, &Encoder::changeA);
    intA.fall(this, &Encoder::changeA);
}

long Encoder::getCount()
{
    return count;
}

void Encoder::changeA()
{
    if (encA.read() == encB.read())
        count++;
    else
        count--;
}