![]() |
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. More... | |
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, int16_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 () |
![]() | |
PersistentStorage () | |
virtual | ~PersistentStorage () |
void | restoreFlashDelayed () |
![]() | |
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) |
Public Attributes | |
std::array< FFB_Effect, max_effects > | effects |
Static Public Attributes | |
static ClassIdentifier | info |
static const uint32_t | max_effects = MAX_EFFECTS |
![]() | |
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) |
![]() | |
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 |
const 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 std::vector< PersistentStorage * > & | getFlashHandlers () |
static void | restoreFlashStartupCb () |
![]() | |
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) |
![]() | |
void | setInstance (uint8_t instance) |
virtual void | addCommandHandler () |
virtual void | removeCommandHandler () |
![]() | |
static std::vector< uint16_t > & | getCommandHandlerIds () |
![]() | |
bool | restoreDelayedFlag = false |
![]() | |
bool | commandsEnabled = true |
std::vector< CmdHandlerCommanddef > | registeredCommands |
CmdHandlerInfo | cmdHandlerInfo |
![]() | |
static bool | startupComplete = false |
![]() | |
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 279 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 407 of file EffectsCalculator.cpp.
|
private |
Calculates forces from a non conditional effect Periodic and constant effects
Definition at line 164 of file EffectsCalculator.cpp.
void EffectsCalculator::calcStatsEffectType | ( | uint8_t | type, |
int16_t | force, | ||
uint8_t | axis | ||
) |
Definition at line 672 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 95 of file EffectsCalculator.cpp.
|
private |
Definition at line 614 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 737 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 985 of file EffectsCalculator.cpp.
void EffectsCalculator::free_effect | ( | uint16_t | idx | ) |
Resets an effect and marks the effect as free
Definition at line 970 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 441 of file EffectsCalculator.cpp.
uint8_t EffectsCalculator::getGain | ( | ) |
Definition at line 516 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 687 of file EffectsCalculator.cpp.
void EffectsCalculator::logEffectState | ( | uint8_t | type, |
uint8_t | state | ||
) |
Definition at line 662 of file EffectsCalculator.cpp.
void EffectsCalculator::logEffectType | ( | uint8_t | type, |
bool | remove = false |
||
) |
Definition at line 641 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 726 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 523 of file EffectsCalculator.cpp.
|
virtual |
Implementation of your actual thread code. You must override this function.
Implements cpp_freertos::Thread.
Definition at line 946 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 575 of file EffectsCalculator.cpp.
void EffectsCalculator::setActive | ( | bool | active | ) |
Definition at line 66 of file EffectsCalculator.cpp.
|
virtual |
Definition at line 464 of file EffectsCalculator.cpp.
void EffectsCalculator::setGain | ( | uint8_t | gain | ) |
Definition at line 511 of file EffectsCalculator.cpp.
|
private |
Definition at line 397 of file EffectsCalculator.cpp.
|
private |
Definition at line 628 of file EffectsCalculator.cpp.
|
private |
Definition at line 111 of file EffectsCalculator.h.
std::array<FFB_Effect,max_effects> EffectsCalculator::effects |
Definition at line 98 of file EffectsCalculator.h.
|
private |
Definition at line 121 of file EffectsCalculator.h.
|
private |
Definition at line 123 of file EffectsCalculator.h.
|
private |
Definition at line 124 of file EffectsCalculator.h.
|
private |
Definition at line 122 of file EffectsCalculator.h.
|
private |
Definition at line 109 of file EffectsCalculator.h.
|
private |
Definition at line 110 of file EffectsCalculator.h.
|
private |
Definition at line 118 of file EffectsCalculator.h.
|
private |
Definition at line 116 of file EffectsCalculator.h.
|
private |
Definition at line 115 of file EffectsCalculator.h.
|
static |
Definition at line 72 of file EffectsCalculator.h.
|
private |
Definition at line 125 of file EffectsCalculator.h.
|
static |
Definition at line 97 of file EffectsCalculator.h.
|
private |
Definition at line 112 of file EffectsCalculator.h.
|
private |
Definition at line 117 of file EffectsCalculator.h.