Open FFBoard
Open source force feedback firmware
Encoder Class Reference

#include <Encoder.h>

Inheritance diagram for Encoder:
ChoosableClass EncoderBissC EncoderLocal EncoderSSI MotorSimplemotion MtEncoderSPI ODriveCAN RmdMotorCAN TMC4671 VescCAN

Public Member Functions

 Encoder ()
 
virtual ~Encoder ()
 
const ClassIdentifier getInfo ()
 
virtual EncoderType getEncoderType ()
 
virtual int32_t getPos ()
 
virtual float getPos_f ()
 
virtual int32_t getPosAbs ()
 
virtual float getPosAbs_f ()
 
virtual void setPos (int32_t pos)
 
virtual uint32_t getCpr ()
 
virtual const ClassType getClassType () override
 returns the used classchooser selection id of this instance More...
 
- Public Member Functions inherited from ChoosableClass
virtual ~ChoosableClass ()
 
uint16_t getSelectionID ()
 

Static Public Attributes

static ClassIdentifier info ={.name = "None" , .id=CLSID_ENCODER_NONE, .visibility = ClassVisibility::visible}
 
static const std::vector< class_entry< Encoder > > all_encoders
 
- Static Public Attributes inherited from ChoosableClass
static ClassIdentifier info
 

Protected Attributes

uint32_t cpr = 0
 
- Protected Attributes inherited from ChoosableClass
uint16_t selectionId
 Should only be written by ClassChooser during creation. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ChoosableClass
static bool isCreatable ()
 

Detailed Description

Definition at line 29 of file Encoder.h.

Constructor & Destructor Documentation

◆ Encoder()

Encoder::Encoder ( )

Definition at line 18 of file Encoder.cpp.

◆ ~Encoder()

Encoder::~Encoder ( )
virtual

Definition at line 22 of file Encoder.cpp.

Member Function Documentation

◆ getClassType()

virtual const ClassType Encoder::getClassType ( )
inlineoverridevirtual

returns the used classchooser selection id of this instance

Type of this class. Mainclass, motordriver... Should be implemented by the parent class so it is not in the info struct

Reimplemented from ChoosableClass.

Reimplemented in TMC4671.

Definition at line 50 of file Encoder.h.

◆ getCpr()

uint32_t Encoder::getCpr ( )
virtual

Gets the amount of counts per full rotation of the encoder

Reimplemented in EncoderBissC, EncoderSSI, TMC4671, MotorSimplemotion, MtEncoderSPI, ODriveCAN, RmdMotorCAN, and VescCAN.

Definition at line 36 of file Encoder.cpp.

◆ getEncoderType()

EncoderType Encoder::getEncoderType ( )
virtual

Returns the type of the encoder. Must override this and NOT return NONE in other classes

Reimplemented in EncoderBissC, EncoderLocal, EncoderSSI, MtEncoderSPI, MotorSimplemotion, ODriveCAN, RmdMotorCAN, TMC4671, and VescCAN.

Definition at line 29 of file Encoder.cpp.

◆ getInfo()

◆ getPos()

int32_t Encoder::getPos ( )
virtual

Returns the encoder position as raw counts

Reimplemented in EncoderBissC, EncoderLocal, EncoderSSI, MotorSimplemotion, MtEncoderSPI, ODriveCAN, RmdMotorCAN, TMC4671, and VescCAN.

Definition at line 44 of file Encoder.cpp.

◆ getPos_f()

float Encoder::getPos_f ( )
virtual

Returns a float position in rotations

Reimplemented in ODriveCAN, and VescCAN.

Definition at line 67 of file Encoder.cpp.

◆ getPosAbs()

int32_t Encoder::getPosAbs ( )
virtual

Returns absolute positions without offsets for absolute encoders. Otherwise it returns getPos

Reimplemented in EncoderBissC, EncoderSSI, MtEncoderSPI, and TMC4671.

Definition at line 59 of file Encoder.cpp.

◆ getPosAbs_f()

float Encoder::getPosAbs_f ( )
virtual

Definition at line 48 of file Encoder.cpp.

◆ setPos()

void Encoder::setPos ( int32_t  pos)
virtual

Change the position of the encoder Can be used to reset the center

Reimplemented in EncoderBissC, EncoderLocal, EncoderSSI, MtEncoderSPI, MotorSimplemotion, ODriveCAN, RmdMotorCAN, TMC4671, and VescCAN.

Definition at line 78 of file Encoder.cpp.

Member Data Documentation

◆ all_encoders

std::vector< class_entry< Encoder > > const Encoder::all_encoders
static
Initial value:
=
{
add_class<Encoder, Encoder>(0),
#ifdef LOCALENCODER
add_class<EncoderLocal, Encoder>(2),
#endif
#ifdef MTENCODERSPI
add_class<MtEncoderSPI, Encoder>(4),
#endif
#ifdef BISSENCODER
add_class<EncoderBissC, Encoder>(5),
#endif
#ifdef SSIENCODER
add_class<EncoderSSI, Encoder>(6),
#endif
}

Definition at line 49 of file Encoder.h.

◆ cpr

uint32_t Encoder::cpr = 0
protected

Definition at line 53 of file Encoder.h.

◆ info

ClassIdentifier Encoder::info ={.name = "None" , .id=CLSID_ENCODER_NONE, .visibility = ClassVisibility::visible}
static

Definition at line 33 of file Encoder.h.


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