SpaIot Library
|
Analog multiplexer for buttons. More...
Public Types | |
enum | { A = 0 , B , C , D , E , F , G , H } |
Public Member Functions | |
Multiplexer (const std::initializer_list< int > &spins, int inhPin) | |
Constructor. More... | |
Multiplexer (const String &name, const std::initializer_list< int > &spins, int inhPin) | |
Constructor with name. More... | |
Multiplexer () | |
Default constructor. More... | |
Multiplexer (const Multiplexer &other) | |
Copy Constructor. (const ButtonController &other) More... | |
Multiplexer & | operator= (const Multiplexer &other) |
Assignment operator. (const ButtonController &other) More... | |
Multiplexer (Multiplexer &&other) | |
Copy Constructor. (ButtonController &&other) More... | |
Multiplexer & | operator= (Multiplexer &&other) |
Assignment operator. (const ButtonController &&other) More... | |
int | selectPin (int order) const |
Given a order, return the corresponding value. More... | |
void | setSelectPin (int order, int pin) |
It sets the pin number for the select pin of the given order. More... | |
int | inhPin () const |
Get the pin number of the inhibit pin. | |
void | setInhPin (int pin) |
Set the pin number of the inhibit pin. | |
int | size () const |
Returns the number of multiplexer channels that are available. 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 ButtonController & | getFromRegister (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... | |
Analog multiplexer for buttons.
This class implements a multiplexer for buttons. It is a concrete class, and can be instantiated. It is a ButtonController, and can be used as such.
This class is copyable and movable.
The multiplexer is controlled by a set of pins that select the channel to be used. The pins are connected to the multiplexer in ascending order of weight: A for the least significant bit, B for the second least significant bit, and so on. The pins are connected to the multiplexer in the following order: A, B, C, D, E, F, G, H. The multiplexer has an inhibit pin that is used to disable the multiplexer. The multiplexer is disabled when the inhibit pin is in high level. That corresponds to integrated circuits like CD4051, CD4052, CD4053, CD4067, etc.
anonymous enum |
SpaIot::Multiplexer::Multiplexer | ( | const std::initializer_list< int > & | spins, |
int | inhPin | ||
) |
Constructor.
The constructor of Multiplexer takes a list of integers and an integer as input. The list of integers represents the selection pins that are connected to the multiplexer. The integer represents the pin that is connected to the inhibit pin
spins | a list of integers that represent the pins that are connected to the multiplexer, in ascending order of weight |
inhPin | The pin number of the inhibit pin ((active in high level) |
SpaIot::Multiplexer::Multiplexer | ( | const String & | name, |
const std::initializer_list< int > & | spins, | ||
int | inhPin | ||
) |
Constructor with name.
The constructor of Multiplexer takes a list of integers and an integer as input. The list of integers represents the selection pins that are connected to the multiplexer. The integer represents the pin that is connected to the inhibit pin
name | The name of the multiplexer |
spins | a list of integers that represent the pins that are connected to the multiplexer, in ascending order of weight |
inhPin | The pin number of the inhibit pin ((active in high level) |
SpaIot::Multiplexer::Multiplexer | ( | ) |
Default constructor.
isEmpty() will return true after this constructor, used for copy or move
SpaIot::Multiplexer::Multiplexer | ( | const Multiplexer & | other | ) |
Copy Constructor. (const ButtonController &other)
(const ButtonController &other)
SpaIot::Multiplexer::Multiplexer | ( | Multiplexer && | other | ) |
Copy Constructor. (ButtonController &&other)
(ButtonController &&other)
|
staticinherited |
Adds a ButtonController object to the register.
name | The name of the ButtonController object that will be used to retrieve it from the register |
controller | The ButtonController object |
|
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)
name | The name of the ButtonController object that will be used to retrieve it from the register |
Multiplexer& SpaIot::Multiplexer::operator= | ( | const Multiplexer & | other | ) |
Assignment operator. (const ButtonController &other)
(const ButtonController &other)
Multiplexer& SpaIot::Multiplexer::operator= | ( | Multiplexer && | other | ) |
Assignment operator. (const ButtonController &&other)
(const ButtonController &&other)
|
staticinherited |
Returns true if the register contains a ButtonController object with the given name.
name | The name of the ButtonController object that will be used to retrieve it from the register |
|
virtual |
Selects a button.
button | the button to be selected |
Implements SpaIot::ButtonController.
int SpaIot::Multiplexer::selectPin | ( | int | order | ) | const |
Given a order, return the corresponding value.
order | The order of the parameter. |
void SpaIot::Multiplexer::setSelectPin | ( | int | order, |
int | pin | ||
) |
It sets the pin number for the select pin of the given order.
order | the order to be used for the pin |
pin | the pin number |
int SpaIot::Multiplexer::size | ( | ) | const |
Returns the number of multiplexer channels that are available.
That is the number of buttons that can be connected to the multiplexer