Quadrature Encoder Switch (Alps EC11)
EncoderSwitch.h@1:7d24b4076453, 2015-04-01 (annotated)
- Committer:
- michaelruck
- Date:
- Wed Apr 01 05:43:10 2015 +0000
- Revision:
- 1:7d24b4076453
- Parent:
- 0:1330a261101d
Added Timeout to prevent isr chattering
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
michaelruck | 0:1330a261101d | 1 | /* michael@ruck.com märz 2015 v0.1*/ |
michaelruck | 0:1330a261101d | 2 | // Important! Two different EXTI Lines from 0 to 4! |
michaelruck | 0:1330a261101d | 3 | // For Encoder Alps EC11 |
michaelruck | 0:1330a261101d | 4 | |
michaelruck | 0:1330a261101d | 5 | #ifndef MBED_ENCODERSWITCH_H |
michaelruck | 0:1330a261101d | 6 | #define MBED_ENCODERSWITCH_H |
michaelruck | 0:1330a261101d | 7 | |
michaelruck | 0:1330a261101d | 8 | #include "mbed.h" |
michaelruck | 0:1330a261101d | 9 | |
michaelruck | 0:1330a261101d | 10 | class EncoderSwitch |
michaelruck | 0:1330a261101d | 11 | { |
michaelruck | 0:1330a261101d | 12 | public: |
michaelruck | 0:1330a261101d | 13 | EncoderSwitch(PinName pinA, PinName pinB, PinMode pull=PullNone); |
michaelruck | 0:1330a261101d | 14 | ~EncoderSwitch(); |
michaelruck | 0:1330a261101d | 15 | int16_t count; |
michaelruck | 0:1330a261101d | 16 | void setLimits(int16_t limit_down=0, int16_t limit_up=9); |
michaelruck | 0:1330a261101d | 17 | |
michaelruck | 0:1330a261101d | 18 | private: |
michaelruck | 0:1330a261101d | 19 | InterruptIn _pinA; |
michaelruck | 0:1330a261101d | 20 | InterruptIn _pinB; |
michaelruck | 0:1330a261101d | 21 | |
michaelruck | 1:7d24b4076453 | 22 | Timeout _timeout; |
michaelruck | 1:7d24b4076453 | 23 | void _enable_isr(); |
michaelruck | 1:7d24b4076453 | 24 | |
michaelruck | 0:1330a261101d | 25 | int16_t _limit_down; |
michaelruck | 0:1330a261101d | 26 | int16_t _limit_up; |
michaelruck | 0:1330a261101d | 27 | volatile int8_t _increment; |
michaelruck | 0:1330a261101d | 28 | |
michaelruck | 0:1330a261101d | 29 | void isra(); |
michaelruck | 0:1330a261101d | 30 | void isrb(); |
michaelruck | 0:1330a261101d | 31 | void counter(int16_t increment); |
michaelruck | 0:1330a261101d | 32 | }; |
michaelruck | 0:1330a261101d | 33 | #endif |