Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding light capability #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/Appliance/AirConditioner/AirConditioner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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};
Expand Down
11 changes: 11 additions & 0 deletions include/Appliance/AirConditioner/StatusData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Comment on lines +67 to +73
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Enum for display light setting
enum Display : uint8_t {
/// Display is off
DISPLAY_OFF=7,
/// Display is on
DISPLAY_ON=0
};
/// 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,
Expand Down Expand Up @@ -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<Display>(this->m_getValue(14,7,4)); }
Comment on lines +126 to +127
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* DISPLAY LIGHT */
Display getLight() const { return static_cast<Display>(this->m_getValue(14,7,4)); }
/* DISPLAY LIGHT */
Display getLight() const { return static_cast<Display>(this->m_getValue(14, 7, 4)); }


protected:
/* POWER */
bool m_getPower() const { return this->m_getValue(1, 1); }
Expand Down
1 change: 1 addition & 0 deletions src/Appliance/AirConditioner/AirConditioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down