![]() |
Open FFBoard
Open source force feedback firmware
|
#include <EffectsCalculator.h>
Public Member Functions | |
| EffectsCalculator () | |
| virtual | ~EffectsCalculator () |
| const ClassIdentifier | getInfo () |
| Command handlers always have class infos. Works well with ChoosableClass. | |
| const ClassType | getClassType () override |
| void | saveFlash () |
| void | restoreFlash () |
| bool | isActive () |
| void | setActive (bool active) |
| void | calculateEffects (std::vector< std::unique_ptr< Axis > > &axes) |
| virtual void | setFilters (FFB_Effect *effect) |
| void | setGain (uint8_t gain) |
| uint8_t | getGain () |
| void | logEffectType (uint8_t type, bool remove=false) |
| void | calcStatsEffectType (uint8_t type, int32_t force, uint8_t axis) |
| void | logEffectState (uint8_t type, uint8_t state) |
| void | resetLoggedActiveEffects (bool reinit) |
| int32_t | find_free_effect (uint8_t type) |
| void | free_effect (uint16_t idx) |
| CommandStatus | command (const ParsedCommand &cmd, std::vector< CommandReply > &replies) |
| virtual std::string | getHelpstring () |
| void | Run () |
| void | updateSamplerate (float newSamplerate) |
Public Member Functions inherited from PersistentStorage | |
| PersistentStorage () | |
| virtual | ~PersistentStorage () |
| void | restoreFlashDelayed () |
Public Member Functions inherited from CommandHandler | |
| 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 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 | postCmdhandlerInit () |
| template<typename ID> | |
| void | overrideCommandFlags (const ID cmdid, uint32_t flagmask=0) |
Public Attributes | |
| std::array< FFB_Effect, max_effects > | effects |
Static Public Attributes | |
| static ClassIdentifier | info |
| static const uint32_t | max_effects = MAX_EFFECTS |
Static Public Attributes inherited from CommandHandler | |
| static bool | logEnabled = true |
Private Member Functions | |
| int32_t | calcComponentForce (FFB_Effect *effect, int32_t forceVector, std::vector< std::unique_ptr< Axis > > &axes, uint8_t axis) |
| int32_t | calcNonConditionEffectForce (FFB_Effect *effect) |
| float | speedRampupPct () |
| int32_t | calcConditionEffectForce (FFB_Effect *effect, float metric, uint8_t gain, uint8_t idx, float scale, float angle_ratio) |
| int32_t | getEnvelopeMagnitude (FFB_Effect *effect) |
| std::string | listEffectsUsed (bool details=false, uint8_t axis=0) |
| void | checkFilterCoeff (biquad_constant_t *filter, uint32_t freq, uint8_t q) |
| void | updateFilterSettingsForEffects (uint8_t type_effect) |
Private Member Functions inherited from cpp_freertos::Thread | |
| Thread (const std::string Name, uint16_t StackDepth, UBaseType_t Priority) | |
| Thread (const char *Name, uint16_t StackDepth, UBaseType_t Priority) | |
| Thread (uint16_t StackDepth, UBaseType_t Priority) | |
| bool | Start () |
| virtual | ~Thread () |
| TaskHandle_t | GetHandle () |
| void | Suspend () |
| void | Resume () |
| void | ResumeFromISR () |
| void | Notify () |
| void | NotifyFromISR () |
| uint32_t | WaitForNotification (TickType_t Timeout=portMAX_DELAY) |
| UBaseType_t | GetPriority () |
| UBaseType_t | GetPriorityFromISR () |
| void | SetPriority (UBaseType_t NewPriority) |
| std::string | GetName () |
| char * | GetName () |
| virtual void | Cleanup () |
| void | Delay (const TickType_t Delay) |
| void | DelayUntil (const TickType_t Period) |
| void | ResetDelayUntil () |
| bool | Wait (ConditionVariable &Cv, Mutex &CvLock, TickType_t Timeout=portMAX_DELAY) |
Private Attributes | |
| effect_biquad_t | filter [2] |
| uint8_t | filterProfileId = 0 |
| uint32_t | calcfrequency = 1000 |
| const float | qfloatScaler = 0.01 |
| uint8_t | global_gain = 0xff |
| effect_gain_t | gain |
| effect_scaler_t | scaler |
| uint8_t | frictionPctSpeedToRampup = 25 |
| bool | effects_active = false |
| uint32_t | effects_used = 0 |
| std::array< effect_stat_t, 12 > | effects_stats |
| std::array< effect_stat_t, 12 > | effects_statslast |
| bool | isMonitorEffect = false |
Additional Inherited Members | |
Static Public Member Functions inherited from PersistentStorage | |
| static std::vector< PersistentStorage * > & | getFlashHandlers () |
| static void | restoreFlashStartupCb () |
Static Public Member Functions inherited from CommandHandler | |
| static void | logSerial (std::string string) |
| Send a log formatted sequence. | |
| static void | logSerialDebug (std::string string) |
| Send a log formatted sequence if debug is on. | |
| 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) |
Protected Member Functions inherited from CommandHandler | |
| void | setInstance (uint8_t instance) |
| virtual void | addCommandHandler () |
| virtual void | removeCommandHandler () |
| void | registerCommand_INT (const char *cmd, const uint32_t cmdid, const char *help=nullptr, uint32_t flags=0) |
| void | overrideCommandFlags_INT (const uint32_t cmdid, uint32_t flagmask=CMDFLAG_GET|CMDFLAG_GETADR) |
Static Protected Member Functions inherited from CommandHandler | |
| static std::vector< uint16_t > & | getCommandHandlerIds () |
Protected Attributes inherited from PersistentStorage | |
| bool | restoreDelayedFlag = false |
Protected Attributes inherited from CommandHandler | |
| bool | commandsEnabled = true |
| std::vector< CmdHandlerCommanddef > | registeredCommands |
| CmdHandlerInfo | cmdHandlerInfo |
Static Protected Attributes inherited from PersistentStorage | |
| static bool | startupComplete = false |
Static Private Member Functions inherited from cpp_freertos::Thread | |
| static void | Yield () |
| static void | StartScheduler () |
| static void | EndScheduler () |
Definition at line 65 of file EffectsCalculator.h.
| EffectsCalculator::EffectsCalculator | ( | ) |
Definition at line 26 of file EffectsCalculator.cpp.
|
virtual |
Definition at line 56 of file EffectsCalculator.cpp.
|
private |
Calculates the force of an effect
| (rampup is from 0..5% of max velocity) | __________ (after use max coefficient) | / | / |- ---------------------— Velocity -| / | / | ----— | |
Definition at line 288 of file EffectsCalculator.cpp.
|
private |
Calculates a conditional effect Takes care of deadband and offsets and scalers Gain of 255 = 1x. Prescale with scale factor
Definition at line 416 of file EffectsCalculator.cpp.
|
private |
Calculates forces from a non conditional effect Periodic and constant effects
Definition at line 173 of file EffectsCalculator.cpp.
| void EffectsCalculator::calcStatsEffectType | ( | uint8_t | type, |
| int32_t | force, | ||
| uint8_t | axis ) |
Definition at line 681 of file EffectsCalculator.cpp.
| void EffectsCalculator::calculateEffects | ( | std::vector< std::unique_ptr< Axis > > & | axes | ) |
Calculates the resulting torque for FFB effects Takes current position input scaled from -0x7fff to 0x7fff Outputs a torque value from -0x7fff to 0x7fff (not yet clipped)
Definition at line 104 of file EffectsCalculator.cpp.
|
private |
Definition at line 623 of file EffectsCalculator.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 746 of file EffectsCalculator.cpp.
| int32_t EffectsCalculator::find_free_effect | ( | uint8_t | type | ) |
Will return the first effect index which is empty or -1 if none found
Definition at line 994 of file EffectsCalculator.cpp.
| void EffectsCalculator::free_effect | ( | uint16_t | idx | ) |
Resets an effect and marks the effect as free
Definition at line 979 of file EffectsCalculator.cpp.
|
inlineoverridevirtual |
Type of this class. Mainclass, motordriver... Should be implemented by the parent class so it is not in the info struct
Reimplemented from CommandHandler.
Definition at line 74 of file EffectsCalculator.h.
|
private |
Modulates the magnitude of an effect based on time and attack/fade levels During attack time the strength changes from the initial attack level to the normal magnitude which is sustained until the fade time where the strength changes to the fade level until the stop time of the effect. Infinite effects can't have an envelope and return the normal magnitude.
Definition at line 450 of file EffectsCalculator.cpp.
| uint8_t EffectsCalculator::getGain | ( | ) |
Definition at line 525 of file EffectsCalculator.cpp.
|
inlinevirtual |
Returns a description of this class
Reimplemented from CommandHandler.
Definition at line 95 of file EffectsCalculator.h.
|
virtual |
Command handlers always have class infos. Works well with ChoosableClass.
Implements CommandHandler.
Definition at line 22 of file EffectsCalculator.cpp.
| bool EffectsCalculator::isActive | ( | ) |
Definition at line 62 of file EffectsCalculator.cpp.
|
private |
Prints a list of effects that were active at some point Does not reset when an effect is deactivated Axis only used in detail mode
Definition at line 696 of file EffectsCalculator.cpp.
| void EffectsCalculator::logEffectState | ( | uint8_t | type, |
| uint8_t | state ) |
Definition at line 671 of file EffectsCalculator.cpp.
| void EffectsCalculator::logEffectType | ( | uint8_t | type, |
| bool | remove = false ) |
Definition at line 650 of file EffectsCalculator.cpp.
| void EffectsCalculator::resetLoggedActiveEffects | ( | bool | reinit | ) |
Resets the effects_used flags If reinit is true it will set the flag again if the currently active effect number is not 0
Definition at line 735 of file EffectsCalculator.cpp.
|
virtual |
Should be implemented to restore settings. This is not automatically called and should be called when appropriate.
Reimplemented from PersistentStorage.
Definition at line 532 of file EffectsCalculator.cpp.
|
virtual |
Implementation of your actual thread code. You must override this function.
Implements cpp_freertos::Thread.
Definition at line 955 of file EffectsCalculator.cpp.
|
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 584 of file EffectsCalculator.cpp.
| void EffectsCalculator::setActive | ( | bool | active | ) |
Definition at line 66 of file EffectsCalculator.cpp.
|
virtual |
Definition at line 473 of file EffectsCalculator.cpp.
| void EffectsCalculator::setGain | ( | uint8_t | gain | ) |
Definition at line 520 of file EffectsCalculator.cpp.
|
private |
Definition at line 406 of file EffectsCalculator.cpp.
|
private |
Definition at line 637 of file EffectsCalculator.cpp.
| void EffectsCalculator::updateSamplerate | ( | float | newSamplerate | ) |
Definition at line 77 of file EffectsCalculator.cpp.
|
private |
Definition at line 113 of file EffectsCalculator.h.
| std::array<FFB_Effect,max_effects> EffectsCalculator::effects |
Definition at line 98 of file EffectsCalculator.h.
|
private |
Definition at line 123 of file EffectsCalculator.h.
|
private |
Definition at line 125 of file EffectsCalculator.h.
|
private |
Definition at line 126 of file EffectsCalculator.h.
|
private |
Definition at line 124 of file EffectsCalculator.h.
|
private |
Definition at line 111 of file EffectsCalculator.h.
|
private |
Definition at line 112 of file EffectsCalculator.h.
|
private |
Definition at line 120 of file EffectsCalculator.h.
|
private |
Definition at line 118 of file EffectsCalculator.h.
|
private |
Definition at line 117 of file EffectsCalculator.h.
|
static |
Definition at line 17 of file EffectsCalculator.h.
|
private |
Definition at line 127 of file EffectsCalculator.h.
|
static |
Definition at line 97 of file EffectsCalculator.h.
|
private |
Definition at line 114 of file EffectsCalculator.h.
|
private |
Definition at line 119 of file EffectsCalculator.h.