Jan Wolfsberger / Sensor

Dependencies:   CommandHandler HygroClip2 InterruptBasedEncoder SPI_TFT_ILI9341 mbed-src-no-hal

Revision:
4:47fd4584df95
Parent:
3:3ef8c2d7b1bf
diff -r 3ef8c2d7b1bf -r 47fd4584df95 Encoder.h
--- a/Encoder.h	Tue Mar 15 07:46:06 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-#ifndef ENCODER_H_INCLUDED
-#define ENCODER_H_INCLUDED
-
-class RotaryEncoder {
-public:
-    RotaryEncoder(PinName outa, PinName outb)
-        : position_(0), delta_(0),
-          inta_(outa), intb_(outb), outa_(outa), outb_(outb) {
-        outa_.mode(PullUp);
-        outb_.mode(PullUp);
-        inta_.rise(this, &RotaryEncoder::handleIntA);
-        inta_.fall(this, &RotaryEncoder::handleIntA);
-        intb_.rise(this, &RotaryEncoder::handleIntB);
-        intb_.fall(this, &RotaryEncoder::handleIntB);
-    }
-
-    /** Returns the overall position of the encoder
-     */
-    int position() {
-        return position_;
-    }
-
-    /** Returns the encoders change since the last call to this function
-     */
-    int delta() {
-        int d = delta_;
-        delta_ = 0;
-        return d;
-    }
-
-private:
-
-    // A  = B --> Clockwise
-    // A /= B --> Counter clockwise
-    void handleIntA() {
-        if (outa_ == outb_) {
-            increment(1);
-        } else {
-            increment(-1);
-        }
-    }
-
-    // A  = B --> Counter clockwise
-    // A /= B --> Clockwise
-    void handleIntB() {
-        if (outa_ == outb_) {
-            increment(-1);
-        } else {
-            increment(1);
-        }
-    }
-
-    void increment(int i) {
-        position_ += i;
-        delta_ += i;
-    }
-
-    int position_;
-    int delta_;
-
-    InterruptIn inta_;
-    InterruptIn intb_;
-    DigitalIn outa_;
-    DigitalIn outb_;
-};
-
-#endif /* ENCODER_H_INCLUDED */