Six crescent shaped legs

Dependencies:   mbed

Encoder.cpp

Committer:
sim642
Date:
2016-04-12
Revision:
8:c3af2a1c206c
Parent:
2:cf0147952fb9
Child:
12:8de7f5d56fe4

File content as of revision 8:c3af2a1c206c:

#include "Encoder.hpp"

Encoder::Encoder(EncoderData nData) : data(nData), encA(data.encAPin), encB(data.encBPin), intA(data.encAPin), intB(data.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--;
}