SpaIot Library
|
This class decodes information from the technical block of the spa. More...
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 BusSettings & | busSettings () const |
Bus settings provides at the instantiation. More... | |
const std::map< int, LedSettings > | ledSettings () 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... | |
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.
SpaIot::FrameDecoder::FrameDecoder | ( | ) |
Default constructor.
You must call begin(const BusSettings & bus, const std::map <int, LedSettings> & leds) before using the instance.
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.
bus | the bus settings |
leds | the leds settings |
|
virtual |
Destructor.
call end()
|
virtual |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
settings | describes the bus pins settings |
leds | describes the leds settings |
|
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
waitingTimeMs | Maximum time that the function will wait for a frame coming from the bus (-1 for infinity) |
Reimplemented in SpaIot::ControlPanel.
const BusSettings& SpaIot::FrameDecoder::busSettings | ( | ) | const |
Bus settings provides at the instantiation.
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.
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.
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).
uint32_t SpaIot::FrameDecoder::frameCounter | ( | ) | const |
Number of frames received from startup.
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).
bool SpaIot::FrameDecoder::hasLed | ( | int | key | ) | const |
Check if the hardware configuration has the LED.
key | LED identification key in the possible values of SpaIot::Key |
|
inline |
Last state of the Bubble LED.
Lets you know if the bubble generator is started.
References SpaIot::Bubble, and isLedOn().
uint8_t SpaIot::FrameDecoder::isDisplayBlink | ( | ) | const |
Check if the display blink.
|
inline |
Last state of the Filter LED.
Lets you know if the water filtration pump is started.
References SpaIot::Filter, and isLedOn().
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
|
inline |
Last state of the HeatReached LED.
Lets you know if the water temperature is greater than or equal to the desired temperature.
References SpaIot::HeatReached, and isLedOn().
|
inline |
Last state of the Jet LED.
Lets you know if the water jets are activated.
References isLedOn(), and SpaIot::Jet.
uint8_t SpaIot::FrameDecoder::isLedOn | ( | int | key | ) | const |
Last state received from an LED.
key | LED identification key in the possible values of SpaIot::Key |
Referenced by isBubbleOn(), isFilterOn(), isHeatReached(), isJetOn(), isPowerOn(), and isSanitizerOn().
|
virtual |
Indicates whether the connection with the spa is established.
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.
|
inline |
Last state of the Power LED.
References isLedOn(), and SpaIot::Power.
|
inline |
Last state of the Sanitizer LED.
Lets you know if the sanitation of the water is in progress.
References isLedOn(), and SpaIot::Sanitizer.
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.
const std::map<int, LedSettings> SpaIot::FrameDecoder::ledSettings | ( | ) | const |
Leds settings provides at the instantiation.
uint16_t SpaIot::FrameDecoder::rawStatus | ( | ) | const |
Last state of the LEDs received.
Pour la mise au point uniquement.
uint16_t SpaIot::FrameDecoder::sanitizerTime | ( | ) | const |
Remaining sanitation time.
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.
MaxWaitingTimeMs | Maximum waiting time in milliseconds |
uint8_t SpaIot::FrameDecoder::waitUntilDisplayBlink | ( | unsigned long | MaxWaitingTimeMs = 5000 | ) | const |
Wait until the display blink.
MaxWaitingTimeMs | Maximum waiting time in milliseconds |
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.