gianni-carbone / STM32encoder

Arduino library for the management of rotary encoders with STM32
GNU General Public License v3.0
18 stars 3 forks source link
arduino-library rotary-encoder stm32

STM32encoder

GitHub release contributions welcome GitHub issues

Description

Arduino library for the management of rotary encoders with STM32. This Arduino library simplifies the use of rotary encoders. It works with stm32 platforms.

This Arduino library makes it easy to use rotary encoders. With a few lines of code it is possible to instantiate an encoder object and fully manage it. You can link a variable so that it is increased and decreased by turning the knob. It is also possible to attach a user defined isr to be executed on each tick of knob. Optionally, the library can take into account the rotation dynamics, detecting the speed and correcting the rate of increase in proportion to it.

The library uses the "encoder mode" features of the advanced timers present in the STM32 mcu. Each instantiated object uses (consumes) a timer. In general, each STM32 mcu has several timers available that offer the encoder mode, so it is possible to use multiple encoders connected to a single mcu. The maximum number of encoders depends on the mcu model.

The encoder object can be instantiated in "managed" or "freewheel" mode. In the first mode it is possible to exploit all the potential of the library. The second mode, while facilitating the use of the encoder and keeping low mcu overheads, leaves the user to manage the higher level functions. By default, object instantiation is in "managed" mode.

There is also a small set of functions for managing the knob button. Currently the library debounces the button and detects click and long click events. Alternatively, the knob button can be settled to vary the incRate on a predefined scale (eg 1, 10, 100) presets it via the setButton function.

Please take a look at the examples to get a better understanding of how it works.

Brief of methods and properties

Available main methods in "managed" mode:

Available methods in "freewheel" mode:

Syntax of methods and properties


Contributing

If you want to contribute to this project: