David Knight / Mbed 2 deprecated lichtspiel

Dependencies:   PololuLedStrip mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Rotary.h Source File

Rotary.h

00001 #ifndef ROTARY_H
00002 #define ROTARY_H
00003 
00004 #include "mbed.h"
00005 
00006 class Rotary {
00007   public:
00008     enum Action {
00009       NONE, LEFT, RIGHT, TIMEOUT
00010     };
00011 
00012 #ifdef DEV
00013         static const uint32_t TIMEOUT_MILLIS = 20 * 1000UL;
00014 #else
00015         static const uint32_t TIMEOUT_MILLIS = 120 * 1000UL;
00016 #endif
00017 
00018     Rotary(PinName _pinA, PinName _pinB);
00019     Action read();
00020     Action waitForAction();
00021 
00022   private:
00023     uint8_t _prevPos, _flags;
00024     DigitalIn pinA, pinB;
00025     uint8_t readEnc();
00026 };
00027 
00028 #endif