components/esp32-rotary-encoder/README.md

changeset 0
88d965579617
equal deleted inserted replaced
-1:000000000000 0:88d965579617
1 # esp32-rotary-encoder
2
3 [![Platform: ESP-IDF](https://img.shields.io/badge/ESP--IDF-v3.0%2B-blue.svg)](https://docs.espressif.com/projects/esp-idf/en/stable/get-started/)
4 [![License: GPL v3](https://img.shields.io/badge/License-GPLv3+-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
5
6 ## Introduction
7
8 This ESP32 component uses a debouncing state machine to track the position of an [incremental](https://en.wikipedia.org/wiki/Rotary_encoder#Incremental) rotary encoder such as the [EC11](https://www.alps.com/prod/info/E/HTML/Encoder/Incremental/EC11/EC11_list.html) or [LPD3806](https://www.codrey.com/electronic-circuits/paupers-rotary-encoder/).
9
10 These encoders provide two outputs (typically "A" and "B") that have a quadrature relationship - that is, they oscillate between high and low as the shaft rotates, but with a 90 degree phase offset. Therefore the outputs `AB` may go through the following pattern: `00`, `10`, `11`, `01`, `00` ... The direction can be determined by observing the order of this pattern. This component uses a state machine to decode the sequence of quadrature states, and therefore provides a fairly glitch-free and accurate measurement of the encoder's movement.
11
12 Interrupts are registered on the A and B pins to detect edges. This component assumes that `gpio_install_isr_service()` has been called prior.
13
14 The direction event is placed into a FreeRTOS queue and can be used by a task to increment or decrement a counter that represents the encoder's absolute position.
15
16 Encoders that provide a push button are supported, however this component does not provide direct support for the button. Typically, the button is normally open and pushing it closes the contacts, which can be used to pull a GPIO pin high or low depending on arrangement. This can be detected with a normal GPIO poll or interrupt.
17
18 ## Dependencies
19
20 It is written and tested for v3.0-v3.2 of the [ESP-IDF](https://github.com/espressif/esp-idf) environment, using the xtensa-esp32-elf toolchain (gcc version 5.2.0). It may or may not work with older or newer versions.
21
22 ## Example
23
24 An example application that uses this component is available: [esp32-rotary-encoder-example](https://github.com/DavidAntliff/esp32-rotary-encoder-example)
25
26 ## Features
27
28 * Publication of an event into a user-supplied queue when the encoder moves to either a full or half step:
29 * Full step mode, where the encoder must move through an entire sequence of four steps before an event is published.
30 * Half step mode, where the encoder must move through half an entire sequence (two steps) before an event is published.
31
32 ## Documentation
33
34 Automatically generated API documentation is available [here](https://davidantliff.github.io/esp32-rotary-encoder/index.html).
35
36 ## Source Code
37
38 The source is available from [GitHub](https://www.github.com/DavidAntliff/esp32-rotary-encoder).
39
40 ## License
41
42 The code in this project is licensed under the GNU GPL Version 3, or (at your option) any later version. - see [LICENSE](LICENSE) for details.
43
44 ## Links
45
46 * [esp32-rotary-encoder-example](https://github.com/DavidAntliff/esp32-rotary-encoder-example)
47 * [Espressif IoT Development Framework for ESP32](https://github.com/espressif/esp-idf)
48
49 ## Acknowledgements
50
51 Thank you to [Ben Buxton](mailto://bb@cactii.net) who provided the [original](https://github.com/buxtronix/arduino/tree/master/libraries/Rotary) Arduino code that this component is based upon.
52
53
54

mercurial