From 65985b211a61e33803fbaee76440dc5bfe1172ec Mon Sep 17 00:00:00 2001 From: Rasmus Date: Wed, 24 May 2023 10:38:58 +0400 Subject: [PATCH] adding light capability --- include/Appliance/AirConditioner/AirConditioner.h | 2 ++ include/Appliance/AirConditioner/StatusData.h | 11 +++++++++++ src/Appliance/AirConditioner/AirConditioner.cpp | 1 + 3 files changed, 14 insertions(+) diff --git a/include/Appliance/AirConditioner/AirConditioner.h b/include/Appliance/AirConditioner/AirConditioner.h index cc783c3..515f35b 100644 --- a/include/Appliance/AirConditioner/AirConditioner.h +++ b/include/Appliance/AirConditioner/AirConditioner.h @@ -36,6 +36,7 @@ class AirConditioner : public ApplianceBase { SwingMode getSwingMode() const { return this->m_swingMode; } FanMode getFanMode() const { return this->m_fanMode; } Preset getPreset() const { return this->m_preset; } + Display getLight() const { return this->m_light; } const Capabilities &getCapabilities() const { return this->m_capabilities; } void displayToggle() { this->m_displayToggle(); } protected: @@ -52,6 +53,7 @@ class AirConditioner : public ApplianceBase { float m_outdoorTemp{}; float m_targetTemp{}; float m_powerUsage{}; + Display m_light{}; Mode m_mode{Mode::MODE_OFF}; Preset m_preset{Preset::PRESET_NONE}; FanMode m_fanMode{FanMode::FAN_AUTO}; diff --git a/include/Appliance/AirConditioner/StatusData.h b/include/Appliance/AirConditioner/StatusData.h index 18ab31b..763e84a 100644 --- a/include/Appliance/AirConditioner/StatusData.h +++ b/include/Appliance/AirConditioner/StatusData.h @@ -64,6 +64,14 @@ enum Preset : uint8_t { PRESET_FREEZE_PROTECTION, }; +/// Enum for display light setting +enum Display : uint8_t { +/// Display is off +DISPLAY_OFF=7, +/// Display is on +DISPLAY_ON=0 +}; + class StatusData : public FrameData { public: StatusData() : FrameData({0x40, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, @@ -115,6 +123,9 @@ class StatusData : public FrameData { bool isFahrenheits() const { return this->m_getValue(10, 4); } void setFahrenheits(bool state) { this->m_setMask(10, state, 4); } + /* DISPLAY LIGHT */ + Display getLight() const { return static_cast(this->m_getValue(14,7,4)); } + protected: /* POWER */ bool m_getPower() const { return this->m_getValue(1, 1); } diff --git a/src/Appliance/AirConditioner/AirConditioner.cpp b/src/Appliance/AirConditioner/AirConditioner.cpp index acfe85e..4bd6ed8 100644 --- a/src/Appliance/AirConditioner/AirConditioner.cpp +++ b/src/Appliance/AirConditioner/AirConditioner.cpp @@ -211,6 +211,7 @@ ResponseStatus AirConditioner::m_readStatus(FrameData data) { if (newStatus.getMode() == Mode::MODE_OFF) this->m_lastPreset = this->m_preset; } + setProperty(this->m_light, newStatus.getLight(), hasUpdate); setProperty(this->m_preset, newStatus.getPreset(), hasUpdate); setProperty(this->m_fanMode, newStatus.getFanMode(), hasUpdate); setProperty(this->m_swingMode, newStatus.getSwingMode(), hasUpdate);