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

@ -34,6 +34,8 @@ object id:
6 s_time (txt)
7 s_date (txt)
8 s_outside_temp (txt)
9 idle_timer (timer) // wait one min for inactivity then dim screen
10 s_weather_icon (pic)
picture id:
@ -132,22 +134,30 @@ object id:
18 light_m_l1
19 light_m_l2
20 light_m_l3
21 light_1_l0
22 light_1_l1
23 light_1_l2
24 light_1_l3
25 light_2_l0
26 light_2_l1
27 light_2_l2
28 light_2_l3
29 light_3_l0
30 light_3_l1
31 light_3_l2
32 light_3_l3
33 light_4_l0
34 light_4_l1
35 light_4_l2
36 light_4_l3
37 time (txt)
38 date (txt)
39 outside_temp (txt)
21 time (txt)
22 date (txt)
23 outside_temp (txt)
24 light_r1_slide
25 light_r2_slide
26 light_r3_slide
27 light_r4_slide
28 light_row1_sw
29 light_row2_sw
30 light_row3_sw
31 light_row4_sw
32 weather_icon (pic)
weather picture id:
63 fair_day
64 fair_night
65 cloudy
66 clearsky_day
67 clearsky_night
68 partlycloudy_day
69 partlycloudy_night
70 heavyrain
71 heavyrainandthunder
72 rainandthunder
73 rain
74 lightrain
75 fog

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()
{

View file

@ -43,6 +43,7 @@ class ISEDisplay : public ESPMegaDisplay {
uint8_t climateCallbackHandle;
uint8_t user_mode;
uint8_t time_since_last_screen_update;
void updateLightGroupStatePageDashboard();
@ -51,6 +52,8 @@ class ISEDisplay : public ESPMegaDisplay {
void updateACState();
bool calculateLightGroupState();
void toggleLightGroupState();
void toggleLightIndividual(uint8_t row);
void toggleSliderLight(uint8_t row,uint8_t lightLevel);
void togglePM();
void toggleAC();
void changeUserACmode();

View file

@ -9,6 +9,7 @@ tentetive pin mapping
2: row 2
3: row 3
4: row 4
(value from 0-3)
5: Air Purifier status (on/off)
6: Air Purifier fan speed (0-20)
@ -57,6 +58,9 @@ lights have 4 states
#define COMPONENT_STANDBY_DATE_TXT 7
#define COMPONENT_STANDBY_OUTSIDE_TEMP_TXT 8
#define COMPONENT_STANDBY_TIMER 9
#define COMPONENT_STANDBY_WEATHER_ICON 10
//standby page picture id
#define COMPONENT_BACKGROUND_PIC 44
#define COMPONENT_BACKGROUND_REFERENCE_PIC 45
@ -111,29 +115,21 @@ lights have 4 states
#define COMPONENT_LIGHT_MASTER_LEVEL2_TOUCHPOINT 19
#define COMPONENT_LIGHT_MASTER_LEVEL3_TOUCHPOINT 20
#define COMPONENT_LIGHT_ROW1_LEVEL0_TOUCHPOINT 21
#define COMPONENT_LIGHT_ROW1_LEVEL1_TOUCHPOINT 22
#define COMPONENT_LIGHT_ROW1_LEVEL2_TOUCHPOINT 23
#define COMPONENT_LIGHT_ROW1_LEVEL3_TOUCHPOINT 24
#define COMPONENT_DASHBOARD_TIME_TXT 21
#define COMPONENT_DASHBOARD_DATE_TXT 22
#define COMPONENT_DASHBOARD_OUTSIDE_TEMP_TXT 23
#define COMPONENT_LIGHT_ROW2_LEVEL0_TOUCHPOINT 25
#define COMPONENT_LIGHT_ROW2_LEVEL1_TOUCHPOINT 26
#define COMPONENT_LIGHT_ROW2_LEVEL2_TOUCHPOINT 27
#define COMPONENT_LIGHT_ROW2_LEVEL3_TOUCHPOINT 28
#define COMPONENT_LIGHT_ROW1_SLIDER 24
#define COMPONENT_LIGHT_ROW2_SLIDER 25
#define COMPONENT_LIGHT_ROW3_SLIDER 26
#define COMPONENT_LIGHT_ROW4_SLIDER 27
#define COMPONENT_LIGHT_ROW3_LEVEL0_TOUCHPOINT 29
#define COMPONENT_LIGHT_ROW3_LEVEL1_TOUCHPOINT 30
#define COMPONENT_LIGHT_ROW3_LEVEL2_TOUCHPOINT 31
#define COMPONENT_LIGHT_ROW3_LEVEL3_TOUCHPOINT 32
#define COMPONENT_LIGHT_ROW1_SWITCH 28
#define COMPONENT_LIGHT_ROW2_SWITCH 29
#define COMPONENT_LIGHT_ROW3_SWITCH 30
#define COMPONENT_LIGHT_ROW4_SWITCH 31
#define COMPONENT_LIGHT_ROW4_LEVEL0_TOUCHPOINT 33
#define COMPONENT_LIGHT_ROW4_LEVEL1_TOUCHPOINT 34
#define COMPONENT_LIGHT_ROW4_LEVEL2_TOUCHPOINT 35
#define COMPONENT_LIGHT_ROW4_LEVEL3_TOUCHPOINT 36
#define COMPONENT_DASHBOARD_TIME_TXT 37
#define COMPONENT_DASHBOARD_DATE_TXT 38
#define COMPONENT_DASHBOARD_OUTSIDE_TEMP_TXT 39
#define COMPONENT_DASHBOARD_WEATHER_ICON 32
//dashboard page picture id
@ -196,7 +192,20 @@ lights have 4 states
#define COMPONENT_LIGHT_LEVEL_3 42
//weather icon legend
#define COMPONENT_WEATHER_ICON_FAIR_DAY 63
#define COMPONENT_WEATHER_ICON_FAIR_NIGHT 64
#define COMPONENT_WEATHER_ICON_CLOUDY 65
#define COMPONENT_WEATHER_ICON_CLEARSKY_DAY 66
#define COMPONENT_WEATHER_ICON_CLEARSKY_NIGHT 67
#define COMPONENT_WEATHER_ICON_PARTLYCLOUDY_DAY 68
#define COMPONENT_WEATHER_ICON_PARTLYCLOUDY_NIGHT 69
#define COMPONENT_WEATHER_ICON_HEAVY_RAIN 70
#define COMPONENT_WEATHER_ICON_HEAVY_RAIN_AND_THUNDER 71
#define COMPONENT_WEATHER_ICON_RAIN_AND_THUNDER 72
#define COMPONENT_WEATHER_ICON_RAIN 73
#define COMPONENT_WEATHER_ICON_LIGHT_RAIN 74
#define COMPONENT_WEATHER_ICON_FOG 75
//need to toggle 4 row of light independently and have one master switch that can control all