Compare commits

..

8 commits

4 changed files with 39 additions and 29 deletions

2
.gitignore vendored
View file

@ -3,3 +3,5 @@
.vscode/c_cpp_properties.json .vscode/c_cpp_properties.json
.vscode/launch.json .vscode/launch.json
.vscode/ipch .vscode/ipch
/.vscode
/.vscode

View file

@ -12,6 +12,6 @@
platform = espressif32 platform = espressif32
board = wt32-eth01 board = wt32-eth01
framework = arduino framework = arduino
lib_deps = siwats/ESPMegaPROR3@^2.9.0 lib_deps = siwats/ESPMegaPROR3@^2.9.4
monitor_speed = 115200 monitor_speed = 115200
build_flags = -DCORE_DEBUG_LEVEL=0 -DSW_VERSION='"ise-final-1.0"' -DBOARD_MODEL='"ESPMegaPRO R3.3b"' build_flags = -DCORE_DEBUG_LEVEL=0 -DSW_VERSION='"ise-final-1.3"' -DBOARD_MODEL='"ESPMegaPRO R3.3b"'

View file

@ -535,6 +535,13 @@ void ISEDisplay::updatePMinside(u_int16_t pm25_inside)
void ISEDisplay::setPMstate(bool is_pm_on, uint8_t pm_fan_speed) void ISEDisplay::setPMstate(bool is_pm_on, uint8_t pm_fan_speed)
{ {
//check pm_lock if true do nothing
this->pm_lock_state = strcmp(pm_lock->getValue(), "on") == 0;
if (this->pm_lock_state == true)
{
ESP_LOGI("ISEDisplay", "PM lock is on, do nothing");
return;
}
ESP_LOGI("ISEDisplay", "Setting PM state: %d, fan speed: %d", is_pm_on, pm_fan_speed); ESP_LOGI("ISEDisplay", "Setting PM state: %d, fan speed: %d", is_pm_on, pm_fan_speed);
char buffer[4]; char buffer[4];
itoa(pm_fan_speed, buffer, DEC); itoa(pm_fan_speed, buffer, DEC);
@ -562,6 +569,13 @@ void ISEDisplay::setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_te
this->ac_fan_speed = ac_fan_speed; this->ac_fan_speed = ac_fan_speed;
this->ac_mode = ac_mode; this->ac_mode = ac_mode;
this->ac_temperature = ac_temperature; this->ac_temperature = ac_temperature;
//check ac_lock if true do nothing
this->ac_lock_state = strcmp(ac_lock->getValue(), "on") == 0;
if (this->ac_lock_state == true)
{
ESP_LOGI("ISEDisplay", "AC lock is on, do nothing");
return;
}
// check ac_temp is within bound of daikin // check ac_temp is within bound of daikin
if (this->ac_temperature < DAIKIN_MIN_TEMP) if (this->ac_temperature < DAIKIN_MIN_TEMP)
{ {
@ -1174,13 +1188,18 @@ void ISEDisplay::toggleSystem()
bool state = calculateAllState(); bool state = calculateAllState();
if (state) if (state)
{ {
setACstate(0, ac_fan_speed, ac_temperature); //if AC mode is not zero, toggleAC()
if(ac_mode != 0) {
toggleAC();
}
setLightGroupState(0); setLightGroupState(0);
setPMstate(false, pm_fan_speed); setPMstate(false, pm_fan_speed);
} }
else else
{ {
setACstate(2, ac_fan_speed, ac_temperature); if(ac_mode == 0) {
toggleAC();
}
setLightGroupState(3); setLightGroupState(3);
setPMstate(true, pm_fan_speed); setPMstate(true, pm_fan_speed);
} }

View file

@ -129,7 +129,7 @@ void setup()
// set debounce time to 500 for pin 0-11 // set debounce time to 500 for pin 0-11
for (uint16_t i = 0; i < 16; i++) for (uint16_t i = 0; i < 16; i++)
{ {
espmega.inputs.setDebounceTime(i, 1000); espmega.inputs.setDebounceTime(i, 75);
} }
// ------------ IoT Module Initialization Routine ------------ // ------------ IoT Module Initialization Routine ------------
@ -172,33 +172,10 @@ void setup()
climateCard_daikin.setFRAMAutoSave(true); climateCard_daikin.setFRAMAutoSave(true);
espmega.display->bindClimateCard(&climateCard_daikin); espmega.display->bindClimateCard(&climateCard_daikin);
// Current Transformers
#ifdef ANALOG_ENABLE
espmega.installCard(4, &analogCard);
espmega.installCard(5, &ct1);
ct1.bindFRAM(&espmega.fram, 6000);
espmega.iot->registerCard(5);
espmega.installCard(6, &ct2);
ct2.bindFRAM(&espmega.fram, 6100);
espmega.iot->registerCard(6);
espmega.installCard(7, &ct3);
ct3.bindFRAM(&espmega.fram, 6200);
espmega.iot->registerCard(7);
espmega.installCard(8, &ct4);
ct4.bindFRAM(&espmega.fram, 6300);
espmega.iot->registerCard(8);
espmega.installCard(9, &ct5);
ct5.bindFRAM(&espmega.fram, 6400);
espmega.iot->registerCard(9);
espmega.installCard(10, &ct6);
ct6.bindFRAM(&espmega.fram, 6500);
espmega.iot->registerCard(10);
#endif
// Input callbacks // Input callbacks
// pre-load the input buffers // pre-load the input buffers
ESP_LOGV("ISE IoT OS", "Pre-loading input buffers"); ESP_LOGV("ISE IoT OS", "Pre-loading input buffers");
espmega.inputs.loop(); espmega.inputs.preloadInputBuffer();
// ------------ Climate Cards Initialization Routine ------------ // ------------ Climate Cards Initialization Routine ------------
ESP_LOGD("ISE OS", "Setting up climate cards"); ESP_LOGD("ISE OS", "Setting up climate cards");
@ -234,16 +211,28 @@ void setup()
ESP_LOGV("ISE OS", "Analog card available, installing current transformer cards"); ESP_LOGV("ISE OS", "Analog card available, installing current transformer cards");
espmega.installCard(5, &ct1); espmega.installCard(5, &ct1);
ct1.bindFRAM(&espmega.fram, 5010); ct1.bindFRAM(&espmega.fram, 5010);
ct1.loadEnergy();
ct1.setEnergyAutoSave(true);
espmega.installCard(6, &ct2); espmega.installCard(6, &ct2);
ct2.bindFRAM(&espmega.fram, 5020); ct2.bindFRAM(&espmega.fram, 5020);
ct2.loadEnergy();
ct2.setEnergyAutoSave(true);
espmega.installCard(7, &ct3); espmega.installCard(7, &ct3);
ct3.bindFRAM(&espmega.fram, 5030); ct3.bindFRAM(&espmega.fram, 5030);
ct3.loadEnergy();
ct3.setEnergyAutoSave(true);
espmega.installCard(8, &ct4); espmega.installCard(8, &ct4);
ct4.bindFRAM(&espmega.fram, 5040); ct4.bindFRAM(&espmega.fram, 5040);
ct4.loadEnergy();
ct4.setEnergyAutoSave(true);
espmega.installCard(9, &ct5); espmega.installCard(9, &ct5);
ct5.bindFRAM(&espmega.fram, 5050); ct5.bindFRAM(&espmega.fram, 5050);
ct5.loadEnergy();
ct5.setEnergyAutoSave(true);
espmega.installCard(10, &ct5); espmega.installCard(10, &ct5);
ct6.bindFRAM(&espmega.fram, 5060); ct6.bindFRAM(&espmega.fram, 5060);
ct6.loadEnergy();
ct6.setEnergyAutoSave(true);
espmega.iot->registerCard(5); espmega.iot->registerCard(5);
espmega.iot->registerCard(6); espmega.iot->registerCard(6);
espmega.iot->registerCard(7); espmega.iot->registerCard(7);