driver for incremental encoder

Committer:
ianaherne
Date:
Tue Jan 08 17:10:13 2019 +0000
Revision:
0:c3a05fe15b84
Child:
1:017efde7ab29
working counting up and down and directional information

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ianaherne 0:c3a05fe15b84 1 #ifndef DECODER_H
ianaherne 0:c3a05fe15b84 2 #define DECODER_H
ianaherne 0:c3a05fe15b84 3 #include "mbed.h"
ianaherne 0:c3a05fe15b84 4
ianaherne 0:c3a05fe15b84 5
ianaherne 0:c3a05fe15b84 6
ianaherne 0:c3a05fe15b84 7
ianaherne 0:c3a05fe15b84 8 class decoder{
ianaherne 0:c3a05fe15b84 9
ianaherne 0:c3a05fe15b84 10 public:
ianaherne 0:c3a05fe15b84 11
ianaherne 0:c3a05fe15b84 12 decoder(PinName channelA,PinName channelB);
ianaherne 0:c3a05fe15b84 13
ianaherne 0:c3a05fe15b84 14 void isr();
ianaherne 0:c3a05fe15b84 15
ianaherne 0:c3a05fe15b84 16 int8_t getDirection();
ianaherne 0:c3a05fe15b84 17 int16_t getCount();
ianaherne 0:c3a05fe15b84 18
ianaherne 0:c3a05fe15b84 19
ianaherne 0:c3a05fe15b84 20
ianaherne 0:c3a05fe15b84 21 private:
ianaherne 0:c3a05fe15b84 22
ianaherne 0:c3a05fe15b84 23 InterruptIn _channelA;
ianaherne 0:c3a05fe15b84 24 InterruptIn _channelB;
ianaherne 0:c3a05fe15b84 25
ianaherne 0:c3a05fe15b84 26
ianaherne 0:c3a05fe15b84 27 int8_t _direction;
ianaherne 0:c3a05fe15b84 28 int16_t _count;
ianaherne 0:c3a05fe15b84 29 int16_t _oldCount;
ianaherne 0:c3a05fe15b84 30
ianaherne 0:c3a05fe15b84 31
ianaherne 0:c3a05fe15b84 32 };
ianaherne 0:c3a05fe15b84 33
ianaherne 0:c3a05fe15b84 34 #endif