fix ac_toggle -> air_toggle

This commit is contained in:
reaw55 2024-01-08 22:25:34 +07:00
parent 74cb7530fe
commit cad22768ce
1 changed files with 42 additions and 32 deletions

View File

@ -20,7 +20,7 @@ NexButton temp_plus = NexButton(1, 18, "temp_plus");
NexButton temp_neg = NexButton(1, 17, "temp_neg");
NexButton fan = NexButton(1, 16, "fan");
NexButton mode = NexButton(1, 15, "mode");
NexButton ac_toggle = NexButton(1, 1, "ac_toggle");
NexButton air_toggle = NexButton(1, 1, "air_toggle");
NexText cur_temp = NexText(1, 19, "cur_temp");
// List of Component ID Message to listen to
NexTouch *nex_listen_list[] =
@ -42,7 +42,7 @@ NexTouch *nex_listen_list[] =
&temp_neg,
&fan,
&mode,
&ac_toggle,
&air_toggle,
NULL};
bool row_is_on(int light1_pin, int light2_pin)
@ -152,11 +152,21 @@ void mode_pop_callback(void *ptr)
user_acmode = 1;
ac_set_state(1, ac_get_temperature(), ac_get_fan_speed());
}
else {
if (user_acmode == 1)
{
user_acmode = 2;
}
else
{
user_acmode = 1;
}
}
// ac_set_state(new_mode, ac_get_temperature(), ac_get_fan_speed());
}
void ac_toggle_pop_callback(void *ptr)
void air_toggle_pop_callback(void *ptr)
{
// this function should set the state of the AC to toggle between off (mode 0) and the same state as before store in variable acmode
// val user_acmode already initialized to 1 (cool mode)
@ -239,7 +249,7 @@ void user_init()
temp_neg.attachPop(temp_neg_pop_callback, &temp_neg);
fan.attachPop(fan_pop_callback, &fan);
mode.attachPop(mode_pop_callback, &mode);
ac_toggle.attachPop(ac_toggle_pop_callback, &ac_toggle);
air_toggle.attachPop(air_toggle_pop_callback, &air_toggle);
update_lcd_row1();
update_lcd_row2();
update_lcd_row3();
@ -453,27 +463,27 @@ void update_lcd_ac()
}
// update the mode cool is 22, fan mode is 24, for off the toggle button act as indicator
// Mode 0: Off, 1: Cool, 2: Fan
uint8_t mode_state = user_acmode;
//uint8_t mode_state = user_acmode;
// mode.Set_background_image_pic(mode_state==1?22:24);
elcd_send_stop_bit();
if (mode_state == 1)
if (user_acmode == 1)
{
elcd_send_stop_bit();
elcd.print("ac_toggle.pic=2");
elcd.print("air_toggle.pic=2");
elcd_send_stop_bit();
elcd.print("ac_toggle.pic2=2");
elcd.print("air_toggle.pic2=2");
elcd_send_stop_bit();
elcd.print("mode.pic=22");
elcd_send_stop_bit();
elcd.print("mode.pic2=22");
elcd_send_stop_bit();
}
else if (mode_state == 2)
else if (user_acmode == 2)
{
elcd_send_stop_bit();
elcd.print("ac_toggle.pic=2");
elcd.print("air_toggle.pic=2");
elcd_send_stop_bit();
elcd.print("ac_toggle.pic2=2");
elcd.print("air_toggle.pic2=2");
elcd_send_stop_bit();
elcd.print("mode.pic=24");
elcd_send_stop_bit();
@ -483,25 +493,25 @@ void update_lcd_ac()
else if (ac_get_mode() == 0)
{
elcd_send_stop_bit();
elcd.print("ac_toggle.pic=1");
elcd.print("air_toggle.pic=1");
elcd_send_stop_bit();
elcd.print("ac_toggle.pic2=1");
// if (user_acmode == 1)
// {
// elcd_send_stop_bit();
// elcd.print("mode.pic=22");
// elcd_send_stop_bit();
// elcd.print("mode.pic2=22");
// elcd_send_stop_bit();
// }
// else
// {
// elcd_send_stop_bit();
// elcd.print("mode.pic=24");
// elcd_send_stop_bit();
// elcd.print("mode.pic2=24");
// elcd_send_stop_bit();
// }
elcd.print("air_toggle.pic2=1");
if (user_acmode == 1)
{
elcd_send_stop_bit();
elcd.print("mode.pic=22");
elcd_send_stop_bit();
elcd.print("mode.pic2=22");
elcd_send_stop_bit();
}
else
{
elcd_send_stop_bit();
elcd.print("mode.pic=24");
elcd_send_stop_bit();
elcd.print("mode.pic2=24");
elcd_send_stop_bit();
}
}
/* elcd.print("mode.pic=");
elcd.print(mode_state==1?22:24);
@ -510,12 +520,12 @@ void update_lcd_ac()
elcd.print(mode_state==1?22:24);
elcd_send_stop_bit();
//update the ac toggle button
//ac_toggle.Set_background_image_pic(ac_get_mode()==0?1:2);
//air_toggle.Set_background_image_pic(ac_get_mode()==0?1:2);
elcd_send_stop_bit();
elcd.print("ac_toggle.pic=");
elcd.print("air_toggle.pic=");
elcd.print(ac_get_mode()==0?2:1);
elcd_send_stop_bit();
elcd.print("ac_toggle.pic2=");
elcd.print("air_toggle.pic2=");
elcd.print(ac_get_mode()==0?2:1);
elcd_send_stop_bit(); */
}