#include <Submodules/Encoder/Encoder.h>
Class for reading quadrature encoders, based on http://www.pjrc.com/teensy/td_libs_Encoder.html.
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... | |
Encoder & | operator= (const Encoder &)=delete |
Copy assignment: copying an Encoder object is semantically meaningless, so it has been deleted. More... | |
Encoder (Encoder &&other) | |
Move constructor. More... | |
Encoder & | operator= (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_t * | interruptArgs [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 |
Encoder | ( | uint8_t | pin1, |
uint8_t | pin2 | ||
) |
Constructor.
pin1 | The first pin, connected to the encoder's "A" pin. |
pin2 | The 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.
Copy constructor: copying an Encoder object is semantically meaningless, so it has been deleted.
Move constructor.
Definition at line 21 of file Encoder.cpp.
~Encoder | ( | ) |
Destructor.
Definition at line 62 of file Encoder.cpp.
Copy assignment: copying an Encoder object is semantically meaningless, so it has been deleted.
Move assignment.
Definition at line 23 of file Encoder.cpp.
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.
void end | ( | ) |
Disable the interrupts used by this encoder.
Definition at line 87 of file Encoder.cpp.
|
inline |
Read the current absolute position of the encoder.
Definition at line 5 of file Encoder.ipp.
|
inline |
Read the current absolute position of the encoder and reset it to zero afterwards.
Definition at line 17 of file Encoder.ipp.
|
inline |
Set the absolute position to the given value.
Definition at line 30 of file Encoder.ipp.
|
private |
Definition at line 94 of file Encoder.cpp.
|
private |
Definition at line 102 of file Encoder.cpp.
|
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.
|
private |
|
static |