complete touch module

This commit is contained in:
Siwat Sirichai 2023-09-03 22:55:07 +07:00
parent 4e9b98b4d7
commit b585db50bb
1 changed files with 99 additions and 2 deletions

View File

@ -117,7 +117,20 @@ void lcd_top_bar_update();
void trigger0();
void trigger1();
void trigger2();
void trigger3();
void trigger4();
void trigger5();
void trigger6();
void trigger7();
void trigger8();
void trigger9();
void trigger10();
void trigger11();
void trigger12();
void trigger13();
void lcd_ac_refresh_fan();
void lcd_ac_refresh_mode();
char PWM_STATE_TOPIC[75] = MQTT_BASE_TOPIC "/pwm/00/state";
char PWM_VALUE_TOPIC[75] = MQTT_BASE_TOPIC "/pwm/00/value";
@ -499,7 +512,6 @@ void publish_ac_state()
break;
}
mqtt.publish(String(AC_FAN_TOPIC), temp);
Serial.println("AC State Published.");
}
void ac_state_callback(String topic, String message)
@ -554,6 +566,16 @@ void ac_set_state(int mode, int temperature, int fan_speed)
ac_temperature = temperature;
ac_fan_speed = fan_speed;
temperature -= AC_MIN_TEMPERATURE;
if (lcd_current_page == 4)
{
lcd_ac_refresh_fan();
lcd_ac_refresh_mode();
if (ac_mode != 2)
panel.writeStr("temp.txt", String(ac_temperature) + "C");
else
panel.writeStr("temp.txt", "--C");
}
publish_ac_state();
switch (mode)
{
@ -641,11 +663,19 @@ void lcd_refresh()
panel.writeNum("j" + String(i) + ".pco", pwm_states[i] ? 47829 : 12710);
}
break;
case 4:
if (ac_mode != 2)
panel.writeStr("temp.txt", String(ac_temperature) + "C");
else
panel.writeStr("temp.txt", "--C");
lcd_ac_refresh_fan();
lcd_ac_refresh_mode();
case 5:
panel.writeStr("pwm_id.txt", String("P") + String(lcd_pwmAdj_id));
panel.writeStr("pwm_state.txt", pwm_states[lcd_pwmAdj_id] ? "ON" : "OFF");
panel.writeNum("pwm_value.val", pwm_values[lcd_pwmAdj_id]);
break;
default:
break;
}
@ -657,6 +687,22 @@ void lcd_top_bar_update()
panel.writeNum("lan.pic", ETH.linkUp() ? 3 : 2);
}
void lcd_ac_refresh_mode()
{
// auto high mid low
panel.writeNum("mode_cool.pic", ac_mode == 1 ? 12 : 13);
panel.writeNum("mode_fan.pic", ac_mode == 2 ? 22 : 23);
panel.writeNum("mode_off.pic", ac_mode == 0 ? 24 : 25);
}
void lcd_ac_refresh_fan()
{
panel.writeNum("fan_auto.pic", ac_fan_speed == 0 ? 14 : 15);
panel.writeNum("fan_low.pic", ac_fan_speed == 3 ? 18 : 19);
panel.writeNum("fan_mid.pic", ac_fan_speed == 2 ? 20 : 21);
panel.writeNum("fan_high.pic", ac_fan_speed == 1 ? 16 : 17);
}
void trigger0()
{
if (lcd_pwmAdj_id >= 15)
@ -685,5 +731,56 @@ void trigger3()
int value = panel.readNumber("pwm_value.val");
Serial.println(value);
lcd_send_stop_bit();
pwm_set_value(lcd_pwmAdj_id,value);
pwm_set_value(lcd_pwmAdj_id, value);
}
void trigger4()
{
if (ac_temperature < AC_MAX_TEMPERATURE && ac_mode != 2)
ac_set_state(ac_mode, ac_temperature + 1, ac_fan_speed);
}
void trigger5()
{
if (ac_temperature > AC_MIN_TEMPERATURE && ac_mode != 2)
ac_set_state(ac_mode, ac_temperature - 1, ac_fan_speed);
}
void trigger6()
{
ac_set_state(ac_mode, ac_temperature, 0);
}
void trigger7()
{
ac_set_state(ac_mode, ac_temperature, 3);
}
void trigger8()
{
ac_set_state(ac_mode, ac_temperature, 2);
}
void trigger9()
{
ac_set_state(ac_mode, ac_temperature, 1);
}
void trigger10()
{
ac_set_state(1, ac_temperature, ac_fan_speed);
}
void trigger11()
{
ac_set_state(2, ac_temperature, ac_fan_speed);
}
void trigger12()
{
ac_set_state(0, ac_temperature, ac_fan_speed);
}
void trigger13()
{
}