SimpleFOClibrary  2.1
Encoder Class Reference

#include <Encoder.h>

Inheritance diagram for Encoder:

Public Member Functions

 Encoder (int encA, int encB, float ppr, int index=0)
void init ()
void enableInterrupts (void(*doA)()=nullptr, void(*doB)()=nullptr, void(*doIndex)()=nullptr)
void handleA ()
void handleB ()
void handleIndex ()
float getAngle () override
float getVelocity () override
int needsSearch () override

Public Attributes

int pinA
 encoder hardware pin A More...
int pinB
 encoder hardware pin B More...
int index_pin
 index pin More...
Pullup pullup
 Configuration parameter internal or external pullups. More...
Quadrature quadrature
 Configuration parameter enable or disable quadrature mode. More...
float cpr
 encoder cpr number More...

Detailed Description

Definition at line 18 of file Encoder.h.

Constructor & Destructor Documentation

◆ Encoder()

Encoder::Encoder ( int  encA,
int  encB,
float  ppr,
int  index = 0 

Encoder class constructor

encAencoder B pin
encBencoder B pin
pprimpulses per rotation (cpr=ppr*4)
indexindex pin number (optional input)

Definition at line 11 of file Encoder.cpp.

Member Function Documentation

◆ enableInterrupts()

void Encoder::enableInterrupts ( void(*)()  doA = nullptr,
void(*)()  doB = nullptr,
void(*)()  doIndex = nullptr 

function enabling hardware interrupts for the encoder channels with provided callback functions if callback is not provided then the interrupt is not enabled

doApointer to the A channel interrupt handler function
doBpointer to the B channel interrupt handler function
doIndexpointer to the Index channel interrupt handler function

Definition at line 190 of file Encoder.cpp.

◆ getAngle()

float Encoder::getAngle ( )

get current angle (rad)

Implements Sensor.

Definition at line 104 of file Encoder.cpp.

◆ getVelocity()

float Encoder::getVelocity ( )

get current angular velocity (rad/s)

Reimplemented from Sensor.

Definition at line 111 of file Encoder.cpp.

◆ handleA()

void Encoder::handleA ( )

A channel callback function

Definition at line 42 of file Encoder.cpp.

◆ handleB()

void Encoder::handleB ( )

B channel callback function

Definition at line 63 of file Encoder.cpp.

◆ handleIndex()

void Encoder::handleIndex ( )

Index channel callback function

Definition at line 85 of file Encoder.cpp.

◆ init()

void Encoder::init ( )

encoder initialise pins

Definition at line 160 of file Encoder.cpp.

◆ needsSearch()

int Encoder::needsSearch ( )

returns 0 if it does need search for absolute zero 0 - encoder without index 1 - ecoder with index

Reimplemented from Sensor.

Definition at line 148 of file Encoder.cpp.

Member Data Documentation

◆ cpr

float Encoder::cpr

encoder cpr number

Definition at line 59 of file Encoder.h.

◆ index_pin

int Encoder::index_pin

index pin

Definition at line 54 of file Encoder.h.

◆ pinA

int Encoder::pinA

encoder hardware pin A

Definition at line 52 of file Encoder.h.

◆ pinB

int Encoder::pinB

encoder hardware pin B

Definition at line 53 of file Encoder.h.

◆ pullup

Pullup Encoder::pullup

Configuration parameter internal or external pullups.

Definition at line 57 of file Encoder.h.

◆ quadrature

Quadrature Encoder::quadrature

Configuration parameter enable or disable quadrature mode.

Definition at line 58 of file Encoder.h.

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