Open FFBoard
Open source force feedback firmware
EncoderLocal Class Reference

#include <EncoderLocal.h>

Inheritance diagram for EncoderLocal:
Encoder ExtiHandler TimerHandler CommandHandler PersistentStorage ChoosableClass

Public Member Functions

const ClassIdentifier getInfo ()
 Command handlers always have class infos. Works well with ChoosableClass. More...
 
 EncoderLocal ()
 
virtual ~EncoderLocal ()
 
EncoderType getEncoderType ()
 
void registerCommands ()
 
int32_t getPos ()
 
void setPos (int32_t pos)
 
void setPeriod (uint32_t period)
 
void overflowCallback ()
 
void exti (uint16_t GPIO_Pin) override
 
void timerElapsed (TIM_HandleTypeDef *htim)
 
int32_t getTimerCount ()
 
void setCpr (uint32_t cpr)
 
CommandStatus command (const ParsedCommand &cmd, std::vector< CommandReply > &replies)
 
std::string getHelpstring ()
 
void saveFlash ()
 
void restoreFlash ()
 
- Public Member Functions inherited from Encoder
 Encoder ()
 
virtual ~Encoder ()
 
virtual float getPos_f ()
 
virtual int32_t getPosAbs ()
 
virtual float getPosAbs_f ()
 
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 ()
 
- Public Member Functions inherited from ExtiHandler
 ExtiHandler ()
 
virtual ~ExtiHandler ()
 
- Public Member Functions inherited from CommandHandler
virtual const ClassType getClassType ()
 
 CommandHandler (const char *clsname, uint16_t clsid, uint8_t instance=0)
 
virtual ~CommandHandler ()
 
virtual bool hasCommands ()
 
virtual void setCommandsEnabled (bool enable)
 
void registerCommands ()
 
virtual CommandStatus internalCommand (const ParsedCommand &cmd, std::vector< CommandReply > &replies)
 
virtual std::string getCommandsHelpstring ()
 
virtual std::string getCsvHelpstring ()
 
virtual uint8_t getCommandHandlerInstance ()
 
void broadcastCommandReply (CommandReply reply, uint32_t cmdId, CMDtype type)
 
void sendCommandReplyAsync (CommandReply reply, uint32_t cmdId, CMDtype type, CommandInterface *interface=nullptr)
 
virtual uint16_t getCommandHandlerID ()
 
virtual CmdHandlerInfogetCommandHandlerInfo ()
 
virtual bool isValidCommandId (uint32_t cmdid, uint32_t ignoredFlags=0, uint32_t requiredFlag=0)
 
virtual CmdHandlerCommanddefgetCommandFromName (const std::string &cmd, uint32_t ignoredFlags=0)
 
virtual CmdHandlerCommanddefgetCommandFromId (const uint32_t id, uint32_t ignoredFlags=0)
 
template<typename ID >
void registerCommand (const char *cmd, const ID cmdid, const char *help=nullptr, uint32_t flags=0)
 
- Public Member Functions inherited from PersistentStorage
 PersistentStorage ()
 
virtual ~PersistentStorage ()
 
void restoreFlashDelayed ()
 

Static Public Member Functions

static bool isCreatable ()
 
- Static Public Member Functions inherited from ChoosableClass
static bool isCreatable ()
 
- Static Public Member Functions inherited from CommandHandler
static void logSerial (std::string string)
 Send a log formatted sequence. More...
 
static void logSerialDebug (std::string string)
 Send a log formatted sequence if debug is on. More...
 
static bool logsEnabled ()
 
static void setLogsEnabled (bool enabled)
 
static uint32_t getClassIdFromName (const char *name)
 
static const char * getClassNameFromId (const uint32_t id)
 
static CommandHandlergetHandlerFromHandlerId (const uint16_t cmdhandlerID)
 
static CommandHandlergetHandlerFromId (const uint16_t id, const uint8_t instance=0xFF)
 
static CommandHandlergetHandlerFromClassName (const char *name, const uint8_t instance=0xFF)
 
static std::vector< CommandHandler * > getHandlersFromClassName (const char *name)
 
static std::vector< CommandHandler * > getHandlersFromId (const uint16_t id)
 
static bool isInHandlerList (CommandHandler *handler)
 
static std::string getAllHelpstrings ()
 
static std::vector< CommandHandler * > & getCommandHandlers ()
 
template<typename TVal >
static CommandStatus handleGetSet (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value)
 
template<typename TVal , class cls , class cls1 >
static CommandStatus handleGetSetFunc (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value, void(cls1::*setfunc)(TVal), cls *obj)
 
template<typename TVal , class cls , class cls1 , class cls2 >
static CommandStatus handleGetFuncSetFunc (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal(cls1::*getfunc)(), void(cls2::*setfunc)(TVal), cls *obj)
 
template<typename TVal , class cls , class cls1 >
static CommandStatus handleGetFuncSet (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value, TVal(cls1::*getfunc)(), cls *obj)
 
- Static Public Member Functions inherited from PersistentStorage
static std::vector< PersistentStorage * > & getFlashHandlers ()
 
static void restoreFlashStartupCb ()
 

Static Public Attributes

static bool inUse = false
 
static ClassIdentifier info
 
- Static Public Attributes inherited from Encoder
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
 
- Static Public Attributes inherited from ExtiHandler
static std::vector< ExtiHandler * > extiHandlers
 
- Static Public Attributes inherited from CommandHandler
static bool logEnabled = true
 

Private Types

enum class  EncoderLocal_commands : uint32_t { cpr , useindex }
 

Private Attributes

TIM_HandleTypeDef * htim
 
int16_t offset = 0
 
int32_t pos = 0
 
uint32_t indexpos = 0
 
bool indexHit = false
 
bool useIndex = false
 

Additional Inherited Members

- Protected Member Functions inherited from CommandHandler
void setInstance (uint8_t instance)
 
virtual void addCommandHandler ()
 
virtual void removeCommandHandler ()
 
- Static Protected Member Functions inherited from CommandHandler
static std::vector< uint16_t > & getCommandHandlerIds ()
 
- Protected Attributes inherited from Encoder
uint32_t cpr = 0
 
- Protected Attributes inherited from ChoosableClass
uint16_t selectionId
 Should only be written by ClassChooser during creation. More...
 
- Protected Attributes inherited from CommandHandler
bool commandsEnabled = true
 
std::vector< CmdHandlerCommanddefregisteredCommands
 
CmdHandlerInfo cmdHandlerInfo
 
- Protected Attributes inherited from PersistentStorage
bool restoreDelayedFlag = false
 
- Static Protected Attributes inherited from PersistentStorage
static bool startupComplete = false
 
- Private Member Functions inherited from TimerHandler
 TimerHandler ()
 
virtual ~TimerHandler ()
 
- Static Private Attributes inherited from TimerHandler
static std::vector< TimerHandler * > timerHandlers
 

Detailed Description

Definition at line 24 of file EncoderLocal.h.

Member Enumeration Documentation

◆ EncoderLocal_commands

enum class EncoderLocal::EncoderLocal_commands : uint32_t
strongprivate
Enumerator
cpr 
useindex 

Definition at line 25 of file EncoderLocal.h.

Constructor & Destructor Documentation

◆ EncoderLocal()

EncoderLocal::EncoderLocal ( )

Definition at line 20 of file EncoderLocal.cpp.

◆ ~EncoderLocal()

EncoderLocal::~EncoderLocal ( )
virtual

Definition at line 41 of file EncoderLocal.cpp.

Member Function Documentation

◆ command()

CommandStatus EncoderLocal::command ( const ParsedCommand cmd,
std::vector< CommandReply > &  replies 
)
virtual
Parameters
[in]cmdThe parsed command to be executed.
[out]repliesA vector to return one or multiple reply objects into. Replies to the interface will be generated based on the reply objects. A string reply may not contain start, end and separation markers: [,],| Other characters are allowed.

Reimplemented from CommandHandler.

Definition at line 133 of file EncoderLocal.cpp.

◆ exti()

void EncoderLocal::exti ( uint16_t  GPIO_Pin)
overridevirtual

Reimplemented from ExtiHandler.

Definition at line 98 of file EncoderLocal.cpp.

◆ getEncoderType()

EncoderType EncoderLocal::getEncoderType ( )
virtual

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

Reimplemented from Encoder.

Definition at line 70 of file EncoderLocal.cpp.

◆ getHelpstring()

std::string EncoderLocal::getHelpstring ( )
inlinevirtual

Returns a description of this class

Reimplemented from CommandHandler.

Definition at line 54 of file EncoderLocal.h.

◆ getInfo()

const ClassIdentifier EncoderLocal::getInfo ( )
virtual

Command handlers always have class infos. Works well with ChoosableClass.

Implements CommandHandler.

Definition at line 16 of file EncoderLocal.cpp.

◆ getPos()

int32_t EncoderLocal::getPos ( )
virtual

Returns the encoder position as raw counts

Reimplemented from Encoder.

Definition at line 75 of file EncoderLocal.cpp.

◆ getTimerCount()

int32_t EncoderLocal::getTimerCount ( )

Definition at line 66 of file EncoderLocal.cpp.

◆ isCreatable()

static bool EncoderLocal::isCreatable ( )
inlinestatic

Definition at line 32 of file EncoderLocal.h.

◆ overflowCallback()

void EncoderLocal::overflowCallback ( )

Definition at line 121 of file EncoderLocal.cpp.

◆ registerCommands()

void EncoderLocal::registerCommands ( )

Definition at line 35 of file EncoderLocal.cpp.

◆ restoreFlash()

void EncoderLocal::restoreFlash ( )
virtual

Should be implemented to restore settings. This is not automatically called and should be called when appropriate.

Reimplemented from PersistentStorage.

Definition at line 53 of file EncoderLocal.cpp.

◆ saveFlash()

void EncoderLocal::saveFlash ( )
virtual

Called when the user uses the "save" command and presses the save button in the configurator Automatically called by the command parser thread for every class that inherits from PersistentStorage

Reimplemented from PersistentStorage.

Definition at line 47 of file EncoderLocal.cpp.

◆ setCpr()

void EncoderLocal::setCpr ( uint32_t  cpr)

Definition at line 129 of file EncoderLocal.cpp.

◆ setPeriod()

void EncoderLocal::setPeriod ( uint32_t  period)

Definition at line 94 of file EncoderLocal.cpp.

◆ setPos()

void EncoderLocal::setPos ( int32_t  pos)
virtual

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

Reimplemented from Encoder.

Definition at line 79 of file EncoderLocal.cpp.

◆ timerElapsed()

void EncoderLocal::timerElapsed ( TIM_HandleTypeDef *  htim)
virtual

Reimplemented from TimerHandler.

Definition at line 115 of file EncoderLocal.cpp.

Member Data Documentation

◆ htim

TIM_HandleTypeDef* EncoderLocal::htim
private

Definition at line 60 of file EncoderLocal.h.

◆ indexHit

bool EncoderLocal::indexHit = false
private

Definition at line 65 of file EncoderLocal.h.

◆ indexpos

uint32_t EncoderLocal::indexpos = 0
private

Definition at line 63 of file EncoderLocal.h.

◆ info

ClassIdentifier EncoderLocal::info
static
Initial value:
= {
.name = "Local ABN" ,
.id=CLSID_ENCODER_LOCAL,
}

Definition at line 30 of file EncoderLocal.h.

◆ inUse

bool EncoderLocal::inUse = false
static

Definition at line 29 of file EncoderLocal.h.

◆ offset

int16_t EncoderLocal::offset = 0
private

Definition at line 61 of file EncoderLocal.h.

◆ pos

int32_t EncoderLocal::pos = 0
private

Definition at line 62 of file EncoderLocal.h.

◆ useIndex

bool EncoderLocal::useIndex = false
private

Definition at line 66 of file EncoderLocal.h.


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