add sound, resize weather icon, replace button with slider

This commit is contained in:
reaw55 2024-02-07 17:06:59 +07:00
parent 89ebcfb64c
commit d8c57b4a22
37 changed files with 144 additions and 114 deletions

View file

@ -2,19 +2,12 @@
ISEDisplay::ISEDisplay(HardwareSerial *adapter) : ESPMegaDisplay(adapter, 115200, 912600, 4, 17)
{
}
// sat->sun
// Work left
// TODO : Implement
// debug to complie
// standby
// dimable
// sun -> mon
// debug to work
// appdeamon send data / receive data
// sound
// mon -> tue
// slider
void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCard, ClimateCard *climateCard)
{
this->inputCard = inputCard;
@ -100,6 +93,11 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
{
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)
{
case COMPONENT_LIGHT_MASTER_BUTTON:
@ -110,85 +108,49 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
break;
// TODOlater : can't this be done better with array lookup?
case COMPONENT_LIGHT_ROW1_LEVEL0_TOUCHPOINT:
case COMPONENT_LIGHT_ROW1_SLIDER:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(1, 0);
lightLevelRow1 = this->getNumber("light_r1_slide.val");
toggleSliderLight(1, lightLevelRow1);
break;
case COMPONENT_LIGHT_ROW1_LEVEL1_TOUCHPOINT:
case COMPONENT_LIGHT_ROW2_SLIDER:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(1, 1);
lightLevelRow2 = this->getNumber("light_r2_slide.val");
toggleSliderLight(2, lightLevelRow2);
break;
case COMPONENT_LIGHT_ROW1_LEVEL2_TOUCHPOINT:
case COMPONENT_LIGHT_ROW3_SLIDER:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(1, 2);
lightLevelRow3 = this->getNumber("light_r3_slide.val");
toggleSliderLight(3, lightLevelRow3);
break;
case COMPONENT_LIGHT_ROW1_LEVEL3_TOUCHPOINT:
case COMPONENT_LIGHT_ROW4_SLIDER:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(1, 3);
lightLevelRow4 = this->getNumber("light_r4_slide.val");
toggleSliderLight(4, lightLevelRow4);
break;
case COMPONENT_LIGHT_ROW2_LEVEL0_TOUCHPOINT:
case COMPONENT_LIGHT_ROW1_SWITCH:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(2, 0);
toggleLightIndividual(1);
break;
case COMPONENT_LIGHT_ROW2_LEVEL1_TOUCHPOINT:
case COMPONENT_LIGHT_ROW2_SWITCH:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(2, 1);
toggleLightIndividual(2);
break;
case COMPONENT_LIGHT_ROW2_LEVEL2_TOUCHPOINT:
case COMPONENT_LIGHT_ROW3_SWITCH:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(2, 2);
toggleLightIndividual(3);
break;
case COMPONENT_LIGHT_ROW2_LEVEL3_TOUCHPOINT:
case COMPONENT_LIGHT_ROW4_SWITCH:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(2, 3);
break;
case COMPONENT_LIGHT_ROW3_LEVEL0_TOUCHPOINT:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(3, 0);
break;
case COMPONENT_LIGHT_ROW3_LEVEL1_TOUCHPOINT:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(3, 1);
break;
case COMPONENT_LIGHT_ROW3_LEVEL2_TOUCHPOINT:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(3, 2);
break;
case COMPONENT_LIGHT_ROW3_LEVEL3_TOUCHPOINT:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(3, 3);
break;
case COMPONENT_LIGHT_ROW4_LEVEL0_TOUCHPOINT:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(4, 0);
break;
case COMPONENT_LIGHT_ROW4_LEVEL1_TOUCHPOINT:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(4, 1);
break;
case COMPONENT_LIGHT_ROW4_LEVEL2_TOUCHPOINT:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(4, 2);
break;
case COMPONENT_LIGHT_ROW4_LEVEL3_TOUCHPOINT:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
setLightLevel(4, 3);
toggleLightIndividual(4);
break;
// TODO : Don't we have fan only mode too? can you really just switch between 0 and 1?
case COMPONENT_AC_TOGGLE_BUTTON:
@ -199,14 +161,13 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
case COMPONENT_AC_MODE:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
this->climateCard->setMode(this->climateCard->getMode() == 0 ? 1 : 0);
// need fix
changeUserACmode();
break;
case COMPONENT_AC_FAN_SPEED:
if (touch_type != TOUCH_TYPE_RELEASE)
break;
fan_speed = this->climateCard->getFanSpeed();
// TODO : 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
this->climateCard->setFanSpeed((fan_speed + 1) % 4);
break;
@ -315,12 +276,11 @@ void ISEDisplay::updateDateTimeText(rtctime_t time)
// appdeamon
void ISEDisplay::updateWeather(uint8_t weather_code, float outside_temp)
{
// TODO : use remotevar to get weather data from appdaemon and update the display
}
void ISEDisplay::updatePMoutside(float pm25_outside)
{
// TODO : use remotevar to get data from appdaemon and update the display
// TODO : use remotevar to get PM2.5 data from appdaemon and update the display
}
void ISEDisplay::updatePMinside(float pm25_inside)
{
@ -399,7 +359,7 @@ void ISEDisplay::setLightLevel(uint8_t row, uint8_t level)
for (uint8_t i = 1; i <= 4; i++)
{
if (row == i)
this->outputCard->setState(row, level);
this->outputCard->setValue(row, level);
}
}
@ -437,7 +397,7 @@ void ISEDisplay::updateLightGroupStatePageDashboard()
for (uint8_t i = 1; i <= 4; i++)
{
u_int8_t state = this->outputCard->getState(i);
u_int8_t state = this->outputCard->getValue(i);
switch (state)
{
case 0:
@ -481,7 +441,7 @@ bool ISEDisplay::calculateLightGroupState()
bool lightOn = false;
for (uint8_t i = 1; i <= 4; i++)
{
if (this->outputCard->getState(i) != 0)
if (this->outputCard->getValue(i) != 0)
{
lightOn = true;
break;
@ -489,6 +449,50 @@ bool ISEDisplay::calculateLightGroupState()
}
return lightOn;
}
void ISEDisplay::toggleLightIndividual(uint8_t row)
{
// Get the current state
uint8_t state = this->outputCard->getValue(row);
if (state != 0)
{
state = 0;
}
else
{
state = 3;
}
// Set the state
setLightLevel(row, state);
}
void ISEDisplay::toggleSliderLight(uint8_t row, uint8_t lightLevel)
{
// Get the current state
uint8_t state = 0;
if (lightLevel < 10)
{
state = 0;
}
else if (lightLevel < 33)
{
state = 1;
}
else if (lightLevel <= 66)
{
state = 2;
}
else if (lightLevel > 66)
{
state = 3;
}
else
{
state = 0;
}
// Set the state
setLightLevel(row, state);
}
void ISEDisplay::updateAirPurifierState()
{
// Get the state
@ -518,6 +522,7 @@ void ISEDisplay::updateAirPurifierState()
}
void ISEDisplay::updateuserACmode()
{
this->takeSerialMutex();
switch (user_mode)
{
case 1:
@ -539,10 +544,12 @@ void ISEDisplay::updateuserACmode()
default:
break;
}
this->giveSerialMutex();
}
void ISEDisplay::updateACfanSpeed()
{
uint8_t fan_speed = this->climateCard->getFanSpeed();
this->takeSerialMutex();
switch (fan_speed)
{
case 0:
@ -580,6 +587,7 @@ void ISEDisplay::updateACfanSpeed()
default:
break;
}
this->giveSerialMutex();
}
void ISEDisplay::updateACState()
{