optimize climate card

This commit is contained in:
Siwat Sirichai 2024-02-16 23:55:43 +07:00
parent f4af513d65
commit e380606742
3 changed files with 12 additions and 2 deletions

View File

@ -345,7 +345,6 @@ void ClimateCard::updateSensor()
*/ */
void ClimateCard::updateAirConditioner() void ClimateCard::updateAirConditioner()
{ {
// // The IR Transmissions are not working yet so we just return
const uint16_t* ir_code_ptr = nullptr; 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); 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);
@ -453,3 +452,13 @@ void ClimateCard::unregisterSensorCallback(uint8_t handler)
{ {
sensor_callbacks.erase(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();
}

View File

@ -81,6 +81,7 @@ class ClimateCard : public ExpansionCard {
void setFanSpeed(uint8_t fan_speed); void setFanSpeed(uint8_t fan_speed);
void setFanSpeedByName(const char* fan_speed_name); void setFanSpeedByName(const char* fan_speed_name);
uint8_t getFanSpeed(); uint8_t getFanSpeed();
void setState(uint8_t mode, uint8_t fan_speed, uint8_t temperature);
char* getFanSpeedName(); char* getFanSpeedName();
float getRoomTemperature(); float getRoomTemperature();
float getHumidity(); float getHumidity();

View File

@ -32,7 +32,7 @@ void IRBlaster::send(const uint16_t *data, const size_t size)
items[j].duration1 = 0; 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; delete[] items;
} }