update ac mode

This commit is contained in:
reaw55 2024-01-08 18:30:17 +07:00
parent d5baddd873
commit 9739ddcf16
1 changed files with 52 additions and 4 deletions

View File

@ -1,6 +1,6 @@
#include <user_code.hpp> #include <user_code.hpp>
uint8_t user_acmode = 0; uint8_t user_acmode = 1;
// Display Componets // Display Componets
// Link with Dual state button object with id 2 on page 1 named bt0 // Link with Dual state button object with id 2 on page 1 named bt0
NexButton light_toggle = NexButton(1,2,"light_toggle"); NexButton light_toggle = NexButton(1,2,"light_toggle");
@ -143,13 +143,20 @@ void mode_pop_callback(void *ptr)
void ac_toggle_pop_callback(void *ptr) void ac_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 //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)
if (ac_get_mode() == 0) { if (ac_get_mode() == 0) {
ac_set_state(user_acmode, ac_get_temperature(), ac_get_fan_speed()); ac_set_state(user_acmode, ac_get_temperature(), ac_get_fan_speed());
} else { } else {
user_acmode = ac_get_mode(); user_acmode = ac_get_mode();
ac_set_state(0, ac_get_temperature(), ac_get_fan_speed()); ac_set_state(0, ac_get_temperature(), ac_get_fan_speed());
} }
/* if (ac_get_mode() == 0) {
//ac_set_state(user_acmode, ac_get_temperature(), ac_get_fan_speed());
} else {
user_acmode = ac_get_mode();
ac_set_state(0, ac_get_temperature(), ac_get_fan_speed());
}
*/
} }
void row1_master_pop_callback(void *ptr) void row1_master_pop_callback(void *ptr)
@ -417,7 +424,48 @@ void update_lcd_ac() {
uint8_t mode_state = ac_get_mode(); uint8_t mode_state = ac_get_mode();
//mode.Set_background_image_pic(mode_state==1?22:24); //mode.Set_background_image_pic(mode_state==1?22:24);
elcd_send_stop_bit(); elcd_send_stop_bit();
elcd.print("mode.pic="); if(mode_state==1){
elcd_send_stop_bit();
elcd.print("ac_toggle.pic=2");
elcd_send_stop_bit();
elcd.print("ac_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){
elcd_send_stop_bit();
elcd.print("ac_toggle.pic=2");
elcd_send_stop_bit();
elcd.print("ac_toggle.pic2=2");
elcd_send_stop_bit();
elcd.print("mode.pic=24");
elcd_send_stop_bit();
elcd.print("mode.pic2=24");
elcd_send_stop_bit();
} else{
elcd_send_stop_bit();
elcd.print("ac_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("mode.pic=");
elcd.print(mode_state==1?22:24); elcd.print(mode_state==1?22:24);
elcd_send_stop_bit(); elcd_send_stop_bit();
elcd.print("mode.pic2="); elcd.print("mode.pic2=");
@ -431,7 +479,7 @@ void update_lcd_ac() {
elcd_send_stop_bit(); elcd_send_stop_bit();
elcd.print("ac_toggle.pic2="); elcd.print("ac_toggle.pic2=");
elcd.print(ac_get_mode()==0?2:1); elcd.print(ac_get_mode()==0?2:1);
elcd_send_stop_bit(); elcd_send_stop_bit(); */
} }