Quadrature decoder
Embed:
(wiki syntax)
Show/hide line numbers
qed.h
00001 #ifndef QED_H 00002 #define QED_H 00003 00004 #include "mbed.h" 00005 00006 #define PREV_MASK 0x1 //Mask for the previous state in determining direction of rotation. 00007 #define CURR_MASK 0x2 //Mask for the current state in determining direction of rotation. 00008 #define INVALID 0x3 //XORing two states where both bits have changed. 00009 00010 class QED { 00011 public: 00012 QED(PinName channelA, PinName channelB); 00013 00014 int read(); 00015 00016 private: 00017 void decode(); 00018 00019 InterruptIn interruptA; 00020 InterruptIn interruptB; 00021 00022 volatile int pulses; 00023 00024 int prevState; 00025 int currState; 00026 }; 00027 00028 #endif
Generated on Sun Jul 17 2022 01:47:21 by 1.7.2