Control Surface master
MIDI Control Surface library for Arduino
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
Encoder Class Reference

#include <Submodules/Encoder/Encoder.h>

Detailed Description

Class for reading quadrature encoders, based on http://www.pjrc.com/teensy/td_libs_Encoder.html.

Definition at line 59 of file Encoder.h.

+ Collaboration diagram for Encoder:

Public Member Functions

 Encoder (uint8_t pin1, uint8_t pin2)
 Constructor. More...
 
 Encoder (const Encoder &)=delete
 Copy constructor: copying an Encoder object is semantically meaningless, so it has been deleted. More...
 
Encoderoperator= (const Encoder &)=delete
 Copy assignment: copying an Encoder object is semantically meaningless, so it has been deleted. More...
 
 Encoder (Encoder &&other)
 Move constructor. More...
 
Encoderoperator= (Encoder &&other)
 Move assignment. More...
 
 ~Encoder ()
 Destructor. More...
 
void begin ()
 Initialize this encoder by enabling the pull-up resistors and attaching the interrupts handlers (if interrupts are enabled and available on the the given pins). More...
 
void end ()
 Disable the interrupts used by this encoder. More...
 
int32_t read ()
 Read the current absolute position of the encoder. More...
 
int32_t readAndReset ()
 Read the current absolute position of the encoder and reset it to zero afterwards. More...
 
void write (int32_t p)
 Set the absolute position to the given value. More...
 

Static Public Member Functions

static void update (Encoder_internal_state_t *arg)
 update() is not meant to be called from outside Encoder, but it is public to allow static interrupt routines. More...
 

Static Public Attributes

static Encoder_internal_state_tinterruptArgs [CORE_NUM_INTERRUPT] = {}
 Similarly to update(), don't use these interrupt handler arguments from your sketch. More...
 

Private Member Functions

void attachInterruptCtx (int interrupt)
 
void detachInterruptCtx (int interrupt)
 

Private Attributes

Encoder_internal_state_t encoder
 
uint8_t pin1
 
uint8_t pin2
 
uint8_t interrupts_in_use = 0
 

Constructor & Destructor Documentation

◆ Encoder() [1/3]

Encoder ( uint8_t  pin1,
uint8_t  pin2 
)

Constructor.

Parameters
pin1The first pin, connected to the encoder's "A" pin.
pin2The second pin, connected to the encoder's "B" pin.

The internal pull-up resistors will be enabled on these pins upon initialization (when calling the begin method).

Definition at line 9 of file Encoder.cpp.

◆ Encoder() [2/3]

Encoder ( const Encoder )
delete

Copy constructor: copying an Encoder object is semantically meaningless, so it has been deleted.

◆ Encoder() [3/3]

Encoder ( Encoder &&  other)

Move constructor.

Definition at line 21 of file Encoder.cpp.

◆ ~Encoder()

~Encoder ( )

Destructor.

Definition at line 62 of file Encoder.cpp.

Member Function Documentation

◆ operator=() [1/2]

Encoder & operator= ( const Encoder )
delete

Copy assignment: copying an Encoder object is semantically meaningless, so it has been deleted.

◆ operator=() [2/2]

Encoder & operator= ( Encoder &&  other)

Move assignment.

Definition at line 23 of file Encoder.cpp.

◆ begin()

void begin ( )

Initialize this encoder by enabling the pull-up resistors and attaching the interrupts handlers (if interrupts are enabled and available on the the given pins).

Definition at line 69 of file Encoder.cpp.

◆ end()

void end ( )

Disable the interrupts used by this encoder.

Definition at line 87 of file Encoder.cpp.

◆ read()

int32_t read ( )
inline

Read the current absolute position of the encoder.

Definition at line 5 of file Encoder.ipp.

◆ readAndReset()

int32_t readAndReset ( )
inline

Read the current absolute position of the encoder and reset it to zero afterwards.

Definition at line 17 of file Encoder.ipp.

◆ write()

void write ( int32_t  p)
inline

Set the absolute position to the given value.

Definition at line 30 of file Encoder.ipp.

◆ attachInterruptCtx()

void attachInterruptCtx ( int  interrupt)
private

Definition at line 94 of file Encoder.cpp.

◆ detachInterruptCtx()

void detachInterruptCtx ( int  interrupt)
private

Definition at line 102 of file Encoder.cpp.

◆ update()

void update ( Encoder_internal_state_t arg)
inlinestatic

update() is not meant to be called from outside Encoder, but it is public to allow static interrupt routines.

DO NOT call update() directly from sketches.

Definition at line 1 of file Encoder-AVR.ipp.

Member Data Documentation

◆ encoder

Encoder_internal_state_t encoder
private

Definition at line 110 of file Encoder.h.

◆ pin1

uint8_t pin1
private

Definition at line 111 of file Encoder.h.

◆ pin2

uint8_t pin2
private

Definition at line 111 of file Encoder.h.

◆ interrupts_in_use

uint8_t interrupts_in_use = 0
private

Definition at line 112 of file Encoder.h.

◆ interruptArgs

Encoder_internal_state_t * interruptArgs = {}
static

Similarly to update(), don't use these interrupt handler arguments from your sketch.

Definition at line 122 of file Encoder.h.


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