SpaIot Library
SpaIot::ControlPanel

Control Panel. More...

Inheritance diagram for SpaIot::ControlPanel:

Public Member Functions

 ControlPanel ()
 Default constructor. More...
 
 ControlPanel (const HardwareSettings &hwsettings)
 Construct a new Control Panel object. More...
 
 ControlPanel (const String &hwSettingsName)
 Construct a new Control Panel object. More...
 
virtual void begin (unsigned long waitingTimeMs=BeginWaitingTimeMs)
 Configures each of the buttons and initializes and connect with the spa. More...
 
virtual void begin (const HardwareSettings &hwsettings, unsigned long waitingTimeMs=BeginWaitingTimeMs)
 Configures each of the buttons and initializes and connect with the spa. More...
 
virtual void begin (const String &hwSettingsName, unsigned long waitingTimeMs=BeginWaitingTimeMs)
 Configures each of the buttons and initializes and connect with the spa. More...
 
virtual bool isOpen () const
 Indicates whether the connection with the spa is established. More...
 
bool hasButton (int key) const
 Check if the hardware configuration has the button. More...
 
Buttonbutton (int key)
 Button. More...
 
bool pushButton (int key)
 Press and release a button. More...
 
uint8_t setPower (bool v=true)
 Start or stop the spa. More...
 
uint8_t setFilter (bool v=true)
 Start or stop the water filtration. More...
 
uint8_t setHeater (bool v=true)
 Start or stop water heating. More...
 
uint8_t setBubble (bool v=true)
 Start or stop the the bubble generator. More...
 
uint8_t setJet (bool v=true)
 Start or stop the water jets. More...
 
bool setDesiredTemp (uint16_t temp)
 Setting the desired water temperature. More...
 
bool setSanitizerTime (uint16_t time)
 Set the water sanitation time. More...
 
uint16_t waitForDesiredTemp (unsigned long MaxWaitingTimeMs=5000)
 Press the TempUp button to read the desired temperature. More...
 
void end ()
 Close the FrameDecoder.
 
const std::map< int, ButtonSettingsbuttonSettings () const
 Button settings provides. More...
 
virtual void begin (const BusSettings &settings, const std::map< int, LedSettings > &leds, unsigned long waitingTimeMs=BeginWaitingTimeMs)
 
virtual bool isReady () const
 Check if communication with the spa is ready, that is to say if a frame has been received.
 
bool hasLed (int key) const
 Check if the hardware configuration has the LED. More...
 
const BusSettingsbusSettings () const
 Bus settings provides at the instantiation. More...
 
const std::map< int, LedSettingsledSettings () const
 Leds settings provides at the instantiation. More...
 
uint16_t rawStatus () const
 Last state of the LEDs received. More...
 
uint8_t isLedOn (int key) const
 Last state received from an LED. More...
 
uint8_t isPowerOn () const
 Last state of the Power LED. More...
 
uint8_t isFilterOn () const
 Last state of the Filter LED. More...
 
uint8_t isBubbleOn () const
 Last state of the Bubble LED. More...
 
uint8_t isHeatReached () const
 Last state of the HeatReached LED. More...
 
uint8_t isJetOn () const
 Last state of the Jet LED. More...
 
uint8_t isSanitizerOn () const
 Last state of the Sanitizer LED. More...
 
uint8_t isHeaterOn () const
 State of water heating. More...
 
uint16_t waterTemp () const
 Water temperature in °C. More...
 
uint16_t desiredTemp () const
 Water temperature desired in °C. More...
 
uint16_t sanitizerTime () const
 Remaining sanitation time. More...
 
uint32_t frameCounter () const
 Number of frames received from startup. More...
 
uint32_t frameDropped () const
 Number of dropped frames. More...
 
uint16_t error () const
 Error code displayed by the control panel. More...
 
bool isSetupModeTriggered () const
 Reset request triggered. More...
 
uint8_t isDisplayBlink () const
 Check if the display blink. More...
 
uint8_t waitUntilDisplayBlink (unsigned long MaxWaitingTimeMs=5000) const
 Wait until the display blink. More...
 
uint16_t waitForWaterTemp (unsigned long MaxWaitingTimeMs=25000) const
 Wait until the water temperature could be read. More...
 
void clearTempUnitChangeCounter ()
 Clear the setup mode trigger counter. More...
 

Detailed Description

Control Panel.

This class is the programming interface of the application (API). It allows to monitor and control the spa.

Constructor & Destructor Documentation

◆ ControlPanel() [1/3]

SpaIot::ControlPanel::ControlPanel ( )

Default constructor.

You must call begin(const HardwareSettings & hwsettings) before using the instance.

◆ ControlPanel() [2/3]

SpaIot::ControlPanel::ControlPanel ( const HardwareSettings hwsettings)

Construct a new Control Panel object.

Parameters
hwsettingsDescription of hardware settings

◆ ControlPanel() [3/3]

SpaIot::ControlPanel::ControlPanel ( const String &  hwSettingsName)

Construct a new Control Panel object.

Parameters
hwSettingsNameconfiguration name in the register of hardware settings, warning this name must be contained in the register ! (see SpaIot::HardwareSettings::registerSettings()

Member Function Documentation

◆ begin() [1/4]

virtual void SpaIot::FrameDecoder::begin ( const BusSettings settings,
const std::map< int, LedSettings > &  leds,
unsigned long  waitingTimeMs = BeginWaitingTimeMs 
)
virtualinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
settingsdescribes the bus pins settings
ledsdescribes the leds settings

◆ begin() [2/4]

virtual void SpaIot::ControlPanel::begin ( const HardwareSettings hwsettings,
unsigned long  waitingTimeMs = BeginWaitingTimeMs 
)
virtual

Configures each of the buttons and initializes and connect with the spa.

isOpen() lets you know if the connection has been successfully completed

Parameters
hwsettingsDescription of hardware settings

◆ begin() [3/4]

virtual void SpaIot::ControlPanel::begin ( const String &  hwSettingsName,
unsigned long  waitingTimeMs = BeginWaitingTimeMs 
)
virtual

Configures each of the buttons and initializes and connect with the spa.

isOpen() lets you know if the connection has been successfully completed

Parameters
hwSettingsNameconfiguration name in the register of hardware settings

◆ begin() [4/4]

virtual void SpaIot::ControlPanel::begin ( unsigned long  waitingTimeMs = BeginWaitingTimeMs)
virtual

Configures each of the buttons and initializes and connect with the spa.

isOpen() lets you know if the connection has been successfully completed

Reimplemented from SpaIot::FrameDecoder.

◆ busSettings()

const BusSettings& SpaIot::FrameDecoder::busSettings ( ) const
inherited

Bus settings provides at the instantiation.

Returns
constant reference on settings

◆ button()

Button& SpaIot::ControlPanel::button ( int  key)

Button.

Parameters
keybutton identification key in the possible values of SpaIot::Key
Returns
refernce on the button

◆ buttonSettings()

const std::map<int, ButtonSettings> SpaIot::ControlPanel::buttonSettings ( ) const

Button settings provides.

Returns
Constant reference on the std::map containing the button settings. The different key values are defined by SpaIot::Key

◆ clearTempUnitChangeCounter()

void SpaIot::FrameDecoder::clearTempUnitChangeCounter ( )
inherited

Clear the setup mode trigger counter.

The user can trigger a reset of settings by quickly changing SpaIot::SetupTrigUnitChangeMin times the temperature unit.

See also
SpaIot::SetupTrigUnitChangeMin This function can be used to clear the counter if the user wants to ignore the trigger.

◆ desiredTemp()

uint16_t SpaIot::FrameDecoder::desiredTemp ( ) const
inherited

Water temperature desired in °C.

The desired temperature can only be known if the user has made a setting. Indeed, this temperature is only displayed when the user presses the SpaIot::TempUp or SpaIot::TempDown buttons (blinking the display).
We can use ControlPanel::waitForDesiredTemp() to perform this operation and can read a correct value.

Returns
Water temperature desired in °C, UnsetValue16 if it has not been determined yet.

◆ error()

uint16_t SpaIot::FrameDecoder::error ( ) const
inherited

Error code displayed by the control panel.

For example, the E90 value can be displayed to indicate a water circulation problem. The user manual must be consulted for the meaning of this code.
This value is reset when calling this function if no error code has been displayed for more than 4 seconds (SpaIot::ResetErrorTimeMs).

Returns
The error code, 0 in normal situation

◆ frameCounter()

uint32_t SpaIot::FrameDecoder::frameCounter ( ) const
inherited

Number of frames received from startup.

Returns
Number of frames received including the frames dropped

◆ frameDropped()

uint32_t SpaIot::FrameDecoder::frameDropped ( ) const
inherited

Number of dropped frames.

If a new frame is received before decoding the previous frame is complete, this frame is lost. If the value of this counter increases rapidly is that the number of operations running under interruption by the CPU is important (the real time constraint is too high).
It is important to adjust the frequency of the CPU to its maximum value (160MHz for ESP8266).

Returns
Number of frames dropped

◆ hasButton()

bool SpaIot::ControlPanel::hasButton ( int  key) const

Check if the hardware configuration has the button.

Parameters
keybutton identification key in the possible values of SpaIot::Key
Returns
true if the button exists, false otherwise

◆ hasLed()

bool SpaIot::FrameDecoder::hasLed ( int  key) const
inherited

Check if the hardware configuration has the LED.

Parameters
keyLED identification key in the possible values of SpaIot::Key
Returns
true if the LED exists

◆ isBubbleOn()

uint8_t SpaIot::FrameDecoder::isBubbleOn ( ) const
inlineinherited

Last state of the Bubble LED.

Lets you know if the bubble generator is started.

Returns
true if the LED is lit, false if it is off, UnsetValue8 if this LED does not exist or if no frame has been received.

References SpaIot::Bubble, and SpaIot::FrameDecoder::isLedOn().

◆ isDisplayBlink()

uint8_t SpaIot::FrameDecoder::isDisplayBlink ( ) const
inherited

Check if the display blink.

Returns
true if blinking, false if not, UnsetValue8 if no frame has been received.

◆ isFilterOn()

uint8_t SpaIot::FrameDecoder::isFilterOn ( ) const
inlineinherited

Last state of the Filter LED.

Lets you know if the water filtration pump is started.

Returns
true if the LED is lit, false if it is off, UnsetValue8 if this LED does not exist or if no frame has been received.

References SpaIot::Filter, and SpaIot::FrameDecoder::isLedOn().

◆ isHeaterOn()

uint8_t SpaIot::FrameDecoder::isHeaterOn ( ) const
inherited

State of water heating.

Indicates that the heating is started, that the temperature of the water is reached or not

Returns
true if the heater is started, false if it is off, UnsetValue8 if no frame has been received.

◆ isHeatReached()

uint8_t SpaIot::FrameDecoder::isHeatReached ( ) const
inlineinherited

Last state of the HeatReached LED.

Lets you know if the water temperature is greater than or equal to the desired temperature.

Returns
true if the LED is lit, false if it is off, UnsetValue8 if this LED does not exist or if no frame has been received.

References SpaIot::HeatReached, and SpaIot::FrameDecoder::isLedOn().

◆ isJetOn()

uint8_t SpaIot::FrameDecoder::isJetOn ( ) const
inlineinherited

Last state of the Jet LED.

Lets you know if the water jets are activated.

Returns
true if the LED is lit, false if it is off, UnsetValue8 if this LED does not exist or if no frame has been received.

References SpaIot::FrameDecoder::isLedOn(), and SpaIot::Jet.

◆ isLedOn()

uint8_t SpaIot::FrameDecoder::isLedOn ( int  key) const
inherited

Last state received from an LED.

Parameters
keyLED identification key in the possible values of SpaIot::Key
Returns
true if the LED is lit, false if it is off, UnsetValue8 if this LED does not exist or if no frame has been received.

Referenced by SpaIot::FrameDecoder::isBubbleOn(), SpaIot::FrameDecoder::isFilterOn(), SpaIot::FrameDecoder::isHeatReached(), SpaIot::FrameDecoder::isJetOn(), SpaIot::FrameDecoder::isPowerOn(), and SpaIot::FrameDecoder::isSanitizerOn().

◆ isOpen()

virtual bool SpaIot::ControlPanel::isOpen ( ) const
virtual

Indicates whether the connection with the spa is established.

Returns
If begin() succeeded and everything works returns true. Returns false if the connection to the spa is not established and no frame is received.

Reimplemented from SpaIot::FrameDecoder.

◆ isPowerOn()

uint8_t SpaIot::FrameDecoder::isPowerOn ( ) const
inlineinherited

Last state of the Power LED.

Returns
true if the LED is lit, false if it is off, UnsetValue8 if this LED does not exist or if no frame has been received.

References SpaIot::FrameDecoder::isLedOn(), and SpaIot::Power.

◆ isSanitizerOn()

uint8_t SpaIot::FrameDecoder::isSanitizerOn ( ) const
inlineinherited

Last state of the Sanitizer LED.

Lets you know if the sanitation of the water is in progress.

Returns
true if the LED is lit, false if it is off, UnsetValue8 if this LED does not exist or if no frame has been received.

References SpaIot::FrameDecoder::isLedOn(), and SpaIot::Sanitizer.

◆ isSetupModeTriggered()

bool SpaIot::FrameDecoder::isSetupModeTriggered ( ) const
inherited

Reset request triggered.

The user can trigger a reset of settings by quickly changing SpaIot::SetupTrigUnitChangeMin times the temperature unit.

See also
SpaIot::SetupTrigUnitChangeMin
SpaIot::SetupTrigUnitChangeStepMaxMs
Returns
true if triggered

◆ ledSettings()

const std::map<int, LedSettings> SpaIot::FrameDecoder::ledSettings ( ) const
inherited

Leds settings provides at the instantiation.

Returns
Constant reference on the std::map containing the LED settings. The different key values are defined by SpaIot::Key

◆ pushButton()

bool SpaIot::ControlPanel::pushButton ( int  key)

Press and release a button.

Parameters
keybutton identification key in the possible values of SpaIot::Key
Returns
true if the button exists, false otherwise

◆ rawStatus()

uint16_t SpaIot::FrameDecoder::rawStatus ( ) const
inherited

Last state of the LEDs received.

Pour la mise au point uniquement.

Returns
The value corresponding to the last control frame of the LEDs, the value is the binary complement of the frame signal. UnsetValue16 is returned if no frame has been received.

◆ sanitizerTime()

uint16_t SpaIot::FrameDecoder::sanitizerTime ( ) const
inherited

Remaining sanitation time.

Returns
Remaining sanitation time in hours, UnsetValue16 if it has not been determined yet.

◆ setBubble()

uint8_t SpaIot::ControlPanel::setBubble ( bool  v = true)

Start or stop the the bubble generator.

Parameters
vtrue for ON, false for OFF
Returns
the state returned by isBubbleOn()

◆ setDesiredTemp()

bool SpaIot::ControlPanel::setDesiredTemp ( uint16_t  temp)

Setting the desired water temperature.

Parameters
temptemperature in °C
Returns

◆ setFilter()

uint8_t SpaIot::ControlPanel::setFilter ( bool  v = true)

Start or stop the water filtration.

Parameters
vtrue for ON, false for OFF
Returns
the state returned by isFilterOn()

◆ setHeater()

uint8_t SpaIot::ControlPanel::setHeater ( bool  v = true)

Start or stop water heating.

Parameters
vtrue for ON, false for OFF
Returns
the state returned by isHeaterOn()

◆ setJet()

uint8_t SpaIot::ControlPanel::setJet ( bool  v = true)

Start or stop the water jets.

Parameters
vtrue for ON, false for OFF
Returns
the state returned by isJetOn()

◆ setPower()

uint8_t SpaIot::ControlPanel::setPower ( bool  v = true)

Start or stop the spa.

Parameters
vtrue for ON, false for OFF
Returns
the state returned by isPowerOn()

◆ setSanitizerTime()

bool SpaIot::ControlPanel::setSanitizerTime ( uint16_t  time)

Set the water sanitation time.

Parameters
timeSanitation time in hours, the possible values are {0, 3, 5, 8}. 0 Disables sanitation.
Returns
true if the setting has been made, false if the requested value is invalid.

◆ waitForDesiredTemp()

uint16_t SpaIot::ControlPanel::waitForDesiredTemp ( unsigned long  MaxWaitingTimeMs = 5000)

Press the TempUp button to read the desired temperature.

Parameters
MaxWaitingTimeMsMaximum waiting time in milliseconds
Returns
Water temperature desired in °C, UnsetValue16 if it has not been determined yet.

◆ waitForWaterTemp()

uint16_t SpaIot::FrameDecoder::waitForWaterTemp ( unsigned long  MaxWaitingTimeMs = 25000) const
inherited

Wait until the water temperature could be read.

Framedecoder must wait to be sure that the display does not blink and the value is stable before determining the temperature of the water.
It can take 20 seconds. waitForWaterTemp() can be used to wait for FrameDecoder to determine the temperature.

Parameters
MaxWaitingTimeMsMaximum waiting time in milliseconds
Returns
Water temperature in °C, UnsetValue16 if it has not been determined yet.

◆ waitUntilDisplayBlink()

uint8_t SpaIot::FrameDecoder::waitUntilDisplayBlink ( unsigned long  MaxWaitingTimeMs = 5000) const
inherited

Wait until the display blink.

Parameters
MaxWaitingTimeMsMaximum waiting time in milliseconds
Returns
true if blinking, false if not, UnsetValue8 if no frame has been received.

◆ waterTemp()

uint16_t SpaIot::FrameDecoder::waterTemp ( ) const
inherited

Water temperature in °C.

Framedecoder must wait to be sure that the display does not blink and the value is stable before determining the temperature of the water.
It can take 2 seconds. waitForWaterTemp() can be used to wait for FrameDecoder to determine the temperature. The frame decoder engine considers that the temperature is stable if the value not change during 2 seconds INIT_STABLE_WATER_COUNTER, thus the value is only changed if it is stable for 2 seconds.

Returns
Water temperature in °C, UnsetValue16 if it has not been determined yet.