SpaIot Library
SpaIot::FrameDecoder

This class decodes information from the technical block of the spa. More...

Inheritance diagram for SpaIot::FrameDecoder:

Public Member Functions

 FrameDecoder ()
 Default constructor. More...
 
 FrameDecoder (const BusSettings &bus, const std::map< int, LedSettings > &leds)
 Construct a new Frame Decoder object. More...
 
virtual ~FrameDecoder ()
 Destructor. More...
 
virtual void begin (unsigned long waitingTimeMs=BeginWaitingTimeMs)
 Initializes and connect with the spa. More...
 
virtual void begin (const BusSettings &settings, const std::map< int, LedSettings > &leds, unsigned long waitingTimeMs=BeginWaitingTimeMs)
 
virtual void end ()
 Close the FrameDecoder.
 
virtual bool isOpen () const
 Indicates whether the connection with the spa is established. More...
 
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

This class decodes information from the technical block of the spa.

This class decodes the frames so as to retrieve the condition of the LEDs and the value present on the 7-segment display.It can not detect if the user presses a button.
FrameDecoder stores the bits of the frame on each interrupt triggered by the clock rising edges, once the 16 bits of the raw status received, it decodes this status on the rising edge of the nWR (HOLD) signal.

Constructor & Destructor Documentation

◆ FrameDecoder() [1/2]

SpaIot::FrameDecoder::FrameDecoder ( )

Default constructor.

You must call begin(const BusSettings & bus, const std::map <int, LedSettings> & leds) before using the instance.

◆ FrameDecoder() [2/2]

SpaIot::FrameDecoder::FrameDecoder ( const BusSettings bus,
const std::map< int, LedSettings > &  leds 
)

Construct a new Frame Decoder object.

You may call begin() after this constructor.

Parameters
busthe bus settings
ledsthe leds settings

◆ ~FrameDecoder()

virtual SpaIot::FrameDecoder::~FrameDecoder ( )
virtual

Destructor.

call end()

Member Function Documentation

◆ begin() [1/2]

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

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/2]

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

Initializes and connect with the spa.

This function must be called before you can use the instance. This function configures the different hardware features, then loop waiting for a frame for a time of BeginWaitingTimeMs milliseconds. isOpen() lets you know if the connection has been successfully completed

Parameters
waitingTimeMsMaximum time that the function will wait for a frame coming from the bus (-1 for infinity)

Reimplemented in SpaIot::ControlPanel.

◆ busSettings()

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

Bus settings provides at the instantiation.

Returns
constant reference on settings

◆ clearTempUnitChangeCounter()

void SpaIot::FrameDecoder::clearTempUnitChangeCounter ( )

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

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

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

Number of frames received from startup.

Returns
Number of frames received including the frames dropped

◆ frameDropped()

uint32_t SpaIot::FrameDecoder::frameDropped ( ) const

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

◆ hasLed()

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

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
inline

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 isLedOn().

◆ isDisplayBlink()

uint8_t SpaIot::FrameDecoder::isDisplayBlink ( ) const

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
inline

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 isLedOn().

◆ isHeaterOn()

uint8_t SpaIot::FrameDecoder::isHeaterOn ( ) const

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
inline

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 isLedOn().

◆ isJetOn()

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

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 isLedOn(), and SpaIot::Jet.

◆ isLedOn()

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

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 isBubbleOn(), isFilterOn(), isHeatReached(), isJetOn(), isPowerOn(), and isSanitizerOn().

◆ isOpen()

virtual bool SpaIot::FrameDecoder::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 in SpaIot::ControlPanel.

◆ isPowerOn()

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

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 isLedOn(), and SpaIot::Power.

◆ isSanitizerOn()

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

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 isLedOn(), and SpaIot::Sanitizer.

◆ isSetupModeTriggered()

bool SpaIot::FrameDecoder::isSetupModeTriggered ( ) const

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

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

◆ rawStatus()

uint16_t SpaIot::FrameDecoder::rawStatus ( ) const

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

Remaining sanitation time.

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

◆ waitForWaterTemp()

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

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

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

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.