Giter Site home page Giter Site logo

ericyeargan / esp32-rotary-encoder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from davidantliff/esp32-rotary-encoder

0.0 0.0 0.0 144 KB

ESP32-compatible rotary encoder driver

License: GNU General Public License v3.0

Makefile 0.08% C 99.07% CMake 0.85%

esp32-rotary-encoder's Introduction

esp32-rotary-encoder

Platform: ESP-IDF License: GPL v3

Introduction

This ESP32 component uses a debouncing state machine to track the position of an incremental rotary encoder such as the EC11 or LPD3806.

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.

Interrupts are registered on the A and B pins to detect edges. This component assumes that gpio_install_isr_service() has been called prior.

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.

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.

Dependencies

It is written and tested for v3.0-v3.2 of the 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.

Example

An example application that uses this component is available: esp32-rotary-encoder-example

Features

  • Publication of an event into a user-supplied queue when the encoder moves to either a full or half step:
    • Full step mode, where the encoder must move through an entire sequence of four steps before an event is published.
    • Half step mode, where the encoder must move through half an entire sequence (two steps) before an event is published.

Documentation

Automatically generated API documentation is available here.

Source Code

The source is available from GitHub.

License

The code in this project is licensed under the GNU GPL Version 3, or (at your option) any later version. - see LICENSE for details.

Links

Acknowledgements

Thank you to Ben Buxton who provided the original Arduino code that this component is based upon.

esp32-rotary-encoder's People

Contributors

davidantliff avatar ericyeargan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.