add york
This commit is contained in:
parent
3a75276d5c
commit
20d38ec7ac
10 changed files with 303 additions and 77 deletions
80
src/main.cpp
80
src/main.cpp
|
|
@ -7,7 +7,8 @@ RemoteVariable weather = RemoteVariable();
|
|||
RemoteVariable pm_switch = RemoteVariable();
|
||||
RemoteVariable pm_fan_speed = RemoteVariable();
|
||||
|
||||
const char *mode_names[] = {"off", "cool", "fan_only", "dry"};
|
||||
const char *mode_names_daikin[] = {"off", "cool", "fan_only", "dry"};
|
||||
const char *mode_names_york[] = {"off", "cool", "fan_only"};
|
||||
const char *fan_speed_names[] = {"auto", "high", "medium", "low"};
|
||||
uint8_t row = 4;
|
||||
uint8_t column = 2;
|
||||
|
|
@ -18,14 +19,24 @@ const uint8_t light_array[4][2] = {
|
|||
{LIGHT_ROW4_COLUMN1, LIGHT_ROW4_COLUMN2}};
|
||||
|
||||
|
||||
AirConditioner ac = {
|
||||
.max_temperature = 32,
|
||||
.min_temperature = 16,
|
||||
AirConditioner ac_daikin = {
|
||||
.max_temperature = 30,
|
||||
.min_temperature = 18,
|
||||
.modes = 4,
|
||||
.mode_names = mode_names,
|
||||
.mode_names = mode_names_daikin,
|
||||
.fan_speeds = 4,
|
||||
.fan_speed_names = fan_speed_names,
|
||||
.getInfraredCode = &getInfraredCode};
|
||||
.getInfraredCode = &getInfraredCode_daikin};
|
||||
|
||||
AirConditioner ac_york = {
|
||||
.max_temperature = 30,
|
||||
.min_temperature = 18,
|
||||
.modes = 3,
|
||||
.mode_names = mode_names_york,
|
||||
.fan_speeds = 4,
|
||||
.fan_speed_names = fan_speed_names,
|
||||
.getInfraredCode = &getInfraredCode_york};
|
||||
|
||||
/***********************************************
|
||||
* End Configuration *
|
||||
***********************************************/
|
||||
|
|
@ -33,9 +44,13 @@ AirConditioner ac = {
|
|||
ESPMegaPRO espmega = ESPMegaPRO();
|
||||
ISEDisplay iseDisplay = ISEDisplay(&iseDisplayAdapter, &light_array[0][0], row, column);
|
||||
|
||||
ClimateCard climateCard = ClimateCard(AIR_CONDITIONER_IR_PIN, ac,
|
||||
AIR_CONDITIONER_SENSOR_TYPE, AIR_CONDITIONER_SENSOR_PIN,
|
||||
AIR_CONDITIONER_RMT_CHANNEL);
|
||||
ClimateCard climateCard_daikin = ClimateCard(AIR_CONDITIONER_DAIKIN_IR_PIN, ac_daikin,
|
||||
AIR_CONDITIONER_SENSOR_TYPE, AIR_CONDITIONER_SENSOR_PIN,
|
||||
AIR_CONDITIONER_RMT_CHANNEL0);
|
||||
|
||||
ClimateCard climateCard_york = ClimateCard(AIR_CONDITIONER_YORK_IR_PIN, ac_york,
|
||||
AC_SENSOR_TYPE_NONE, 0,
|
||||
AIR_CONDITIONER_RMT_CHANNEL1);
|
||||
|
||||
void handleMqttMessage(char *topic, char *payload)
|
||||
{
|
||||
|
|
@ -110,11 +125,23 @@ void setup()
|
|||
}
|
||||
espmega.outputs.setState(12, true);
|
||||
espmega.outputs.setValue(12,4095);
|
||||
espmega.installCard(2, &climateCard);
|
||||
climateCard.bindFRAM(&espmega.fram, 5000);
|
||||
climateCard.loadStateFromFRAM();
|
||||
climateCard.setFRAMAutoSave(true);
|
||||
espmega.display->bindClimateCard(&climateCard);
|
||||
ESP_LOGD("ISE OS", "Setting up climate cards");
|
||||
|
||||
// Daikin Climate Card
|
||||
ESP_LOGD("ISE OS", "Installing daikin climate card");
|
||||
espmega.installCard(2, &climateCard_daikin);
|
||||
climateCard_daikin.bindFRAM(&espmega.fram, 5000);
|
||||
climateCard_daikin.loadStateFromFRAM();
|
||||
climateCard_daikin.setFRAMAutoSave(true);
|
||||
// Bind daikin climate card to the internal display
|
||||
espmega.display->bindClimateCard(&climateCard_daikin);
|
||||
|
||||
// York Climate Card
|
||||
ESP_LOGD("ISE OS", "Installing york climate card");
|
||||
espmega.installCard(3, &climateCard_york);
|
||||
climateCard_york.bindFRAM(&espmega.fram, 5005);
|
||||
climateCard_york.loadStateFromFRAM();
|
||||
climateCard_york.setFRAMAutoSave(true);
|
||||
// auto binded_display_update_on_pm25_out = std::bind(&display_update,0,std::placeholders::_1);
|
||||
// auto binded_display_update_on_pm25_in = std::bind(&display_update,1,std::placeholders::_1);
|
||||
// auto binded_display_update_on_temp_out = std::bind(&display_update,2,std::placeholders::_1);
|
||||
|
|
@ -157,9 +184,10 @@ void setup()
|
|||
pm_fan_speed.enableSetValue("/pm/set_fan_speed");
|
||||
espmega.iot->registerCard(0); // Register the Input Card
|
||||
espmega.iot->registerCard(1); // Register the Output Card
|
||||
espmega.iot->registerCard(2); // Register the Climate Card
|
||||
espmega.iot->registerCard(2); // Register the Climate Card Daikin
|
||||
espmega.iot->registerCard(3); // Register the Climate Card York
|
||||
auto bindedGetTime = std::bind(&ESPMegaPRO::getTime, &espmega);
|
||||
iseDisplay.begin(&espmega.inputs, &espmega.outputs, &climateCard, &pm_switch, &pm_fan_speed);
|
||||
iseDisplay.begin(&espmega.inputs, &espmega.outputs, &climateCard_daikin, &climateCard_york, &pm_switch, &pm_fan_speed);
|
||||
espmega.iot->registerRelativeMqttCallback(&handleMqttMessage);
|
||||
iseDisplay.registerPageChangeCallback(&handlePageChange);
|
||||
|
||||
|
|
@ -218,6 +246,25 @@ void loop()
|
|||
espmega.loop();
|
||||
iseDisplay.loop();
|
||||
|
||||
//loop set york ac state between 21 and 22 degree every 5 seconds
|
||||
static uint32_t last_ac_update = 0;
|
||||
if (millis() - last_ac_update > 5000)
|
||||
{
|
||||
uint8_t ac_temperature = climateCard_york.getTemperature();
|
||||
if (ac_temperature == 21)
|
||||
{
|
||||
ESP_LOGV("AC", "Setting AC temperature to 22");
|
||||
climateCard_york.setTemperature(22);
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGV("AC", "Setting AC temperature to 21");
|
||||
climateCard_york.setTemperature(21);
|
||||
}
|
||||
last_ac_update = millis();
|
||||
}
|
||||
|
||||
|
||||
// Update the time every 15 seconds
|
||||
// static bool run_when_init = false; // No static ? , this shit will reset to 0 every loop
|
||||
static uint32_t last_time_updated = 0;
|
||||
|
|
@ -417,6 +464,7 @@ void handlePageChange(uint8_t page)
|
|||
iseDisplay.updatePMinside(get_pm25_in());
|
||||
iseDisplay.updateWeather(weather.getValue());
|
||||
iseDisplay.updateTempOutside(get_temp_out());
|
||||
iseDisplay.updateACState();
|
||||
|
||||
/* iseDisplay.updateACState();
|
||||
iseDisplay.updateAirPurifierState();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue