hctl 2032 encoder for stm32
EncoderCounter.h@4:d99e7d8ed0be, 2014-09-05 (annotated)
- Committer:
- c128
- Date:
- Fri Sep 05 13:31:34 2014 +0000
- Revision:
- 4:d99e7d8ed0be
- Parent:
- 3:b83ec916ba01
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
c128 | 2:3e4d1297e260 | 1 | // porting stm32 http://www.robogaia.com/two-axis-encoder-counter-mega-shield-version-2.html |
c128 | 2:3e4d1297e260 | 2 | // by Paolo Della Vedova |
c128 | 3:b83ec916ba01 | 3 | // there are more problem to convert 5v to 3v |
c128 | 0:b1faec368b5d | 4 | |
c128 | 0:b1faec368b5d | 5 | #ifndef HCTL_2032_DRIVER |
c128 | 0:b1faec368b5d | 6 | #define HCTL_2032_DRIVER |
c128 | 0:b1faec368b5d | 7 | |
c128 | 0:b1faec368b5d | 8 | #include "mbed.h" |
c128 | 0:b1faec368b5d | 9 | |
c128 | 0:b1faec368b5d | 10 | |
c128 | 2:3e4d1297e260 | 11 | // arduino compatibility |
c128 | 0:b1faec368b5d | 12 | #define HIGH 1 |
c128 | 0:b1faec368b5d | 13 | #define LOW 0 |
c128 | 0:b1faec368b5d | 14 | |
c128 | 0:b1faec368b5d | 15 | #define digitalWrite(x,y) x=y |
c128 | 0:b1faec368b5d | 16 | |
c128 | 0:b1faec368b5d | 17 | |
c128 | 0:b1faec368b5d | 18 | |
c128 | 0:b1faec368b5d | 19 | |
c128 | 0:b1faec368b5d | 20 | class ENCODER |
c128 | 0:b1faec368b5d | 21 | { |
c128 | 0:b1faec368b5d | 22 | public: |
c128 | 0:b1faec368b5d | 23 | ENCODER( unsigned char countMode=4 ); |
c128 | 0:b1faec368b5d | 24 | |
c128 | 0:b1faec368b5d | 25 | void XAxisReset( ); |
c128 | 0:b1faec368b5d | 26 | int XAxisGetCount( ); |
c128 | 0:b1faec368b5d | 27 | void YAxisReset( ); |
c128 | 0:b1faec368b5d | 28 | int YAxisGetCount( ); |
c128 | 0:b1faec368b5d | 29 | |
c128 | 0:b1faec368b5d | 30 | void switchCountMode( unsigned char countMode ); |
c128 | 0:b1faec368b5d | 31 | |
c128 | 0:b1faec368b5d | 32 | private: |
c128 | 0:b1faec368b5d | 33 | signed int countEnc; |
c128 | 0:b1faec368b5d | 34 | unsigned char busByte; |
c128 | 0:b1faec368b5d | 35 | signed char busByteMSB; |
c128 | 0:b1faec368b5d | 36 | }; |
c128 | 0:b1faec368b5d | 37 | |
c128 | 0:b1faec368b5d | 38 | |
c128 | 0:b1faec368b5d | 39 | #endif |
c128 | 0:b1faec368b5d | 40 |