fix pm fan speed
This commit is contained in:
parent
b01540a4ce
commit
733ed54f9b
3 changed files with 52 additions and 23 deletions
Binary file not shown.
|
|
@ -17,18 +17,35 @@ void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCar
|
||||||
this->outputCallbackHandle = this->outputCard->registerChangeCallback(bindedHandlePWMChange);
|
this->outputCallbackHandle = this->outputCard->registerChangeCallback(bindedHandlePWMChange);
|
||||||
this->climateCallbackHandle = this->climateCard->registerChangeCallback(bindedHandleACChange);
|
this->climateCallbackHandle = this->climateCard->registerChangeCallback(bindedHandleACChange);
|
||||||
this->user_mode = 1; // initialized to cool by default
|
this->user_mode = 1; // initialized to cool by default
|
||||||
|
this->pm_fan_speed = 10;
|
||||||
|
this->ac_fan_speed = 0;
|
||||||
|
this->ac_mode = 0;
|
||||||
|
this->ac_temperature = 25;
|
||||||
|
this->lightLevelRow1 = 0;
|
||||||
|
this->lightLevelRow2 = 0;
|
||||||
|
this->lightLevelRow3 = 0;
|
||||||
|
this->lightLevelRow4 = 0;
|
||||||
this->time_since_last_screen_update = 0;
|
this->time_since_last_screen_update = 0;
|
||||||
this->registerTouchCallback(bindedHandleTouch);
|
this->registerTouchCallback(bindedHandleTouch);
|
||||||
this->reset();
|
this->reset();
|
||||||
delay(1000);
|
delay(1000);
|
||||||
// TODO : Will the light be on or off when the system is started?, You need to jump to its respective page
|
// TODO : Will the light be on or off when the system is started?, You need to jump to its respective page
|
||||||
// first jump to main then if no activity jump to standby
|
// first jump to main then if no activity jump to standby
|
||||||
this->jumpToPage(1); // change this back later to 2
|
this->jumpToPage(2); // change this back later to 2
|
||||||
delay(100);
|
delay(100);
|
||||||
this->updateAirPurifierState();
|
this->updateAirPurifierState();
|
||||||
this->updateACState();
|
this->updateACState();
|
||||||
this->updateLightGroupStatePageDashboard();
|
this->updateLightGroupStatePageDashboard();
|
||||||
this->updateLightGroupStatePageStandby();
|
this->updateLightGroupStatePageStandby();
|
||||||
|
this->outputCard->setValue(6,pm_fan_speed);
|
||||||
|
this->outputCard->setValue(5,0);
|
||||||
|
this->outputCard->setValue(1,0);
|
||||||
|
this->outputCard->setValue(2,0);
|
||||||
|
this->outputCard->setValue(3,0);
|
||||||
|
this->outputCard->setValue(4,0);
|
||||||
|
// this->climateCard->setTemperature(ac_temperature);
|
||||||
|
// this->climateCard->setFanSpeed(ac_fan_speed);
|
||||||
|
// this->climateCard->setMode(ac_mode);
|
||||||
}
|
}
|
||||||
void ISEDisplay::loop()
|
void ISEDisplay::loop()
|
||||||
{
|
{
|
||||||
|
|
@ -43,13 +60,18 @@ void ISEDisplay::loop()
|
||||||
if (current_time - this->time_since_last_screen_update > 120000)
|
if (current_time - this->time_since_last_screen_update > 120000)
|
||||||
{
|
{
|
||||||
// jump to standby page if there is no activity for 2 minutes
|
// jump to standby page if there is no activity for 2 minutes
|
||||||
this->jumpToPage(1);
|
if(this->currentPage != 1){
|
||||||
|
this->jumpToPage(1);
|
||||||
|
ESP_LOGI("ISEDisplay", "Jumping to standby page");
|
||||||
|
}
|
||||||
|
ESP_LOGI("ISEDisplay", "No activity for 2 minutes & currently at standby page");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type)
|
void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type)
|
||||||
{
|
{
|
||||||
ESP_LOGD("ISEDisplay", "Touch detected on page %d, component %d, touch type %d", page, component, touch_type);
|
ESP_LOGD("ISEDisplay", "Touch detected on page %d, component %d, touch type %d", page, component, touch_type);
|
||||||
|
time_since_last_screen_update = millis(); // update time since last activity
|
||||||
if (page == PAGE_STANDBY)
|
if (page == PAGE_STANDBY)
|
||||||
{
|
{
|
||||||
switch (component)
|
switch (component)
|
||||||
|
|
@ -81,7 +103,7 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
|
||||||
case COMPONENT_STANDBY_PM_TOGGLE:
|
case COMPONENT_STANDBY_PM_TOGGLE:
|
||||||
if (touch_type != TOUCH_TYPE_RELEASE)
|
if (touch_type != TOUCH_TYPE_RELEASE)
|
||||||
break;
|
break;
|
||||||
togglePM();
|
togglePMStandby();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
@ -90,12 +112,7 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
|
||||||
|
|
||||||
else if (page == PAGE_DASHBOARD)
|
else if (page == PAGE_DASHBOARD)
|
||||||
{
|
{
|
||||||
u_int8_t pm_fan_speed = 0;
|
|
||||||
u_int8_t fan_speed = 0;
|
|
||||||
u_int8_t lightLevelRow1 = 0;
|
|
||||||
u_int8_t lightLevelRow2 = 0;
|
|
||||||
u_int8_t lightLevelRow3 = 0;
|
|
||||||
u_int8_t lightLevelRow4 = 0;
|
|
||||||
|
|
||||||
switch (component)
|
switch (component)
|
||||||
{
|
{
|
||||||
|
|
@ -188,10 +205,10 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
|
||||||
case COMPONENT_AC_FAN_SPEED:
|
case COMPONENT_AC_FAN_SPEED:
|
||||||
if (touch_type != TOUCH_TYPE_RELEASE)
|
if (touch_type != TOUCH_TYPE_RELEASE)
|
||||||
break;
|
break;
|
||||||
fan_speed = this->climateCard->getFanSpeed();
|
ac_fan_speed = this->climateCard->getFanSpeed();
|
||||||
// We have auto, low, mid, high right?, that's 0,1,2,3 a modulo operation of 3 only gives 0,1,2
|
// We have auto, low, mid, high right?, that's 0,1,2,3 a modulo operation of 3 only gives 0,1,2
|
||||||
// mod 4 should fixed it
|
// mod 4 should fixed it
|
||||||
this->climateCard->setFanSpeed((fan_speed + 1) % 4);
|
this->climateCard->setFanSpeed((ac_fan_speed + 1) % 4);
|
||||||
updateACState();
|
updateACState();
|
||||||
break;
|
break;
|
||||||
case COMPONENT_AC_TEMP_DOWN_BUTTON:
|
case COMPONENT_AC_TEMP_DOWN_BUTTON:
|
||||||
|
|
@ -215,16 +232,20 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
|
||||||
if (touch_type != TOUCH_TYPE_RELEASE)
|
if (touch_type != TOUCH_TYPE_RELEASE)
|
||||||
break;
|
break;
|
||||||
pm_fan_speed = this->outputCard->getValue(6);
|
pm_fan_speed = this->outputCard->getValue(6);
|
||||||
if (pm_fan_speed >= 0 && pm_fan_speed <= 20)
|
ESP_LOGI("ISEDisplay", "Current PM fan speed: %d", pm_fan_speed);
|
||||||
this->outputCard->setValue(5, (pm_fan_speed - 1));
|
if (pm_fan_speed >=1 && pm_fan_speed <= 20)
|
||||||
|
this->outputCard->setValue(6, (pm_fan_speed - 1));
|
||||||
|
ESP_LOGI("ISEDisplay", "New PM fan speed: %d", pm_fan_speed);
|
||||||
updateAirPurifierState();
|
updateAirPurifierState();
|
||||||
break;
|
break;
|
||||||
case COMPONENT_PM_FAN_SPEED_INCREASE:
|
case COMPONENT_PM_FAN_SPEED_INCREASE:
|
||||||
if (touch_type != TOUCH_TYPE_RELEASE)
|
if (touch_type != TOUCH_TYPE_RELEASE)
|
||||||
break;
|
break;
|
||||||
pm_fan_speed = this->outputCard->getValue(6);
|
pm_fan_speed = this->outputCard->getValue(6);
|
||||||
if (pm_fan_speed >= 0 && pm_fan_speed <= 20)
|
ESP_LOGI("ISEDisplay", "Current PM fan speed: %d", pm_fan_speed);
|
||||||
this->outputCard->setValue(5, (pm_fan_speed + 1));
|
if (pm_fan_speed >= 0 && pm_fan_speed <= 19)
|
||||||
|
this->outputCard->setValue(6, (pm_fan_speed + 1));
|
||||||
|
ESP_LOGI("ISEDisplay", "New PM fan speed: %d", pm_fan_speed);
|
||||||
updateAirPurifierState();
|
updateAirPurifierState();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -368,14 +389,14 @@ void ISEDisplay::updateTempOutside(float temp_outside)
|
||||||
// change temp_outside to int then display
|
// change temp_outside to int then display
|
||||||
u_int8_t temp_outside_int = (u_int8_t)temp_outside;
|
u_int8_t temp_outside_int = (u_int8_t)temp_outside;
|
||||||
this->takeSerialMutex();
|
this->takeSerialMutex();
|
||||||
this->displayAdapter->printf("temp_outside.txt=\"%d\"", temp_outside_int);
|
this->displayAdapter->printf("temp_outside.txt=%d", temp_outside_int);
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
this->giveSerialMutex();
|
this->giveSerialMutex();
|
||||||
}
|
}
|
||||||
void ISEDisplay::updatePMoutside(u_int16_t pm25_outside)
|
void ISEDisplay::updatePMoutside(u_int16_t pm25_outside)
|
||||||
{
|
{
|
||||||
this->takeSerialMutex();
|
this->takeSerialMutex();
|
||||||
this->displayAdapter->printf("pm_outside.txt=\"%d\"", pm25_outside);
|
this->displayAdapter->printf("pm_outside.txt=%d", pm25_outside);
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
this->giveSerialMutex();
|
this->giveSerialMutex();
|
||||||
// TODO : use remotevar to get PM2.5 data from appdaemon and update the display
|
// TODO : use remotevar to get PM2.5 data from appdaemon and update the display
|
||||||
|
|
@ -652,7 +673,7 @@ void ISEDisplay::updateAirPurifierState()
|
||||||
{
|
{
|
||||||
// Get the state
|
// Get the state
|
||||||
bool state = this->outputCard->getState(5);
|
bool state = this->outputCard->getState(5);
|
||||||
uint8_t fan_speed = this->outputCard->getState(6);
|
pm_fan_speed = this->outputCard->getValue(6);
|
||||||
// Send the state to the display
|
// Send the state to the display
|
||||||
this->takeSerialMutex();
|
this->takeSerialMutex();
|
||||||
|
|
||||||
|
|
@ -664,9 +685,9 @@ void ISEDisplay::updateAirPurifierState()
|
||||||
this->displayAdapter->print(state ? COMPONENT_PM_TOGGLE_PIC_ON_PRESSED : COMPONENT_PM_TOGGLE_PIC_OFF_PRESSED);
|
this->displayAdapter->print(state ? COMPONENT_PM_TOGGLE_PIC_ON_PRESSED : COMPONENT_PM_TOGGLE_PIC_OFF_PRESSED);
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
|
||||||
this->displayAdapter->print("pm_speed.txt=\"");
|
this->displayAdapter->print("pm_speed.val=");
|
||||||
this->displayAdapter->print(fan_speed);
|
this->displayAdapter->print(pm_fan_speed);
|
||||||
this->displayAdapter->print("\"");
|
//this->displayAdapter->print("\"");
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
|
||||||
this->displayAdapter->print("pm_speed.pco=");
|
this->displayAdapter->print("pm_speed.pco=");
|
||||||
|
|
@ -788,9 +809,9 @@ void ISEDisplay::updateACState()
|
||||||
|
|
||||||
updateACfanSpeed();
|
updateACfanSpeed();
|
||||||
|
|
||||||
this->displayAdapter->print("ac_temp.txt=\"");
|
this->displayAdapter->print("ac_temp.val=");
|
||||||
this->displayAdapter->print(temperature);
|
this->displayAdapter->print(temperature);
|
||||||
this->displayAdapter->print("\"");
|
//this->displayAdapter->print("\"");
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
|
||||||
this->giveSerialMutex();
|
this->giveSerialMutex();
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,15 @@ class ISEDisplay : public ESPMegaDisplay {
|
||||||
uint8_t outputCallbackHandle;
|
uint8_t outputCallbackHandle;
|
||||||
uint8_t climateCallbackHandle;
|
uint8_t climateCallbackHandle;
|
||||||
uint8_t user_mode;
|
uint8_t user_mode;
|
||||||
|
uint8_t ac_mode;
|
||||||
|
uint8_t ac_fan_speed;
|
||||||
|
uint8_t ac_temperature;
|
||||||
|
uint8_t pm_fan_speed;
|
||||||
uint8_t time_since_last_screen_update;
|
uint8_t time_since_last_screen_update;
|
||||||
|
u_int8_t lightLevelRow1;
|
||||||
|
u_int8_t lightLevelRow2;
|
||||||
|
u_int8_t lightLevelRow3;
|
||||||
|
u_int8_t lightLevelRow4;
|
||||||
|
|
||||||
|
|
||||||
void updateuserACmode();
|
void updateuserACmode();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue