SpaIot Library
SpaIot::Multiplexer< W >

Analog multiplexer template. More...

#include <multiplexer.h>

Inheritance diagram for SpaIot::Multiplexer< W >:

Public Member Functions

 Multiplexer (const std::initializer_list< int > &spins, int inhPin)
 
 Multiplexer ()
 
int size () const
 
virtual void begin ()
 
virtual void end ()
 
virtual int select (int button)
 
virtual void deselect ()
 
virtual bool isNull () const
 
virtual bool operator== (const ButtonController &other) const
 
int selectPin (int key) const
 
void setSelectPin (int key, int pin)
 
virtual int selected () const
 
virtual bool isOpened () const
 
virtual bool isSelected () const
 
virtual const String & name () const
 
virtual bool operator!= (const ButtonController &other) const
 

Static Public Member Functions

static bool addToRegister (const String &name, ButtonController &controller)
 
static ButtonController & getFromRegister (const String &name)
 
static bool registerContains (const String &name)
 

Detailed Description

template<int W>
class SpaIot::Multiplexer< W >

Analog multiplexer template.

Constructor & Destructor Documentation

◆ Multiplexer() [1/2]

template<int W>
SpaIot::Multiplexer< W >::Multiplexer ( const std::initializer_list< int > &  spins,
int  inhPin 
)
inline

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

Parameters
spinsa list of integers that represent the pins that are connected to the multiplexer, in ascending order of weight
inhPinThe pin number of the inhibit pin ((active in high level)

◆ Multiplexer() [2/2]

template<int W>
SpaIot::Multiplexer< W >::Multiplexer ( )
inline

Default constructor The Multiplexer class is a subclass of ButtonController

Member Function Documentation

◆ addToRegister()

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

◆ begin()

template<int W>
virtual void SpaIot::Multiplexer< W >::begin ( )
inlinevirtual

It opens the multiplexer.

Selection pins are low logic state, the inihibition pin in the high logic state.

References SpaIot::Multiplexer< W >::isNull().

◆ deselect()

template<int W>
virtual void SpaIot::Multiplexer< W >::deselect ( )
inlinevirtual

It deselects the current selected item.

◆ end()

template<int W>
virtual void SpaIot::Multiplexer< W >::end ( )
inlinevirtual

This function is called when the program ends.

It sets the pins to be inputs with pullups

◆ getFromRegister()

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

◆ isNull()

template<int W>
virtual bool SpaIot::Multiplexer< W >::isNull ( ) const
inlinevirtual

This function returns true if default construting

Returns
A boolean value.

Referenced by SpaIot::Multiplexer< W >::begin().

◆ isOpened()

virtual bool SpaIot::ButtonController::isOpened ( ) const
virtualinherited
Returns

◆ isSelected()

virtual bool SpaIot::ButtonController::isSelected ( ) const
virtualinherited
Returns

◆ name()

virtual const String & SpaIot::ButtonController::name ( ) const
virtualinherited
Returns

◆ operator!=()

virtual bool SpaIot::ButtonController::operator!= ( const ButtonController &  other) const
virtualinherited
Parameters
other

◆ operator==()

template<int W>
virtual bool SpaIot::Multiplexer< W >::operator== ( const ButtonController &  other) const
inlinevirtual

The Multiplexer class has an operator== function that takes one argument, a Multiplexer object.

Parameters
otherthe other object being compared to this one.
Returns
The result of the comparison of the two objects.

◆ registerContains()

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

◆ select()

template<int W>
virtual int SpaIot::Multiplexer< W >::select ( int  button)
inlinevirtual

If the button is pressed, the corresponding pin is set to high, and the other pins are set to low

Parameters
buttonThe button number to be selected.
Returns
ButtonController::selected()

◆ selected()

virtual int SpaIot::ButtonController::selected ( ) const
virtualinherited
Returns

◆ selectPin()

template<int W>
int SpaIot::Multiplexer< W >::selectPin ( int  key) const
inline

Given a key, return the corresponding value

Parameters
keyThe key of the parameter.
Returns
The pin number for the given key.

◆ setSelectPin()

template<int W>
void SpaIot::Multiplexer< W >::setSelectPin ( int  key,
int  pin 
)
inline

It sets the pin number for the select pin of the given key.

Parameters
keythe key to be used for the pin
pinthe pin number

◆ size()

template<int W>
int SpaIot::Multiplexer< W >::size ( ) const
inline

Return the number of multiplexer channels.

Returns
the number of multiplexer channels