adjust light call function

This commit is contained in:
reaw 2024-02-15 15:59:57 +07:00
parent ea4974893e
commit 2698363317
3 changed files with 28 additions and 7 deletions

View file

@ -40,10 +40,10 @@ void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCar
this->updateACState(); this->updateACState();
this->updateLightGroupStatePageDashboard(); this->updateLightGroupStatePageDashboard();
this->outputCard->setValue(1, 0); // this->outputCard->setValue(1, 0);
this->outputCard->setValue(2, 0); // this->outputCard->setValue(2, 0);
this->outputCard->setValue(3, 0); // this->outputCard->setValue(3, 0);
this->outputCard->setValue(4, 0); // this->outputCard->setValue(4, 0);
this->climateCard->setTemperature(ac_temperature); this->climateCard->setTemperature(ac_temperature);
this->climateCard->setFanSpeed(ac_fan_speed); this->climateCard->setFanSpeed(ac_fan_speed);
this->climateCard->setMode(ac_mode); this->climateCard->setMode(ac_mode);
@ -563,6 +563,14 @@ void ISEDisplay::setLightLevel(uint8_t row, uint8_t level)
} }
} }
u_int8_t ISEDisplay::getLightLevel(uint8_t row)
{
u_int8_t lightLevel = 0;
lightLevel = this->outputCard->getValue(row);
return lightLevel;
}
void ISEDisplay::updateLightGroupStatePageStandby() void ISEDisplay::updateLightGroupStatePageStandby()
{ {
// Calculate the state // Calculate the state
@ -597,7 +605,7 @@ void ISEDisplay::updateLightGroupStatePageDashboard()
for (uint8_t i = 1; i <= 4; i++) for (uint8_t i = 1; i <= 4; i++)
{ {
u_int8_t state = this->outputCard->getValue(i); u_int8_t state = getLightLevel(i);
switch (state) switch (state)
{ {
case 0: case 0:
@ -641,7 +649,7 @@ bool ISEDisplay::calculateLightGroupState()
bool lightOn = false; bool lightOn = false;
for (uint8_t i = 1; i <= 4; i++) for (uint8_t i = 1; i <= 4; i++)
{ {
if (this->outputCard->getValue(i) != 0) if (getLightLevel(i) != 0)
{ {
lightOn = true; lightOn = true;
break; break;
@ -649,10 +657,11 @@ bool ISEDisplay::calculateLightGroupState()
} }
return lightOn; return lightOn;
} }
void ISEDisplay::toggleLightIndividual(uint8_t row) void ISEDisplay::toggleLightIndividual(uint8_t row)
{ {
// Get the current state // Get the current state
uint8_t state = this->outputCard->getValue(row); uint8_t state = getLightLevel(row);
if (state != 0) if (state != 0)
{ {
state = 0; state = 0;

View file

@ -42,6 +42,7 @@ class ISEDisplay : public ESPMegaDisplay {
void setPMstate(bool is_pm_on, uint8_t pm_fan_speed); void setPMstate(bool is_pm_on, uint8_t pm_fan_speed);
void setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_temperature); void setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_temperature);
void setLightLevel(uint8_t row, uint8_t level); void setLightLevel(uint8_t row, uint8_t level);
u_int8_t getLightLevel(uint8_t row);
DigitalInputCard* inputCard; DigitalInputCard* inputCard;
DigitalOutputCard *outputCard; DigitalOutputCard *outputCard;

View file

@ -11,6 +11,17 @@ tentetive pin mapping
4: row 4 4: row 4
(value from 0-3) (value from 0-3)
change light assignment
1: row 1 column 1
2: row 1 column 2
3: row 2 column 1
4: row 2 column 2
5: row 3 column 1
6: row 3 column 2
7: row 4 column 1
8: row 4 column 2
5: Air Purifier status (on/off) 5: Air Purifier status (on/off)
6: Air Purifier fan speed (0-20) 6: Air Purifier fan speed (0-20)