SpaIot Library
SpaIot::Pcf8574Mux

Multiplexer controlled by a PCF8574. More...

Inheritance diagram for SpaIot::Pcf8574Mux:

Public Member Functions

 Pcf8574Mux (uint8_t slaveAddress=0x20, TwoWire &bus=Wire, uint8_t idleValue=0xFF)
 
 Pcf8574Mux (const String &name, uint8_t slaveAddress=0x20, TwoWire &bus=Wire, uint8_t idleValue=0xFF)
 
 Pcf8574Mux (const Pcf8574Mux &other)
 Copy Constructor. (const ButtonController &other) More...
 
Pcf8574Muxoperator= (const Pcf8574Mux &other)
 Assignment operator. (const ButtonController &other) More...
 
 Pcf8574Mux (Pcf8574Mux &&other)
 Copy Constructor. (ButtonController &&other) More...
 
Pcf8574Muxoperator= (Pcf8574Mux &&other)
 Assignment operator. (const ButtonController &&other) More...
 
uint8_t address () const
 Reading of the slave m_address of the integrated circuit. More...
 
virtual void clear ()
 Sets all attributes to their default values (same as the default constructor)
 
virtual bool isEmpty () const
 Checks if all attributes are set to their default values (same as the default constructor)
 
virtual bool operator== (const ButtonController &other) const
 Returns true if the two objects are equal.
 
virtual void begin ()
 Configures all ressources needed to use the object.
 
virtual void end ()
 Releases all ressources used by the object.
 
virtual int select (int button)
 Selects a button. More...
 
virtual void deselect ()
 Deselects the button After the call to this function, isSelected() must return false, and selected() must return -1.
 
bool isNull () const
 Returns true if the object is null (i.e. it has not been initialized, d_ptr is null)
 
virtual bool operator!= (const ButtonController &other) const
 Returns true if the two objects are not equal.
 
virtual int selected () const
 Returns the button number that is selected, or -1 if no button is selected.
 
virtual bool isOpen () const
 Returns true if begin() has been successfully called.
 
virtual bool isSelected () const
 Returns true if a button is selected.
 
virtual const String & name () const
 Returns the name of the ButtonController object if it has been set, otherwise it returns an empty string.
 

Static Public Member Functions

static bool addToRegister (const String &name, ButtonController &controller)
 Adds a ButtonController object to the register. More...
 
static ButtonControllergetFromRegister (const String &name)
 Returns a ButtonController object from the register. More...
 
static bool registerContains (const String &name)
 Returns true if the register contains a ButtonController object with the given name. More...
 

Detailed Description

Multiplexer controlled by a PCF8574.

This class implements a multiplexer for buttons that is controlled by a PCF8574. It is a concrete class, and can be instantiated. This class is copyable and movable.

Constructor & Destructor Documentation

◆ Pcf8574Mux() [1/4]

SpaIot::Pcf8574Mux::Pcf8574Mux ( uint8_t  slaveAddress = 0x20,
TwoWire &  bus = Wire,
uint8_t  idleValue = 0xFF 
)

It creates a new Pcf8574Mux object.

Parameters
slaveAddressThe address of the PCF8574 chip.
busThe TwoWire object that is used to communicate with the PCF8574.
idleValueThe value that the pins will be set to when the device is not in use.

◆ Pcf8574Mux() [2/4]

SpaIot::Pcf8574Mux::Pcf8574Mux ( const String &  name,
uint8_t  slaveAddress = 0x20,
TwoWire &  bus = Wire,
uint8_t  idleValue = 0xFF 
)

It creates a new Pcf8574Mux object.

Parameters
namecontroller name
slaveAddressThe address of the PCF8574 chip.
busThe TwoWire object that is used to communicate with the PCF8574.
idleValueThe value that the pins will be set to when the device is not in use.

◆ Pcf8574Mux() [3/4]

SpaIot::Pcf8574Mux::Pcf8574Mux ( const Pcf8574Mux other)

Copy Constructor. (const ButtonController &other)

(const ButtonController &other)

◆ Pcf8574Mux() [4/4]

SpaIot::Pcf8574Mux::Pcf8574Mux ( Pcf8574Mux &&  other)

Copy Constructor. (ButtonController &&other)

(ButtonController &&other)

Member Function Documentation

◆ address()

uint8_t SpaIot::Pcf8574Mux::address ( ) const

Reading of the slave m_address of the integrated circuit.

Returns
7-bit I²C slave m_address, right-aligned

◆ addToRegister()

static bool SpaIot::ButtonController::addToRegister ( const String &  name,
ButtonController controller 
)
staticinherited

Adds a ButtonController object to the register.

Parameters
nameThe name of the ButtonController object that will be used to retrieve it from the register
controllerThe ButtonController object

◆ getFromRegister()

static ButtonController& SpaIot::ButtonController::getFromRegister ( const String &  name)
staticinherited

Returns a ButtonController object from the register.

The user must call registerContains() before calling this function to check if the register contains a ButtonController object with the given name, otherwise an exception will be thrown std::out_of_range (and if exceptions are not enabled, the program will terminate)

Parameters
nameThe name of the ButtonController object that will be used to retrieve it from the register
Returns
The ButtonController object

◆ operator=() [1/2]

Pcf8574Mux& SpaIot::Pcf8574Mux::operator= ( const Pcf8574Mux other)

Assignment operator. (const ButtonController &other)

(const ButtonController &other)

◆ operator=() [2/2]

Pcf8574Mux& SpaIot::Pcf8574Mux::operator= ( Pcf8574Mux &&  other)

Assignment operator. (const ButtonController &&other)

(const ButtonController &&other)

◆ registerContains()

static bool SpaIot::ButtonController::registerContains ( const String &  name)
staticinherited

Returns true if the register contains a ButtonController object with the given name.

Parameters
nameThe name of the ButtonController object that will be used to retrieve it from the register
Returns
true if the register contains a ButtonController object with the given name

◆ select()

virtual int SpaIot::Pcf8574Mux::select ( int  button)
virtual

Selects a button.

Parameters
buttonthe button to be selected
Returns
the value return by selected()

Implements SpaIot::ButtonController.