Six crescent shaped legs

Dependencies:   mbed

Encoder.cpp

Committer:
sim642
Date:
2016-04-12
Revision:
12:8de7f5d56fe4
Parent:
8:c3af2a1c206c
Child:
14:4143ddddef1b

File content as of revision 12:8de7f5d56fe4:

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