Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Public Types | Public Member Functions | List of all members
Encoder Class Reference

Connect a quadrature rotary encoder. More...

#include <Encoder.h>

Inheritance diagram for Encoder:
BelaEncoder

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 ()
 

Detailed Description

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.

Examples:
Sensors/rotary-encoder/render.cpp.

Member Enumeration Documentation

Enumerator
CCW 

The encoder rotated counter-clockwise.

NONE 

The encoder did not rotate.

CW 

The encoder rotate clockwise.

Which edge of the a signal denotes a transition.

Enumerator
ANY 

Trigger on any edge.

ACTIVE_LOW 

Trigger on negative edges.

ACTIVE_HIGH 

Trigger on negative edges.

Constructor & Destructor Documentation

Encoder::Encoder ( unsigned int  debounce,
Polarity  polarity = ANY 
)
inline

Same as setup().

Member Function Documentation

void Encoder::setup ( unsigned int  debounce,
Polarity  polarity = ANY 
)

Set up the encoder with a given debounce interval.

Parameters
debouncethe number of calls to process() during which changes are ignored after a change in a has been detected.
polarityon which edge to trigger.
Examples:
Sensors/rotary-encoder/render.cpp.
void Encoder::reset ( int  position = 0)

Sets the current position of the encoder to the specified value.

Parameters
positionThe new position (defaults to 0).
Examples:
Sensors/rotary-encoder/render.cpp.
Encoder::Rotation Encoder::process ( bool  a,
bool  b 
)

Process new readings from the encoder's terminals.

Returns
whether, and in which direction, the encoder has moved in this last step.
Examples:
Sensors/rotary-encoder/render.cpp.
int Encoder::get ( )

Get the position of the encoder.

Examples:
Sensors/rotary-encoder/render.cpp.

The documentation for this class was generated from the following files: