![]() |
Open FFBoard
Open source force feedback firmware
|
#include <SerialFFB.h>
Public Member Functions | |
SerialFFB (std::shared_ptr< EffectsCalculator > ec, uint8_t instance=0) | |
virtual | ~SerialFFB () |
CommandStatus | command (const ParsedCommand &cmd, std::vector< CommandReply > &replies) |
const ClassIdentifier | getInfo () |
Command handlers always have class infos. Works well with ChoosableClass. More... | |
bool | getFfbActive () |
void | reset_ffb () |
void | set_FFB (bool state) |
void | set_gain (uint8_t gain) |
int32_t | newEffect (uint8_t effectType) |
void | setMagnitude (uint8_t idx, int16_t magnitude) |
void | setEffectState (uint8_t id, bool state) |
![]() | |
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 | getHelpstring () |
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 CmdHandlerInfo * | getCommandHandlerInfo () |
virtual bool | isValidCommandId (uint32_t cmdid, uint32_t ignoredFlags=0, uint32_t requiredFlag=0) |
virtual CmdHandlerCommanddef * | getCommandFromName (const std::string &cmd, uint32_t ignoredFlags=0) |
virtual CmdHandlerCommanddef * | getCommandFromId (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) |
![]() | |
virtual void | stop_FFB () |
virtual void | start_FFB () |
virtual uint32_t | getConstantForceRate () |
virtual uint32_t | getRate () |
virtual void | cfUpdateEvent () |
virtual void | fxUpdateEvent () |
Private Types | |
enum class | SerialEffects_commands : uint32_t { ffbstate , ffbreset , newEffect , fxtype , fxmagnitude , fxstate , fxperiod , fxduration , fxoffset , fxdeadzone , fxsat , fxcoeff , fxaxisgain } |
Private Attributes | |
std::shared_ptr< EffectsCalculator > | effects_calc |
std::array< FFB_Effect, EffectsCalculator::max_effects > & | effects |
Static Private Attributes | |
static ClassIdentifier | info |
static constexpr FFB_Effect_Condition | defaultCond |
Additional Inherited Members | |
![]() | |
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 CommandHandler * | getHandlerFromHandlerId (const uint16_t cmdhandlerID) |
static CommandHandler * | getHandlerFromId (const uint16_t id, const uint8_t instance=0xFF) |
static CommandHandler * | getHandlerFromClassName (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 bool | logEnabled = true |
![]() | |
void | setInstance (uint8_t instance) |
virtual void | addCommandHandler () |
virtual void | removeCommandHandler () |
![]() | |
static std::vector< uint16_t > & | getCommandHandlerIds () |
![]() | |
bool | commandsEnabled = true |
std::vector< CmdHandlerCommanddef > | registeredCommands |
CmdHandlerInfo | cmdHandlerInfo |
Helper class to manage the effectscalculator effects via commands directly
Definition at line 17 of file SerialFFB.h.
|
strongprivate |
Enumerator | |
---|---|
ffbstate | |
ffbreset | |
newEffect | |
fxtype | |
fxmagnitude | |
fxstate | |
fxperiod | |
fxduration | |
fxoffset | |
fxdeadzone | |
fxsat | |
fxcoeff | |
fxaxisgain |
Definition at line 19 of file SerialFFB.h.
SerialFFB::SerialFFB | ( | std::shared_ptr< EffectsCalculator > | ec, |
uint8_t | instance = 0 |
||
) |
Creates an interface to control standard PID effects via commands
Definition at line 22 of file SerialFFB.cpp.
|
virtual |
Definition at line 40 of file SerialFFB.cpp.
|
virtual |
[in] | cmd | The parsed command to be executed. |
[out] | replies | A 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 124 of file SerialFFB.cpp.
|
virtual |
Implements EffectsControlItf.
Definition at line 45 of file SerialFFB.cpp.
|
virtual |
Command handlers always have class infos. Works well with ChoosableClass.
Implements CommandHandler.
Definition at line 15 of file SerialFFB.cpp.
int32_t SerialFFB::newEffect | ( | uint8_t | effectType | ) |
Takes an effect type and allocates it in the effects array Returns the index where the effect was created or -1 if it can not be created
Definition at line 76 of file SerialFFB.cpp.
|
virtual |
Resets all effects and disables ffb
Implements EffectsControlItf.
Definition at line 52 of file SerialFFB.cpp.
|
virtual |
Enables or disables FFB actuator
Implements EffectsControlItf.
Definition at line 62 of file SerialFFB.cpp.
|
virtual |
Changes the global gain scaler
Implements EffectsControlItf.
Definition at line 68 of file SerialFFB.cpp.
void SerialFFB::setEffectState | ( | uint8_t | id, |
bool | state | ||
) |
Enables or disables an effect
Definition at line 114 of file SerialFFB.cpp.
void SerialFFB::setMagnitude | ( | uint8_t | idx, |
int16_t | magnitude | ||
) |
Changes magnitude of non conditional effects (Constant, ramp, square, triangle, sawtooth)
Definition at line 95 of file SerialFFB.cpp.
|
staticconstexprprivate |
Definition at line 46 of file SerialFFB.h.
|
private |
Definition at line 44 of file SerialFFB.h.
|
private |
Definition at line 43 of file SerialFFB.h.
|
staticprivate |
Definition at line 42 of file SerialFFB.h.