Use Nextion native components replacing command contruction
This commit is contained in:
@@ -187,11 +187,11 @@ api:
|
||||
then:
|
||||
- lambda: |-
|
||||
if (page == current_page->state and !id(is_uploading_tft)) {
|
||||
disp1->send_command_printf("%spic.picc=%u", id.c_str(), state ? 47 : 46);
|
||||
disp1->send_command_printf("%sbri.picc=%u", id.c_str(), state ? 47 : 46);
|
||||
disp1->send_command_printf("%stext.picc=%u", id.c_str(), state ? 47 : 46);
|
||||
disp1->send_command_printf("%sicon.picc=%u", id.c_str(), state ? 47 : 46);
|
||||
disp1->send_command_printf("%sicon.font=%" PRIu32, id.c_str(), icon_font);
|
||||
disp1->set_component_picc((id + "pic").c_str(), state ? 47 : 46);
|
||||
disp1->set_component_picc((id + "bri").c_str(), state ? 47 : 46);
|
||||
disp1->set_component_picc((id + "text").c_str(), state ? 47 : 46);
|
||||
disp1->set_component_picc((id + "icon").c_str(), state ? 47 : 46);
|
||||
disp1->set_component_font((id + "icon").c_str(), icon_font);
|
||||
disp1->set_component_foreground_color((id + "bri").c_str(), state ? 10597 : 65535);
|
||||
disp1->set_component_foreground_color((id + "text").c_str(), state ? 10597 : 65535);
|
||||
disp1->set_component_font_color((id + "icon").c_str(), esphome::display::ColorUtil::color_to_565(esphome::Color(icon_color[0], icon_color[1], icon_color[2])));
|
||||
@@ -564,7 +564,7 @@ api:
|
||||
// Alarm page - Buttons
|
||||
if (supported_features & 1 or state == "armed_home") // Alarm - Button - Home
|
||||
{
|
||||
disp1->send_command_printf("bt_home_pic.pic=%i", (state == "armed_home") ? 43 : 42); // To do: Replace this when esphome/esphome#6378 is merged
|
||||
disp1->set_component_pic("bt_home_pic", (state == "armed_home") ? 43 : 42);
|
||||
disp1->set_component_background_color("bt_home_text", (state == "armed_home") ? 19818 : 52857);
|
||||
disp1->set_component_background_color("bt_home_icon", (state == "armed_home") ? 19818 : 52857);
|
||||
disp1->set_component_font_color("bt_home_text", (state == "armed_home") ? 65535 : 0);
|
||||
@@ -574,7 +574,7 @@ api:
|
||||
}
|
||||
if (supported_features & 2 or state == "armed_away") // Alarm - Button - Away
|
||||
{
|
||||
disp1->send_command_printf("bt_away_pic.pic=%i", (state == "armed_away") ? 43 : 42); // To do: Replace this when esphome/esphome#6378 is merged
|
||||
disp1->set_component_pic("bt_away_pic", (state == "armed_away") ? 43 : 42);
|
||||
disp1->set_component_background_color("bt_away_text", (state == "armed_away") ? 19818 : 52857);
|
||||
disp1->set_component_background_color("bt_away_icon", (state == "armed_away") ? 19818 : 52857);
|
||||
disp1->set_component_font_color("bt_away_text", (state == "armed_away") ? 65535 : 0);
|
||||
@@ -583,7 +583,7 @@ api:
|
||||
}
|
||||
if (supported_features & 4 or state == "armed_night") // Alarm - Button - Night
|
||||
{
|
||||
disp1->send_command_printf("bt_night_pic.pic=%i", (state == "armed_night") ? 43 : 42); // To do: Replace this when esphome/esphome#6378 is merged
|
||||
disp1->set_component_pic("bt_night_pic", (state == "armed_night") ? 43 : 42);
|
||||
disp1->set_component_background_color("bt_night_text", (state == "armed_night") ? 19818 : 52857);
|
||||
disp1->set_component_background_color("bt_night_icon", (state == "armed_night") ? 19818 : 52857);
|
||||
disp1->set_component_font_color("bt_night_text", (state == "armed_night") ? 65535 : 0);
|
||||
@@ -592,7 +592,7 @@ api:
|
||||
}
|
||||
if (supported_features & 32 or state == "armed_vacation") // Alarm - Button - Vacation
|
||||
{
|
||||
disp1->send_command_printf("bt_vacat_pic.pic=%i", (state == "armed_vacation") ? 43 : 42); // To do: Replace this when esphome/esphome#6378 is merged
|
||||
disp1->set_component_pic("bt_vacat_pic", (state == "armed_vacation") ? 43 : 42);
|
||||
disp1->set_component_background_color("bt_vacat_text", (state == "armed_vacation") ? 19818 : 52857);
|
||||
disp1->set_component_background_color("bt_vacat_icon", (state == "armed_vacation") ? 19818 : 52857);
|
||||
disp1->set_component_font_color("bt_vacat_text", (state == "armed_vacation") ? 65535 : 0);
|
||||
@@ -601,7 +601,7 @@ api:
|
||||
}
|
||||
if (supported_features & 16 or state == "armed_bypass") // Alarm - Button - Custom bypass
|
||||
{
|
||||
disp1->send_command_printf("bt_bypass_pic.pic=%i", (state == "armed_bypass") ? 43 : 42); // To do: Replace this when esphome/esphome#6378 is merged
|
||||
disp1->set_component_pic("bt_bypass_pic", (state == "armed_bypass") ? 43 : 42);
|
||||
disp1->set_component_background_color("bt_bypass_text", (state == "armed_bypass") ? 19818 : 52857);
|
||||
disp1->set_component_background_color("bt_bypass_icon", (state == "armed_bypass") ? 19818 : 52857);
|
||||
disp1->set_component_font_color("bt_bypass_text", (state == "armed_bypass") ? 65535 : 0);
|
||||
@@ -610,7 +610,7 @@ api:
|
||||
}
|
||||
if ( true ) // Alarm - Button - Disarm
|
||||
{
|
||||
disp1->send_command_printf("bt_disarm_pic.pic=%i", (state == "disarmed") ? 43 : 42); // To do: Replace this when esphome/esphome#6378 is merged
|
||||
disp1->set_component_pic("bt_disarm_pic", (state == "disarmed") ? 43 : 42);
|
||||
disp1->set_component_background_color("bt_disarm_text", (state == "disarmed") ? 19818 : 52857);
|
||||
disp1->set_component_background_color("bt_disarm_icon", (state == "disarmed") ? 19818 : 52857);
|
||||
disp1->set_component_font_color("bt_disarm_text", (state == "disarmed") ? 65535 : 0);
|
||||
|
||||
Reference in New Issue
Block a user