From e380606742d0ffafbd5a6aae1a222e65ce75385d Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Fri, 16 Feb 2024 23:55:43 +0700 Subject: [PATCH] optimize climate card --- ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateCard.cpp | 11 ++++++++++- ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateCard.hpp | 1 + ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/IRBlaster.cpp | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateCard.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateCard.cpp index 6a5ed6f..ce4f9c5 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateCard.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateCard.cpp @@ -345,7 +345,6 @@ void ClimateCard::updateSensor() */ void ClimateCard::updateAirConditioner() { - // // The IR Transmissions are not working yet so we just return const uint16_t* ir_code_ptr = nullptr; size_t itemCount = (*(this->ac.getInfraredCode))(this->state.ac_mode, this->state.ac_fan_speed, this->state.ac_temperature-this->ac.min_temperature, &ir_code_ptr); @@ -452,4 +451,14 @@ void ClimateCard::unregisterChangeCallback(uint8_t handler) void ClimateCard::unregisterSensorCallback(uint8_t handler) { sensor_callbacks.erase(handler); +} + +void ClimateCard::setState(uint8_t mode, uint8_t fan_speed, uint8_t temperature) +{ + this->state.ac_mode = mode; + this->state.ac_fan_speed = fan_speed; + this->state.ac_temperature = temperature; + updateAirConditioner(); + if (fram_auto_save) + saveStateToFRAM(); } \ No newline at end of file diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateCard.hpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateCard.hpp index 7d7e4ee..79612e8 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateCard.hpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateCard.hpp @@ -81,6 +81,7 @@ class ClimateCard : public ExpansionCard { void setFanSpeed(uint8_t fan_speed); void setFanSpeedByName(const char* fan_speed_name); uint8_t getFanSpeed(); + void setState(uint8_t mode, uint8_t fan_speed, uint8_t temperature); char* getFanSpeedName(); float getRoomTemperature(); float getHumidity(); diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/IRBlaster.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/IRBlaster.cpp index 81478c2..5133ba5 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/IRBlaster.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/IRBlaster.cpp @@ -32,7 +32,7 @@ void IRBlaster::send(const uint16_t *data, const size_t size) items[j].duration1 = 0; } } - ESP_ERROR_CHECK(rmt_write_items(channel, items, size / 2 + size % 2, true)); + ESP_ERROR_CHECK(rmt_write_items(channel, items, size / 2 + size % 2, false)); delete[] items; }