Open FFBoard
Open source force feedback firmware
PCF8574Buttons Class Reference

#include <PCF8574.h>

Inheritance diagram for PCF8574Buttons:
PCF8574 CommandHandler ButtonSource cpp_freertos::Thread I2CDevice ChoosableClass PersistentStorage

Public Types

enum class  PCF8574Buttons_commands : uint32_t { btnnum , invert , speed }
 

Public Member Functions

 PCF8574Buttons ()
 
virtual ~PCF8574Buttons ()
 
void Run ()
 
void saveFlash ()
 
void restoreFlash ()
 
void i2cRxCompleted (I2CPort *port)
 
void i2cError (I2CPort *port)
 
CommandStatus command (const ParsedCommand &cmd, std::vector< CommandReply > &replies) override
 
uint8_t readButtons (uint64_t *buf)
 
uint16_t getBtnNum ()
 
void setBtnNum (uint8_t num)
 
virtual const ClassIdentifier getInfo ()
 
const ClassType getClassType () override
 returns the used classchooser selection id of this instance More...
 
std::string getHelpstring ()
 
void rxDone (uint8_t dat)
 
- Public Member Functions inherited from PCF8574
 PCF8574 (I2CPort &port)
 
virtual ~PCF8574 ()
 
uint8_t readByte (const uint8_t devAddr)
 
void readByteIT (const uint8_t devAddr, uint8_t *data)
 
void writeByteIT (const uint8_t devAddr, uint8_t *data)
 
void writeByte (const uint8_t devAddr, uint8_t data)
 
- Public Member Functions inherited from I2CDevice
 I2CDevice ()
 
virtual ~I2CDevice ()
 
virtual void startI2CTransfer (I2CPort *port)
 
virtual void endI2CTransfer (I2CPort *port)
 
virtual void i2cTxCompleted (I2CPort *port)
 
- 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 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 ButtonSource
 ButtonSource ()
 
virtual ~ButtonSource ()
 
- Public Member Functions inherited from ChoosableClass
virtual ~ChoosableClass ()
 
uint16_t getSelectionID ()
 
- Public Member Functions inherited from PersistentStorage
 PersistentStorage ()
 
virtual ~PersistentStorage ()
 
void restoreFlashDelayed ()
 
- Public 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 ()
 

Static Public Member Functions

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 ButtonSource
static bool isCreatable ()
 
- Static Public Member Functions inherited from ChoosableClass
static bool isCreatable ()
 
- Static Public Member Functions inherited from PersistentStorage
static std::vector< PersistentStorage * > & getFlashHandlers ()
 
static void restoreFlashStartupCb ()
 
- Static Public Member Functions inherited from cpp_freertos::Thread
static void Yield ()
 
static void StartScheduler ()
 
static void EndScheduler ()
 

Static Public Attributes

static ClassIdentifier info
 
- Static Public Attributes inherited from CommandHandler
static bool logEnabled = true
 
- Static Public Attributes inherited from ButtonSource
static ClassIdentifier info
 
static const std::vector< class_entry< ButtonSource > > all_buttonsources
 
- Static Public Attributes inherited from ChoosableClass
static ClassIdentifier info
 

Private Attributes

bool invert = true
 
uint8_t numBytes = 1
 
uint64_t mask = 0xff
 
uint64_t lastButtons = 0
 
uint64_t currentButtons = 0
 
uint8_t lastByte =0
 
uint8_t lastData =0
 
uint32_t lastSuccess =0
 
const uint32_t timeout = 250
 
volatile bool readingData = false
 

Additional Inherited Members

- Protected Member Functions inherited from CommandHandler
void setInstance (uint8_t instance)
 
virtual void addCommandHandler ()
 
virtual void removeCommandHandler ()
 
- Protected Member Functions inherited from cpp_freertos::Thread
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)
 
- Static Protected Member Functions inherited from CommandHandler
static std::vector< uint16_t > & getCommandHandlerIds ()
 
- Protected Attributes inherited from PCF8574
I2CPortport
 
- Protected Attributes inherited from CommandHandler
bool commandsEnabled = true
 
std::vector< CmdHandlerCommanddefregisteredCommands
 
CmdHandlerInfo cmdHandlerInfo
 
- Protected Attributes inherited from ButtonSource
uint16_t btnnum = 0
 
- Protected Attributes inherited from ChoosableClass
uint16_t selectionId
 Should only be written by ClassChooser during creation. More...
 
- Protected Attributes inherited from PersistentStorage
bool restoreDelayedFlag = false
 
- Static Protected Attributes inherited from PersistentStorage
static bool startupComplete = false
 

Detailed Description

Definition at line 50 of file PCF8574.h.

Member Enumeration Documentation

◆ PCF8574Buttons_commands

enum class PCF8574Buttons::PCF8574Buttons_commands : uint32_t
strong
Enumerator
btnnum 
invert 
speed 

Definition at line 55 of file PCF8574.h.

Constructor & Destructor Documentation

◆ PCF8574Buttons()

PCF8574Buttons::PCF8574Buttons ( )

Definition at line 71 of file PCF8574.cpp.

◆ ~PCF8574Buttons()

PCF8574Buttons::~PCF8574Buttons ( )
virtual

Definition at line 82 of file PCF8574.cpp.

Member Function Documentation

◆ command()

CommandStatus PCF8574Buttons::command ( const ParsedCommand cmd,
std::vector< CommandReply > &  replies 
)
overridevirtual
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 186 of file PCF8574.cpp.

◆ getBtnNum()

uint16_t PCF8574Buttons::getBtnNum ( )
virtual

Reimplemented from ButtonSource.

Definition at line 163 of file PCF8574.cpp.

◆ getClassType()

const ClassType PCF8574Buttons::getClassType ( )
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 76 of file PCF8574.h.

◆ getHelpstring()

std::string PCF8574Buttons::getHelpstring ( )
inlinevirtual

Returns a description of this class

Reimplemented from CommandHandler.

Definition at line 78 of file PCF8574.h.

◆ getInfo()

const ClassIdentifier PCF8574Buttons::getInfo ( )
virtual

Implements ButtonSource.

Definition at line 66 of file PCF8574.cpp.

◆ i2cError()

void PCF8574Buttons::i2cError ( I2CPort port)
virtual

Reimplemented from I2CDevice.

Definition at line 130 of file PCF8574.cpp.

◆ i2cRxCompleted()

void PCF8574Buttons::i2cRxCompleted ( I2CPort port)
virtual

Reimplemented from I2CDevice.

Definition at line 103 of file PCF8574.cpp.

◆ isCreatable()

static bool PCF8574Buttons::isCreatable ( )
inlinestatic

Definition at line 74 of file PCF8574.h.

◆ readButtons()

uint8_t PCF8574Buttons::readButtons ( uint64_t *  buf)
virtual

Return a bit field without offset of pressed buttons in the supplied buffer. Returns amount of button read.

Implements ButtonSource.

Definition at line 136 of file PCF8574.cpp.

◆ restoreFlash()

void PCF8574Buttons::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 120 of file PCF8574.cpp.

◆ Run()

void PCF8574Buttons::Run ( )
virtual

Implementation of your actual thread code. You must override this function.

Note
If INCLUDE_vTaskDelete is defined, then you may return from your Run method. This will cause the task to be deleted from FreeRTOS, however you are still responsible to delete the task object. If this is not defined, then retuning from your Run() method will result in an assert.

Implements cpp_freertos::Thread.

Definition at line 87 of file PCF8574.cpp.

◆ rxDone()

void PCF8574Buttons::rxDone ( uint8_t  dat)

◆ saveFlash()

void PCF8574Buttons::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 113 of file PCF8574.cpp.

◆ setBtnNum()

void PCF8574Buttons::setBtnNum ( uint8_t  num)

Changes the amount of buttons to be read num/8 chips required. Each of them taking 200µS for a transfer! Not recommended to use more than 4 modules

Definition at line 173 of file PCF8574.cpp.

Member Data Documentation

◆ currentButtons

uint64_t PCF8574Buttons::currentButtons = 0
private

Definition at line 87 of file PCF8574.h.

◆ info

ClassIdentifier PCF8574Buttons::info
static
Initial value:
= {
.name = "I2C PCF8574" ,
.id=CLSID_BTN_PCF,
}

Definition at line 73 of file PCF8574.h.

◆ invert

bool PCF8574Buttons::invert = true
private

Definition at line 83 of file PCF8574.h.

◆ lastButtons

uint64_t PCF8574Buttons::lastButtons = 0
private

Definition at line 86 of file PCF8574.h.

◆ lastByte

uint8_t PCF8574Buttons::lastByte =0
private

Definition at line 89 of file PCF8574.h.

◆ lastData

uint8_t PCF8574Buttons::lastData =0
private

Definition at line 90 of file PCF8574.h.

◆ lastSuccess

uint32_t PCF8574Buttons::lastSuccess =0
private

Definition at line 92 of file PCF8574.h.

◆ mask

uint64_t PCF8574Buttons::mask = 0xff
private

Definition at line 85 of file PCF8574.h.

◆ numBytes

uint8_t PCF8574Buttons::numBytes = 1
private

Definition at line 84 of file PCF8574.h.

◆ readingData

volatile bool PCF8574Buttons::readingData = false
private

Definition at line 94 of file PCF8574.h.

◆ timeout

const uint32_t PCF8574Buttons::timeout = 250
private

Definition at line 93 of file PCF8574.h.


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