Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
|
Connect a quadrature rotary encoder. More...
#include <Encoder.h>
Public Types | |
enum | Rotation { CCW = -1, NONE = 0, CW = 1 } |
enum | Polarity { ANY, ACTIVE_LOW, ACTIVE_HIGH } |
Public Member Functions | |
Encoder (unsigned int debounce, Polarity polarity=ANY) | |
void | setup (unsigned int debounce, Polarity polarity=ANY) |
void | reset (int position=0) |
Rotation | process (bool a, bool b) |
int | get () |
Connect a quadrature rotary encoder.
Connect a quadrature rotary encoder.
It provides a debouncer to ignore spurious readings due to mechanical bouncing of the contacts.
It contains an internal counter which tracks how many steps the encoder has moved from its initial position. Position is incremented when it moves clockwise and decremented when it movew counter-clockwise.
enum Encoder::Rotation |
enum Encoder::Polarity |
Set up the encoder with a given debounce interval.
debounce | the number of calls to process() during which changes are ignored after a change in a has been detected. |
polarity | on which edge to trigger. |
void Encoder::reset | ( | int | position = 0 | ) |
Sets the current position of the encoder to the specified value.
position | The new position (defaults to 0). |
Encoder::Rotation Encoder::process | ( | bool | a, |
bool | b | ||
) |
Process new readings from the encoder's terminals.
int Encoder::get | ( | ) |
Get the position of the encoder.