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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 904 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 951 B

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 6 KiB

After

Width:  |  Height:  |  Size: 6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -34,6 +34,8 @@ object id:
6 s_time (txt) 6 s_time (txt)
7 s_date (txt) 7 s_date (txt)
8 s_outside_temp (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: picture id:
@ -132,22 +134,30 @@ object id:
18 light_m_l1 18 light_m_l1
19 light_m_l2 19 light_m_l2
20 light_m_l3 20 light_m_l3
21 light_1_l0 21 time (txt)
22 light_1_l1 22 date (txt)
23 light_1_l2 23 outside_temp (txt)
24 light_1_l3 24 light_r1_slide
25 light_2_l0 25 light_r2_slide
26 light_2_l1 26 light_r3_slide
27 light_2_l2 27 light_r4_slide
28 light_2_l3 28 light_row1_sw
29 light_3_l0 29 light_row2_sw
30 light_3_l1 30 light_row3_sw
31 light_3_l2 31 light_row4_sw
32 light_3_l3 32 weather_icon (pic)
33 light_4_l0
34 light_4_l1 weather picture id:
35 light_4_l2 63 fair_day
36 light_4_l3 64 fair_night
37 time (txt) 65 cloudy
38 date (txt) 66 clearsky_day
39 outside_temp (txt) 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) ISEDisplay::ISEDisplay(HardwareSerial *adapter) : ESPMegaDisplay(adapter, 115200, 912600, 4, 17)
{ {
} }
// sat->sun // Work left
// TODO : Implement // TODO : Implement
// debug to complie
// standby
// dimable
// sun -> mon
// debug to work // debug to work
// appdeamon send data / receive data // appdeamon send data / receive data
// sound
// mon -> tue
// slider
void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCard, ClimateCard *climateCard) void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCard, ClimateCard *climateCard)
{ {
this->inputCard = inputCard; 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 pm_fan_speed = 0;
u_int8_t 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)
{ {
case COMPONENT_LIGHT_MASTER_BUTTON: case COMPONENT_LIGHT_MASTER_BUTTON:
@ -110,85 +108,49 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
break; break;
// TODOlater : can't this be done better with array lookup? // 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) if (touch_type != TOUCH_TYPE_RELEASE)
break; break;
setLightLevel(1, 0); lightLevelRow1 = this->getNumber("light_r1_slide.val");
toggleSliderLight(1, lightLevelRow1);
break; break;
case COMPONENT_LIGHT_ROW1_LEVEL1_TOUCHPOINT: case COMPONENT_LIGHT_ROW2_SLIDER:
if (touch_type != TOUCH_TYPE_RELEASE) if (touch_type != TOUCH_TYPE_RELEASE)
break; break;
setLightLevel(1, 1); lightLevelRow2 = this->getNumber("light_r2_slide.val");
toggleSliderLight(2, lightLevelRow2);
break; break;
case COMPONENT_LIGHT_ROW1_LEVEL2_TOUCHPOINT: case COMPONENT_LIGHT_ROW3_SLIDER:
if (touch_type != TOUCH_TYPE_RELEASE) if (touch_type != TOUCH_TYPE_RELEASE)
break; break;
setLightLevel(1, 2); lightLevelRow3 = this->getNumber("light_r3_slide.val");
toggleSliderLight(3, lightLevelRow3);
break; break;
case COMPONENT_LIGHT_ROW1_LEVEL3_TOUCHPOINT: case COMPONENT_LIGHT_ROW4_SLIDER:
if (touch_type != TOUCH_TYPE_RELEASE) if (touch_type != TOUCH_TYPE_RELEASE)
break; break;
setLightLevel(1, 3); lightLevelRow4 = this->getNumber("light_r4_slide.val");
toggleSliderLight(4, lightLevelRow4);
break; break;
case COMPONENT_LIGHT_ROW2_LEVEL0_TOUCHPOINT: case COMPONENT_LIGHT_ROW1_SWITCH:
if (touch_type != TOUCH_TYPE_RELEASE) if (touch_type != TOUCH_TYPE_RELEASE)
break; break;
setLightLevel(2, 0); toggleLightIndividual(1);
break; break;
case COMPONENT_LIGHT_ROW2_LEVEL1_TOUCHPOINT: case COMPONENT_LIGHT_ROW2_SWITCH:
if (touch_type != TOUCH_TYPE_RELEASE) if (touch_type != TOUCH_TYPE_RELEASE)
break; break;
setLightLevel(2, 1); toggleLightIndividual(2);
break; break;
case COMPONENT_LIGHT_ROW2_LEVEL2_TOUCHPOINT: case COMPONENT_LIGHT_ROW3_SWITCH:
if (touch_type != TOUCH_TYPE_RELEASE) if (touch_type != TOUCH_TYPE_RELEASE)
break; break;
setLightLevel(2, 2); toggleLightIndividual(3);
break; break;
case COMPONENT_LIGHT_ROW2_LEVEL3_TOUCHPOINT: case COMPONENT_LIGHT_ROW4_SWITCH:
if (touch_type != TOUCH_TYPE_RELEASE) if (touch_type != TOUCH_TYPE_RELEASE)
break; break;
setLightLevel(2, 3); toggleLightIndividual(4);
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);
break; break;
// TODO : Don't we have fan only mode too? can you really just switch between 0 and 1? // TODO : Don't we have fan only mode too? can you really just switch between 0 and 1?
case COMPONENT_AC_TOGGLE_BUTTON: 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: case COMPONENT_AC_MODE:
if (touch_type != TOUCH_TYPE_RELEASE) if (touch_type != TOUCH_TYPE_RELEASE)
break; break;
this->climateCard->setMode(this->climateCard->getMode() == 0 ? 1 : 0); changeUserACmode();
// need fix
break; break;
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(); 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 // mod 4 should fixed it
this->climateCard->setFanSpeed((fan_speed + 1) % 4); this->climateCard->setFanSpeed((fan_speed + 1) % 4);
break; break;
@ -315,12 +276,11 @@ void ISEDisplay::updateDateTimeText(rtctime_t time)
// appdeamon // appdeamon
void ISEDisplay::updateWeather(uint8_t weather_code, float outside_temp) 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) 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) 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++) for (uint8_t i = 1; i <= 4; i++)
{ {
if (row == 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++) 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) switch (state)
{ {
case 0: case 0:
@ -481,7 +441,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->getState(i) != 0) if (this->outputCard->getValue(i) != 0)
{ {
lightOn = true; lightOn = true;
break; break;
@ -489,6 +449,50 @@ bool ISEDisplay::calculateLightGroupState()
} }
return lightOn; 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() void ISEDisplay::updateAirPurifierState()
{ {
// Get the state // Get the state
@ -518,6 +522,7 @@ void ISEDisplay::updateAirPurifierState()
} }
void ISEDisplay::updateuserACmode() void ISEDisplay::updateuserACmode()
{ {
this->takeSerialMutex();
switch (user_mode) switch (user_mode)
{ {
case 1: case 1:
@ -539,10 +544,12 @@ void ISEDisplay::updateuserACmode()
default: default:
break; break;
} }
this->giveSerialMutex();
} }
void ISEDisplay::updateACfanSpeed() void ISEDisplay::updateACfanSpeed()
{ {
uint8_t fan_speed = this->climateCard->getFanSpeed(); uint8_t fan_speed = this->climateCard->getFanSpeed();
this->takeSerialMutex();
switch (fan_speed) switch (fan_speed)
{ {
case 0: case 0:
@ -580,6 +587,7 @@ void ISEDisplay::updateACfanSpeed()
default: default:
break; break;
} }
this->giveSerialMutex();
} }
void ISEDisplay::updateACState() void ISEDisplay::updateACState()
{ {

View file

@ -45,12 +45,15 @@ class ISEDisplay : public ESPMegaDisplay {
uint8_t time_since_last_screen_update; uint8_t time_since_last_screen_update;
void updateLightGroupStatePageDashboard(); void updateLightGroupStatePageDashboard();
void updateLightGroupStatePageStandby(); void updateLightGroupStatePageStandby();
void updateAirPurifierState(); void updateAirPurifierState();
void updateACState(); void updateACState();
bool calculateLightGroupState(); bool calculateLightGroupState();
void toggleLightGroupState(); void toggleLightGroupState();
void toggleLightIndividual(uint8_t row);
void toggleSliderLight(uint8_t row,uint8_t lightLevel);
void togglePM(); void togglePM();
void toggleAC(); void toggleAC();
void changeUserACmode(); void changeUserACmode();

View file

@ -9,6 +9,7 @@ tentetive pin mapping
2: row 2 2: row 2
3: row 3 3: row 3
4: row 4 4: row 4
(value from 0-3)
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)
@ -57,6 +58,9 @@ lights have 4 states
#define COMPONENT_STANDBY_DATE_TXT 7 #define COMPONENT_STANDBY_DATE_TXT 7
#define COMPONENT_STANDBY_OUTSIDE_TEMP_TXT 8 #define COMPONENT_STANDBY_OUTSIDE_TEMP_TXT 8
#define COMPONENT_STANDBY_TIMER 9
#define COMPONENT_STANDBY_WEATHER_ICON 10
//standby page picture id //standby page picture id
#define COMPONENT_BACKGROUND_PIC 44 #define COMPONENT_BACKGROUND_PIC 44
#define COMPONENT_BACKGROUND_REFERENCE_PIC 45 #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_LEVEL2_TOUCHPOINT 19
#define COMPONENT_LIGHT_MASTER_LEVEL3_TOUCHPOINT 20 #define COMPONENT_LIGHT_MASTER_LEVEL3_TOUCHPOINT 20
#define COMPONENT_LIGHT_ROW1_LEVEL0_TOUCHPOINT 21 #define COMPONENT_DASHBOARD_TIME_TXT 21
#define COMPONENT_LIGHT_ROW1_LEVEL1_TOUCHPOINT 22 #define COMPONENT_DASHBOARD_DATE_TXT 22
#define COMPONENT_LIGHT_ROW1_LEVEL2_TOUCHPOINT 23 #define COMPONENT_DASHBOARD_OUTSIDE_TEMP_TXT 23
#define COMPONENT_LIGHT_ROW1_LEVEL3_TOUCHPOINT 24
#define COMPONENT_LIGHT_ROW2_LEVEL0_TOUCHPOINT 25 #define COMPONENT_LIGHT_ROW1_SLIDER 24
#define COMPONENT_LIGHT_ROW2_LEVEL1_TOUCHPOINT 26 #define COMPONENT_LIGHT_ROW2_SLIDER 25
#define COMPONENT_LIGHT_ROW2_LEVEL2_TOUCHPOINT 27 #define COMPONENT_LIGHT_ROW3_SLIDER 26
#define COMPONENT_LIGHT_ROW2_LEVEL3_TOUCHPOINT 28 #define COMPONENT_LIGHT_ROW4_SLIDER 27
#define COMPONENT_LIGHT_ROW3_LEVEL0_TOUCHPOINT 29 #define COMPONENT_LIGHT_ROW1_SWITCH 28
#define COMPONENT_LIGHT_ROW3_LEVEL1_TOUCHPOINT 30 #define COMPONENT_LIGHT_ROW2_SWITCH 29
#define COMPONENT_LIGHT_ROW3_LEVEL2_TOUCHPOINT 31 #define COMPONENT_LIGHT_ROW3_SWITCH 30
#define COMPONENT_LIGHT_ROW3_LEVEL3_TOUCHPOINT 32 #define COMPONENT_LIGHT_ROW4_SWITCH 31
#define COMPONENT_LIGHT_ROW4_LEVEL0_TOUCHPOINT 33 #define COMPONENT_DASHBOARD_WEATHER_ICON 32
#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
//dashboard page picture id //dashboard page picture id
@ -196,7 +192,20 @@ lights have 4 states
#define COMPONENT_LIGHT_LEVEL_3 42 #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 //need to toggle 4 row of light independently and have one master switch that can control all