![]() |
Open FFBoard
Open source force feedback firmware
|
#include <ShifterAnalog.h>
Classes | |
class | G27ShifterButtonClient |
Public Member Functions | |
ShifterAnalog () | |
virtual | ~ShifterAnalog () |
const ClassIdentifier | getInfo () |
uint8_t | readButtons (uint64_t *buf) override |
uint16_t | getBtnNum () |
void | saveFlash () override |
void | restoreFlash () override |
std::string | printModes () |
CommandStatus | command (const ParsedCommand &cmd, std::vector< CommandReply > &replies) override |
void | registerCommands () |
virtual std::string | getHelpstring () |
const ClassType | getClassType () override |
returns the used classchooser selection id of this instance More... | |
![]() | |
ButtonSource () | |
virtual | ~ButtonSource () |
![]() | |
virtual | ~ChoosableClass () |
uint16_t | getSelectionID () |
![]() | |
PersistentStorage () | |
virtual | ~PersistentStorage () |
void | restoreFlashDelayed () |
Static Public Member Functions | |
static bool | isCreatable () |
![]() | |
static bool | isCreatable () |
![]() | |
static bool | isCreatable () |
![]() | |
static std::vector< PersistentStorage * > & | getFlashHandlers () |
static void | restoreFlashStartupCb () |
Public Attributes | |
const std::array< std::string, number_of_modes > | mode_names {"G29-H","G29 Sequential","G27-H","G27 Sequential"} |
Static Public Attributes | |
static constexpr int | number_of_modes {4} |
static constexpr std::array< bool, number_of_modes > | mode_uses_spi {false, false, true, true} |
static constexpr std::array< bool, number_of_modes > | mode_uses_local_reverse {true, true, false, false} |
static ClassIdentifier | info |
![]() | |
static ClassIdentifier | info |
static const std::vector< class_entry< ButtonSource > > | all_buttonsources |
![]() | |
static ClassIdentifier | info |
Private Types | |
enum class | ShifterMode : uint8_t { G29_H =0 , G29_seq =1 , G27_H =2 , G27_seq =3 } |
enum class | ShifterAnalog_commands : uint32_t { mode , x12 , x56 , y135 , y246 , revbtn , cspin , xchan , ychan , vals , gear } |
Private Member Functions | |
void | updateAdc () |
void | setMode (ShifterMode newMode) |
void | setCSPin (uint8_t new_cs_pin_num) |
void | calculateGear () |
void | updateReverseState () |
int | getUserButtons (uint64_t *buf) |
![]() | |
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) |
void | setInstance (uint8_t instance) |
virtual void | addCommandHandler () |
virtual void | removeCommandHandler () |
Static Private Member Functions | |
static bool | isG27Mode (ShifterMode m) |
![]() | |
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 std::vector< uint16_t > & | getCommandHandlerIds () |
Private Attributes | |
ShifterMode | mode |
uint8_t | x_chan {6} |
uint8_t | y_chan {5} |
uint8_t | reverseButtonNum {1} |
uint8_t | cs_pin_num {1} |
uint16_t | X_12 {25600} |
uint16_t | X_56 {40000} |
uint16_t | Y_135 {51200} |
uint16_t | Y_246 {13600} |
uint16_t | x_val {0} |
uint16_t | y_val {0} |
bool | reverseButtonState {false} |
uint8_t | gear {0} |
uint8_t | bitshift = 0 |
std::unique_ptr< G27ShifterButtonClient > | g27ShifterButtonClient |
![]() | |
bool | commandsEnabled = true |
std::vector< CmdHandlerCommanddef > | registeredCommands |
CmdHandlerInfo | cmdHandlerInfo |
Additional Inherited Members | |
![]() | |
uint16_t | btnnum = 0 |
![]() | |
uint16_t | selectionId |
Should only be written by ClassChooser during creation. More... | |
![]() | |
bool | restoreDelayedFlag = false |
![]() | |
static bool | startupComplete = false |
![]() | |
static bool | logEnabled = true |
Button mapper for analog (Logitech G2x) shifters (6 gears + reverse) optionally SPI buttons on G27.
Connection: X-Axis: mappable analog Y-Axis: mappable analog Reverse Button: mappable digital for G29, SPI button for G27.
Definition at line 27 of file ShifterAnalog.h.
|
strongprivate |
Enumerator | |
---|---|
mode | |
x12 | |
x56 | |
y135 | |
y246 | |
revbtn | |
cspin | |
xchan | |
ychan | |
vals | |
gear |
Definition at line 31 of file ShifterAnalog.h.
|
strongprivate |
Enumerator | |
---|---|
G29_H | |
G29_seq | |
G27_H | |
G27_seq |
Definition at line 29 of file ShifterAnalog.h.
ShifterAnalog::ShifterAnalog | ( | ) |
Definition at line 24 of file ShifterAnalog.cpp.
|
virtual |
Definition at line 32 of file ShifterAnalog.cpp.
|
private |
Definition at line 59 of file ShifterAnalog.cpp.
|
overridevirtual |
[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 218 of file ShifterAnalog.cpp.
|
virtual |
Reimplemented from ButtonSource.
Definition at line 139 of file ShifterAnalog.cpp.
|
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 ButtonSource.
Definition at line 59 of file ShifterAnalog.h.
|
inlinevirtual |
Returns a description of this class
Reimplemented from CommandHandler.
Definition at line 58 of file ShifterAnalog.h.
|
virtual |
Implements ButtonSource.
Definition at line 20 of file ShifterAnalog.cpp.
|
private |
Definition at line 112 of file ShifterAnalog.cpp.
|
inlinestatic |
Definition at line 46 of file ShifterAnalog.h.
|
staticprivate |
Definition at line 188 of file ShifterAnalog.cpp.
std::string ShifterAnalog::printModes | ( | ) |
Definition at line 180 of file ShifterAnalog.cpp.
|
overridevirtual |
Return a bit field without offset of pressed buttons in the supplied buffer. Returns amount of button read.
Implements ButtonSource.
Definition at line 121 of file ShifterAnalog.cpp.
void ShifterAnalog::registerCommands | ( | ) |
Definition at line 36 of file ShifterAnalog.cpp.
|
overridevirtual |
Should be implemented to restore settings. This is not automatically called and should be called when appropriate.
Reimplemented from PersistentStorage.
Definition at line 168 of file ShifterAnalog.cpp.
|
overridevirtual |
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 157 of file ShifterAnalog.cpp.
|
private |
Definition at line 204 of file ShifterAnalog.cpp.
|
private |
Definition at line 192 of file ShifterAnalog.cpp.
|
private |
Definition at line 52 of file ShifterAnalog.cpp.
|
private |
Definition at line 104 of file ShifterAnalog.cpp.
|
private |
Definition at line 92 of file ShifterAnalog.h.
|
private |
Definition at line 79 of file ShifterAnalog.h.
|
private |
Definition at line 94 of file ShifterAnalog.h.
|
private |
Definition at line 90 of file ShifterAnalog.h.
|
static |
Definition at line 45 of file ShifterAnalog.h.
|
private |
Definition at line 74 of file ShifterAnalog.h.
const std::array<std::string, number_of_modes> ShifterAnalog::mode_names {"G29-H","G29 Sequential","G27-H","G27 Sequential"} |
Definition at line 37 of file ShifterAnalog.h.
|
staticconstexpr |
Definition at line 39 of file ShifterAnalog.h.
|
staticconstexpr |
Definition at line 38 of file ShifterAnalog.h.
|
staticconstexpr |
Definition at line 36 of file ShifterAnalog.h.
|
private |
Definition at line 78 of file ShifterAnalog.h.
|
private |
Definition at line 89 of file ShifterAnalog.h.
|
private |
Definition at line 82 of file ShifterAnalog.h.
|
private |
Definition at line 83 of file ShifterAnalog.h.
|
private |
Definition at line 76 of file ShifterAnalog.h.
|
private |
Definition at line 87 of file ShifterAnalog.h.
|
private |
Definition at line 84 of file ShifterAnalog.h.
|
private |
Definition at line 85 of file ShifterAnalog.h.
|
private |
Definition at line 77 of file ShifterAnalog.h.
|
private |
Definition at line 88 of file ShifterAnalog.h.