SpaIot Library
controlpanel.h
1/*
2 * SpaIot Library (c) by epsilonrt - epsilonrt@gmail.com
3 * This file is part of SpaIot library <https://github.com/epsilonrt/spaiot-lib>
4 *
5 * SpaIot library is licensed under a
6 * Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
7 *
8 * You should have received a copy of the license along with this
9 * work. If not, see <http://creativecommons.org/licenses/by-nc-sa/4.0/>.
10 *
11 * SpaIot library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY;
13 */
14#pragma once
15
16#include "hardwaresettings.h"
17#include "framedecoder.h"
18#include "button.h"
19
20namespace SpaIot {
21
30 class ControlPanel : public FrameDecoder {
31 public:
37 static ControlPanel & singleton (const HardwareSettings & hwsettings);
42 static ControlPanel & singleton (const String & hwSettingsName);
53 static ControlPanel * getInstance (const HardwareSettings & hwsettings);
59 static ControlPanel * getInstance (const String & hwSettingsName);
70 void begin (unsigned long waitingTimeMs = BeginWaitingTimeMs);
77 void begin (const HardwareSettings & hwsettings, unsigned long waitingTimeMs = BeginWaitingTimeMs);
84 void begin (const String & hwSettingsName, unsigned long waitingTimeMs = BeginWaitingTimeMs);
91 bool isOpened() const;
97 bool hasButton (int key) const;
103 Button & button (int key);
109 bool pushButton (int key);
115 uint8_t setPower (bool v = true);
121 uint8_t setFilter (bool v = true);
127 uint8_t setHeater (bool v = true);
133 uint8_t setBubble (bool v = true);
139 uint8_t setJet (bool v = true);
145 bool setDesiredTemp (uint16_t temp);
152 bool setSanitizerTime (uint16_t time);
159 uint16_t waitForDesiredTemp (unsigned long MaxWaitingTimeMs = 5000);
163 void end();
175 const std::map <int, ButtonSettings> buttonSettings() const;
176
177 protected:
183 const std::map <int, Button> & buttons() const;
184 ControlPanel (const HardwareSettings & hwsettings);
185 ControlPanel ();
186 uint8_t setKeyOn (int key, bool v);
187 bool makeButtons();
188
189 private:
190 std::map <int, ButtonSettings> m_btnsettings;
191 bool m_isopened;
192 std::map <int, Button> m_button;
193 static ControlPanel * m_instance;
194 };
195
196}
Control Panel.
Definition: controlpanel.h:30
bool hasButton(int key) const
Check if the hardware configuration has the button.
uint8_t setJet(bool v=true)
Start or stop the water jets.
uint8_t setBubble(bool v=true)
Start or stop the the bubble generator.
bool pushButton(int key)
Press and release a button.
static ControlPanel & singleton(const String &hwSettingsName)
bool setDesiredTemp(uint16_t temp)
Setting the desired water temperature.
static ControlPanel & singleton(const HardwareSettings &hwsettings)
Create the control panel singleton with the provided settings.
void begin(const HardwareSettings &hwsettings, unsigned long waitingTimeMs=BeginWaitingTimeMs)
Configures each of the buttons and initializes and connect with the spa.
uint16_t waitForDesiredTemp(unsigned long MaxWaitingTimeMs=5000)
Press the TempUp button to read the desired temperature.
uint8_t setPower(bool v=true)
Start or stop the spa.
static ControlPanel & singleton()
Button & button(int key)
Button.
static ControlPanel * getInstance()
void begin(const String &hwSettingsName, unsigned long waitingTimeMs=BeginWaitingTimeMs)
Configures each of the buttons and initializes and connect with the spa.
void end()
Close the FrameDecoder.
static ControlPanel * getInstance(const HardwareSettings &hwsettings)
Create the control panel instance with the provided settings.
uint8_t setFilter(bool v=true)
Start or stop the water filtration.
const std::map< int, ButtonSettings > buttonSettings() const
Button settings provides.
static ControlPanel * getInstance(const String &hwSettingsName)
bool isOpened() const
Indicates whether the connection with the spa is established.
uint8_t setHeater(bool v=true)
Start or stop water heating.
void begin(unsigned long waitingTimeMs=BeginWaitingTimeMs)
Configures each of the buttons and initializes and connect with the spa.
~ControlPanel()
Destructor.
bool setSanitizerTime(uint16_t time)
Set the water sanitation time.
This class decodes information from the technical block of the spa.
Definition: framedecoder.h:35
SpaIot name space.
Definition: bussettings.h:21
const unsigned long BeginWaitingTimeMs
begin() waiting time in milliseconds
Definition: global.h:63