From bcaeb0beb606255fcc97d95ad99c11149123fd01 Mon Sep 17 00:00:00 2001 From: Steve Meisner Date: Wed, 4 Oct 2023 21:05:29 -0400 Subject: [PATCH 01/10] UI changes for MQTT and updated to 1.3.2 of SLS (Caused a lot of change) --- app/src/ui/CMakeLists.txt | 1 + app/src/ui/components/ui_comp_hook.c | 2 +- app/src/ui/filelist.txt | 1 + app/src/ui/screens/ui_Info.c | 295 ++++---- app/src/ui/screens/ui_LessCommonSetup.c | 368 +++++----- app/src/ui/screens/ui_MainScreen.c | 457 ++++++------ app/src/ui/screens/ui_MatterConfig.c | 107 ++- app/src/ui/screens/ui_MqttConfig.c | 127 ++++ app/src/ui/screens/ui_Setup.c | 433 +++++------ app/src/ui/screens/ui_ThermostatRestart.c | 62 +- app/src/ui/screens/ui_WifiConfig.c | 266 +++---- app/src/ui/ui.c | 834 +++++++++++----------- app/src/ui/ui.h | 279 ++++---- app/src/ui/ui_events.cpp | 76 +- app/src/ui/ui_events.h | 4 +- app/src/ui/ui_helpers.c | 319 +++++---- app/src/ui/ui_helpers.h | 81 ++- 17 files changed, 1976 insertions(+), 1736 deletions(-) create mode 100644 app/src/ui/screens/ui_MqttConfig.c diff --git a/app/src/ui/CMakeLists.txt b/app/src/ui/CMakeLists.txt index 48e926e..f2a8b99 100644 --- a/app/src/ui/CMakeLists.txt +++ b/app/src/ui/CMakeLists.txt @@ -5,6 +5,7 @@ SET(SOURCES screens/ui_MainScreen.c screens/ui_WifiConfig.c screens/ui_MatterConfig.c screens/ui_ThermostatRestart.c + screens/ui_MqttConfig.c ui.c components/ui_comp_hook.c ui_helpers.c) diff --git a/app/src/ui/components/ui_comp_hook.c b/app/src/ui/components/ui_comp_hook.c index c8b7548..351bd29 100644 --- a/app/src/ui/components/ui_comp_hook.c +++ b/app/src/ui/components/ui_comp_hook.c @@ -1,5 +1,5 @@ // This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.3.1 +// SquareLine Studio version: SquareLine Studio 1.3.2 // LVGL version: 8.3.6 // Project name: Thermostat diff --git a/app/src/ui/filelist.txt b/app/src/ui/filelist.txt index baea8d0..4cf773e 100644 --- a/app/src/ui/filelist.txt +++ b/app/src/ui/filelist.txt @@ -5,6 +5,7 @@ screens/ui_LessCommonSetup.c screens/ui_WifiConfig.c screens/ui_MatterConfig.c screens/ui_ThermostatRestart.c +screens/ui_MqttConfig.c ui.c components/ui_comp_hook.c ui_helpers.c diff --git a/app/src/ui/screens/ui_Info.c b/app/src/ui/screens/ui_Info.c index 2bf3e18..f661748 100644 --- a/app/src/ui/screens/ui_Info.c +++ b/app/src/ui/screens/ui_Info.c @@ -1,5 +1,5 @@ // This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.3.1 +// SquareLine Studio version: SquareLine Studio 1.3.2 // LVGL version: 8.3.6 // Project name: Thermostat @@ -7,152 +7,151 @@ void ui_Info_screen_init(void) { - ui_Info = lv_obj_create(NULL); - lv_obj_add_state(ui_Info, LV_STATE_USER_1); /// States - lv_obj_clear_flag(ui_Info, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | - LV_OBJ_FLAG_SCROLL_MOMENTUM); /// Flags - lv_obj_set_scrollbar_mode(ui_Info, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_bg_color(ui_Info, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_Info, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_Info, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_Info, LV_GRAD_DIR_HOR, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_WifiConnectedLabel = lv_label_create(ui_Info); - lv_obj_set_width(ui_WifiConnectedLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_WifiConnectedLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_WifiConnectedLabel, 7); - lv_obj_set_y(ui_WifiConnectedLabel, -100); - lv_obj_set_align(ui_WifiConnectedLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_WifiConnectedLabel, "Connected:"); - lv_obj_set_style_text_font(ui_WifiConnectedLabel, &lv_font_montserrat_18, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_WifiConnCheckBox = lv_checkbox_create(ui_Info); - lv_checkbox_set_text(ui_WifiConnCheckBox, ""); - lv_obj_set_width(ui_WifiConnCheckBox, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_WifiConnCheckBox, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_WifiConnCheckBox, 120); - lv_obj_set_y(ui_WifiConnCheckBox, 8); - lv_obj_add_flag(ui_WifiConnCheckBox, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - lv_obj_clear_flag(ui_WifiConnCheckBox, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_CLICK_FOCUSABLE); /// Flags - lv_obj_set_style_text_font(ui_WifiConnCheckBox, &lv_font_montserrat_18, LV_PART_MAIN | LV_STATE_DEFAULT); - - lv_obj_set_style_bg_color(ui_WifiConnCheckBox, lv_color_hex(0xFFFFFF), LV_PART_INDICATOR | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_WifiConnCheckBox, 0, LV_PART_INDICATOR | LV_STATE_DEFAULT); - lv_obj_set_style_border_width(ui_WifiConnCheckBox, 1, LV_PART_INDICATOR | LV_STATE_DEFAULT); - - ui_WifiSsidLabel = lv_label_create(ui_Info); - lv_obj_set_width(ui_WifiSsidLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_WifiSsidLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_WifiSsidLabel, 160); - lv_obj_set_y(ui_WifiSsidLabel, -100); - lv_obj_set_align(ui_WifiSsidLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_WifiSsidLabel, "SSID:"); - lv_obj_set_style_text_font(ui_WifiSsidLabel, &lv_font_montserrat_18, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_IPLabel = lv_label_create(ui_Info); - lv_obj_set_width(ui_IPLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_IPLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_IPLabel, 7); - lv_obj_set_y(ui_IPLabel, -74); - lv_obj_set_align(ui_IPLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_IPLabel, "IP Address:"); - lv_obj_set_style_text_font(ui_IPLabel, &lv_font_montserrat_18, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_HostnameLabel = lv_label_create(ui_Info); - lv_obj_set_width(ui_HostnameLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_HostnameLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_HostnameLabel, 7); - lv_obj_set_y(ui_HostnameLabel, -48); - lv_obj_set_align(ui_HostnameLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_HostnameLabel, "Hostname:"); - lv_obj_set_style_text_font(ui_HostnameLabel, &lv_font_montserrat_18, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_RssiLabel = lv_label_create(ui_Info); - lv_obj_set_width(ui_RssiLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_RssiLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_RssiLabel, 7); - lv_obj_set_y(ui_RssiLabel, -22); - lv_obj_set_align(ui_RssiLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_RssiLabel, "Signal:"); - lv_obj_set_style_text_font(ui_RssiLabel, &lv_font_montserrat_18, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_FwVersionLabel = lv_label_create(ui_Info); - lv_obj_set_width(ui_FwVersionLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_FwVersionLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_FwVersionLabel, 7); - lv_obj_set_y(ui_FwVersionLabel, 4); - lv_obj_set_align(ui_FwVersionLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_FwVersionLabel, "Firmware:"); - lv_obj_set_style_text_font(ui_FwVersionLabel, &lv_font_montserrat_18, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_BuildDateLabel = lv_label_create(ui_Info); - lv_obj_set_width(ui_BuildDateLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_BuildDateLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_BuildDateLabel, 7); - lv_obj_set_y(ui_BuildDateLabel, 30); - lv_obj_set_align(ui_BuildDateLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_BuildDateLabel, "Build Date:"); - lv_obj_set_style_text_font(ui_BuildDateLabel, &lv_font_montserrat_18, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_CopyrightLabel = lv_label_create(ui_Info); - lv_obj_set_width(ui_CopyrightLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_CopyrightLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_CopyrightLabel, 7); - lv_obj_set_y(ui_CopyrightLabel, 56); - lv_obj_set_align(ui_CopyrightLabel, LV_ALIGN_LEFT_MID); - lv_label_set_long_mode(ui_CopyrightLabel, LV_LABEL_LONG_SCROLL_CIRCULAR); - lv_label_set_text(ui_CopyrightLabel, "Copyright: "); - lv_obj_set_style_text_align(ui_CopyrightLabel, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_font(ui_CopyrightLabel, &lv_font_montserrat_18, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_ShowQR = lv_btn_create(ui_Info); - lv_obj_set_width(ui_ShowQR, 100); - lv_obj_set_height(ui_ShowQR, 36); - lv_obj_set_x(ui_ShowQR, -108); - lv_obj_set_y(ui_ShowQR, -3); - lv_obj_set_align(ui_ShowQR, LV_ALIGN_BOTTOM_RIGHT); - lv_obj_add_flag(ui_ShowQR, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - lv_obj_clear_flag(ui_ShowQR, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_bg_color(ui_ShowQR, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_ShowQR, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_ShowQR, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_ShowQR, LV_GRAD_DIR_VER, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_ShowQRLabel = lv_label_create(ui_Info); - lv_obj_set_width(ui_ShowQRLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_ShowQRLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_ShowQRLabel, -124); - lv_obj_set_y(ui_ShowQRLabel, -14); - lv_obj_set_align(ui_ShowQRLabel, LV_ALIGN_BOTTOM_RIGHT); - lv_label_set_text(ui_ShowQRLabel, "Show QR"); - lv_obj_set_style_text_color(ui_ShowQRLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_opa(ui_ShowQRLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_HomeBtn = lv_btn_create(ui_Info); - lv_obj_set_width(ui_HomeBtn, 100); - lv_obj_set_height(ui_HomeBtn, 36); - lv_obj_set_x(ui_HomeBtn, -2); - lv_obj_set_y(ui_HomeBtn, -3); - lv_obj_set_align(ui_HomeBtn, LV_ALIGN_BOTTOM_RIGHT); - lv_obj_add_flag(ui_HomeBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - lv_obj_clear_flag(ui_HomeBtn, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_bg_color(ui_HomeBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_HomeBtn, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_HomeBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_HomeBtn, LV_GRAD_DIR_VER, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_HomeLabel = lv_label_create(ui_Info); - lv_obj_set_width(ui_HomeLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_HomeLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_HomeLabel, -30); - lv_obj_set_y(ui_HomeLabel, -14); - lv_obj_set_align(ui_HomeLabel, LV_ALIGN_BOTTOM_RIGHT); - lv_label_set_text(ui_HomeLabel, "Home"); - lv_obj_set_style_text_color(ui_HomeLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_opa(ui_HomeLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - - lv_obj_add_event_cb(ui_ShowQR, ui_event_ShowQR, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_HomeBtn, ui_event_HomeBtn, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_Info, ui_event_Info, LV_EVENT_ALL, NULL); +ui_Info = lv_obj_create(NULL); +lv_obj_add_state( ui_Info, LV_STATE_USER_1 ); /// States +lv_obj_clear_flag( ui_Info, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM ); /// Flags +lv_obj_set_scrollbar_mode(ui_Info, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_bg_color(ui_Info, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_Info, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_Info, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_Info, LV_GRAD_DIR_HOR, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_WifiConnectedLabel = lv_label_create(ui_Info); +lv_obj_set_width( ui_WifiConnectedLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_WifiConnectedLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_WifiConnectedLabel, 7 ); +lv_obj_set_y( ui_WifiConnectedLabel, -100 ); +lv_obj_set_align( ui_WifiConnectedLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_WifiConnectedLabel,"Connected:"); +lv_obj_set_style_text_font(ui_WifiConnectedLabel, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_WifiConnCheckBox = lv_checkbox_create(ui_Info); +lv_checkbox_set_text(ui_WifiConnCheckBox,""); +lv_obj_set_width( ui_WifiConnCheckBox, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_WifiConnCheckBox, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_WifiConnCheckBox, 120 ); +lv_obj_set_y( ui_WifiConnCheckBox, 8 ); +lv_obj_add_flag( ui_WifiConnCheckBox, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_WifiConnCheckBox, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_CLICK_FOCUSABLE ); /// Flags +lv_obj_set_style_text_font(ui_WifiConnCheckBox, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); + +lv_obj_set_style_bg_color(ui_WifiConnCheckBox, lv_color_hex(0xFFFFFF), LV_PART_INDICATOR | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_WifiConnCheckBox, 0, LV_PART_INDICATOR| LV_STATE_DEFAULT); +lv_obj_set_style_border_width(ui_WifiConnCheckBox, 1, LV_PART_INDICATOR| LV_STATE_DEFAULT); + +ui_WifiSsidLabel = lv_label_create(ui_Info); +lv_obj_set_width( ui_WifiSsidLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_WifiSsidLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_WifiSsidLabel, 160 ); +lv_obj_set_y( ui_WifiSsidLabel, -100 ); +lv_obj_set_align( ui_WifiSsidLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_WifiSsidLabel,"SSID:"); +lv_obj_set_style_text_font(ui_WifiSsidLabel, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_IPLabel = lv_label_create(ui_Info); +lv_obj_set_width( ui_IPLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_IPLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_IPLabel, 7 ); +lv_obj_set_y( ui_IPLabel, -74 ); +lv_obj_set_align( ui_IPLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_IPLabel,"IP Address:"); +lv_obj_set_style_text_font(ui_IPLabel, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_HostnameLabel = lv_label_create(ui_Info); +lv_obj_set_width( ui_HostnameLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_HostnameLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_HostnameLabel, 7 ); +lv_obj_set_y( ui_HostnameLabel, -48 ); +lv_obj_set_align( ui_HostnameLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_HostnameLabel,"Hostname:"); +lv_obj_set_style_text_font(ui_HostnameLabel, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_RssiLabel = lv_label_create(ui_Info); +lv_obj_set_width( ui_RssiLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_RssiLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_RssiLabel, 7 ); +lv_obj_set_y( ui_RssiLabel, -22 ); +lv_obj_set_align( ui_RssiLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_RssiLabel,"Signal:"); +lv_obj_set_style_text_font(ui_RssiLabel, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_FwVersionLabel = lv_label_create(ui_Info); +lv_obj_set_width( ui_FwVersionLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_FwVersionLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_FwVersionLabel, 7 ); +lv_obj_set_y( ui_FwVersionLabel, 4 ); +lv_obj_set_align( ui_FwVersionLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_FwVersionLabel,"Firmware:"); +lv_obj_set_style_text_font(ui_FwVersionLabel, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_BuildDateLabel = lv_label_create(ui_Info); +lv_obj_set_width( ui_BuildDateLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_BuildDateLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_BuildDateLabel, 7 ); +lv_obj_set_y( ui_BuildDateLabel, 30 ); +lv_obj_set_align( ui_BuildDateLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_BuildDateLabel,"Build Date:"); +lv_obj_set_style_text_font(ui_BuildDateLabel, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_CopyrightLabel = lv_label_create(ui_Info); +lv_obj_set_width( ui_CopyrightLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_CopyrightLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_CopyrightLabel, 7 ); +lv_obj_set_y( ui_CopyrightLabel, 56 ); +lv_obj_set_align( ui_CopyrightLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_long_mode(ui_CopyrightLabel,LV_LABEL_LONG_SCROLL_CIRCULAR); +lv_label_set_text(ui_CopyrightLabel,"Copyright: "); +lv_obj_set_style_text_align(ui_CopyrightLabel, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_text_font(ui_CopyrightLabel, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_ShowQR = lv_btn_create(ui_Info); +lv_obj_set_width( ui_ShowQR, 100); +lv_obj_set_height( ui_ShowQR, 36); +lv_obj_set_x( ui_ShowQR, -108 ); +lv_obj_set_y( ui_ShowQR, -3 ); +lv_obj_set_align( ui_ShowQR, LV_ALIGN_BOTTOM_RIGHT ); +lv_obj_add_flag( ui_ShowQR, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_ShowQR, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_ShowQR, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_ShowQR, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_ShowQR, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_ShowQR, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_ShowQRLabel = lv_label_create(ui_Info); +lv_obj_set_width( ui_ShowQRLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_ShowQRLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_ShowQRLabel, -124 ); +lv_obj_set_y( ui_ShowQRLabel, -14 ); +lv_obj_set_align( ui_ShowQRLabel, LV_ALIGN_BOTTOM_RIGHT ); +lv_label_set_text(ui_ShowQRLabel,"Show QR"); +lv_obj_set_style_text_color(ui_ShowQRLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_ShowQRLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_HomeBtn = lv_btn_create(ui_Info); +lv_obj_set_width( ui_HomeBtn, 100); +lv_obj_set_height( ui_HomeBtn, 36); +lv_obj_set_x( ui_HomeBtn, -2 ); +lv_obj_set_y( ui_HomeBtn, -3 ); +lv_obj_set_align( ui_HomeBtn, LV_ALIGN_BOTTOM_RIGHT ); +lv_obj_add_flag( ui_HomeBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_HomeBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_HomeBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_HomeBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_HomeBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_HomeBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_HomeLabel = lv_label_create(ui_Info); +lv_obj_set_width( ui_HomeLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_HomeLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_HomeLabel, -30 ); +lv_obj_set_y( ui_HomeLabel, -14 ); +lv_obj_set_align( ui_HomeLabel, LV_ALIGN_BOTTOM_RIGHT ); +lv_label_set_text(ui_HomeLabel,"Home"); +lv_obj_set_style_text_color(ui_HomeLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_HomeLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +lv_obj_add_event_cb(ui_ShowQR, ui_event_ShowQR, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_HomeBtn, ui_event_HomeBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_Info, ui_event_Info, LV_EVENT_ALL, NULL); } diff --git a/app/src/ui/screens/ui_LessCommonSetup.c b/app/src/ui/screens/ui_LessCommonSetup.c index 617d875..8a4ef77 100644 --- a/app/src/ui/screens/ui_LessCommonSetup.c +++ b/app/src/ui/screens/ui_LessCommonSetup.c @@ -1,5 +1,5 @@ // This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.3.1 +// SquareLine Studio version: SquareLine Studio 1.3.2 // LVGL version: 8.3.6 // Project name: Thermostat @@ -7,188 +7,188 @@ void ui_LessCommonSetup_screen_init(void) { - ui_LessCommonSetup = lv_obj_create(NULL); - lv_obj_add_state(ui_LessCommonSetup, LV_STATE_USER_1); /// States - lv_obj_clear_flag(ui_LessCommonSetup, - LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM); /// Flags - lv_obj_set_scrollbar_mode(ui_LessCommonSetup, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_bg_color(ui_LessCommonSetup, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_LessCommonSetup, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_LessCommonSetup, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_LessCommonSetup, LV_GRAD_DIR_HOR, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_CalibrateBtn = lv_btn_create(ui_LessCommonSetup); - lv_obj_set_width(ui_CalibrateBtn, 100); - lv_obj_set_height(ui_CalibrateBtn, 36); - lv_obj_set_x(ui_CalibrateBtn, 4); - lv_obj_set_y(ui_CalibrateBtn, 4); - lv_obj_add_flag(ui_CalibrateBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - lv_obj_clear_flag(ui_CalibrateBtn, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_bg_color(ui_CalibrateBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_CalibrateBtn, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_CalibrateBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_CalibrateBtn, LV_GRAD_DIR_VER, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_CalibrateLabel = lv_label_create(ui_LessCommonSetup); - lv_obj_set_width(ui_CalibrateLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_CalibrateLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_CalibrateLabel, 20); - lv_obj_set_y(ui_CalibrateLabel, 13); - lv_label_set_text(ui_CalibrateLabel, "Calibrate"); - lv_obj_set_style_text_color(ui_CalibrateLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_opa(ui_CalibrateLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_TimezoneLabel1 = lv_label_create(ui_LessCommonSetup); - lv_obj_set_width(ui_TimezoneLabel1, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_TimezoneLabel1, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_TimezoneLabel1, 7); - lv_obj_set_y(ui_TimezoneLabel1, -56); - lv_obj_set_align(ui_TimezoneLabel1, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_TimezoneLabel1, "Time Zone:"); - - ui_TimezoneDropdown = lv_dropdown_create(ui_LessCommonSetup); - lv_dropdown_set_options(ui_TimezoneDropdown, - "GMT +11\nGMT +10\nGMT +9\nGMT +8\nGMT +7\nGMT +6\nGMT +5\nGMT +4\nGMT +3\nGMT +2\nGMT +1\nGMT\nGMT -1\nGMT -2\nGMT -3\nGMT -4\nGMT -5\nGMT -6\nGMT -7\nGMT -8\nGMT -9\nGMT -10\nGMT -11\nGMT -12"); - lv_obj_set_width(ui_TimezoneDropdown, 104); - lv_obj_set_height(ui_TimezoneDropdown, 32); - lv_obj_set_x(ui_TimezoneDropdown, 133); - lv_obj_set_y(ui_TimezoneDropdown, -56); - lv_obj_set_align(ui_TimezoneDropdown, LV_ALIGN_LEFT_MID); - lv_obj_add_flag(ui_TimezoneDropdown, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - lv_obj_set_style_bg_color(ui_TimezoneDropdown, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_TimezoneDropdown, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_width(ui_TimezoneDropdown, 1, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_UiSleepTextLabel = lv_label_create(ui_LessCommonSetup); - lv_obj_set_width(ui_UiSleepTextLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_UiSleepTextLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_UiSleepTextLabel, 7); - lv_obj_set_y(ui_UiSleepTextLabel, -15); - lv_obj_set_align(ui_UiSleepTextLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_UiSleepTextLabel, "Display Sleep:"); - - ui_UiSleepLabel = lv_label_create(ui_LessCommonSetup); - lv_obj_set_width(ui_UiSleepLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_UiSleepLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_UiSleepLabel, 138); - lv_obj_set_y(ui_UiSleepLabel, -15); - lv_obj_set_align(ui_UiSleepLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_UiSleepLabel, "30 s"); - - ui_UiSleepSlider = lv_slider_create(ui_LessCommonSetup); - lv_slider_set_range(ui_UiSleepSlider, 10, 90); - lv_slider_set_value(ui_UiSleepSlider, 30, LV_ANIM_OFF); - if(lv_slider_get_mode(ui_UiSleepSlider) == LV_SLIDER_MODE_RANGE) lv_slider_set_left_value(ui_UiSleepSlider, 0, - LV_ANIM_OFF); - lv_obj_set_width(ui_UiSleepSlider, 127); - lv_obj_set_height(ui_UiSleepSlider, 10); - lv_obj_set_x(ui_UiSleepSlider, -9); - lv_obj_set_y(ui_UiSleepSlider, -15); - lv_obj_set_align(ui_UiSleepSlider, LV_ALIGN_RIGHT_MID); - - ui_DualStageHeatLabel = lv_label_create(ui_LessCommonSetup); - lv_obj_set_width(ui_DualStageHeatLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_DualStageHeatLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_DualStageHeatLabel, 7); - lv_obj_set_y(ui_DualStageHeatLabel, 31); - lv_obj_set_align(ui_DualStageHeatLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_DualStageHeatLabel, "2 Stage Heat:"); - - ui_Hvac2StageHeatCheckbox = lv_checkbox_create(ui_LessCommonSetup); - lv_checkbox_set_text(ui_Hvac2StageHeatCheckbox, ""); - lv_obj_set_width(ui_Hvac2StageHeatCheckbox, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_Hvac2StageHeatCheckbox, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_Hvac2StageHeatCheckbox, 0); - lv_obj_set_y(ui_Hvac2StageHeatCheckbox, 31); - lv_obj_set_align(ui_Hvac2StageHeatCheckbox, LV_ALIGN_CENTER); - lv_obj_add_flag(ui_Hvac2StageHeatCheckbox, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - - ui_DisableLabel1 = lv_label_create(ui_LessCommonSetup); - lv_obj_set_width(ui_DisableLabel1, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_DisableLabel1, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_DisableLabel1, 7); - lv_obj_set_y(ui_DisableLabel1, 63); - lv_obj_set_align(ui_DisableLabel1, LV_ALIGN_LEFT_MID); - lv_label_set_long_mode(ui_DisableLabel1, LV_LABEL_LONG_SCROLL); - lv_label_set_text(ui_DisableLabel1, "Reverse Valve:"); - - ui_RevValveCheckbox = lv_checkbox_create(ui_LessCommonSetup); - lv_checkbox_set_text(ui_RevValveCheckbox, ""); - lv_obj_set_width(ui_RevValveCheckbox, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_RevValveCheckbox, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_RevValveCheckbox, 0); - lv_obj_set_y(ui_RevValveCheckbox, 63); - lv_obj_set_align(ui_RevValveCheckbox, LV_ALIGN_CENTER); - lv_obj_add_flag(ui_RevValveCheckbox, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - - ui_DisableBeepLabel = lv_label_create(ui_LessCommonSetup); - lv_obj_set_width(ui_DisableBeepLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_DisableBeepLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_DisableBeepLabel, 7); - lv_obj_set_y(ui_DisableBeepLabel, 95); - lv_obj_set_align(ui_DisableBeepLabel, LV_ALIGN_LEFT_MID); - lv_label_set_long_mode(ui_DisableBeepLabel, LV_LABEL_LONG_SCROLL); - lv_label_set_text(ui_DisableBeepLabel, "Audible Beep:"); - - ui_AudibleBeepCheckbox = lv_checkbox_create(ui_LessCommonSetup); - lv_checkbox_set_text(ui_AudibleBeepCheckbox, ""); - lv_obj_set_width(ui_AudibleBeepCheckbox, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_AudibleBeepCheckbox, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_AudibleBeepCheckbox, 0); - lv_obj_set_y(ui_AudibleBeepCheckbox, 95); - lv_obj_set_align(ui_AudibleBeepCheckbox, LV_ALIGN_CENTER); - lv_obj_add_flag(ui_AudibleBeepCheckbox, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - - ui_SetupWifiBtn = lv_btn_create(ui_LessCommonSetup); - lv_obj_set_width(ui_SetupWifiBtn, 100); - lv_obj_set_height(ui_SetupWifiBtn, 36); - lv_obj_set_x(ui_SetupWifiBtn, -2); - lv_obj_set_y(ui_SetupWifiBtn, -45); - lv_obj_set_align(ui_SetupWifiBtn, LV_ALIGN_BOTTOM_RIGHT); - lv_obj_add_flag(ui_SetupWifiBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - lv_obj_clear_flag(ui_SetupWifiBtn, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_bg_color(ui_SetupWifiBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_SetupWifiBtn, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_SetupWifiBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_SetupWifiBtn, LV_GRAD_DIR_VER, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_SetupWifiLabel = lv_label_create(ui_LessCommonSetup); - lv_obj_set_width(ui_SetupWifiLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_SetupWifiLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_SetupWifiLabel, -36); - lv_obj_set_y(ui_SetupWifiLabel, -56); - lv_obj_set_align(ui_SetupWifiLabel, LV_ALIGN_BOTTOM_RIGHT); - lv_label_set_text(ui_SetupWifiLabel, "Wifi"); - lv_obj_set_style_text_color(ui_SetupWifiLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_opa(ui_SetupWifiLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_SetupHomeBtn2 = lv_btn_create(ui_LessCommonSetup); - lv_obj_set_width(ui_SetupHomeBtn2, 100); - lv_obj_set_height(ui_SetupHomeBtn2, 36); - lv_obj_set_x(ui_SetupHomeBtn2, -2); - lv_obj_set_y(ui_SetupHomeBtn2, -3); - lv_obj_set_align(ui_SetupHomeBtn2, LV_ALIGN_BOTTOM_RIGHT); - lv_obj_add_flag(ui_SetupHomeBtn2, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - lv_obj_clear_flag(ui_SetupHomeBtn2, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_bg_color(ui_SetupHomeBtn2, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_SetupHomeBtn2, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_SetupHomeBtn2, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_SetupHomeBtn2, LV_GRAD_DIR_VER, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_SetupHomeLabel2 = lv_label_create(ui_LessCommonSetup); - lv_obj_set_width(ui_SetupHomeLabel2, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_SetupHomeLabel2, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_SetupHomeLabel2, -30); - lv_obj_set_y(ui_SetupHomeLabel2, -14); - lv_obj_set_align(ui_SetupHomeLabel2, LV_ALIGN_BOTTOM_RIGHT); - lv_label_set_text(ui_SetupHomeLabel2, "Home"); - lv_obj_set_style_text_color(ui_SetupHomeLabel2, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_opa(ui_SetupHomeLabel2, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - - lv_obj_add_event_cb(ui_CalibrateBtn, ui_event_CalibrateBtn, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_UiSleepSlider, ui_event_UiSleepSlider, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_SetupWifiBtn, ui_event_SetupWifiBtn, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_SetupHomeBtn2, ui_event_SetupHomeBtn2, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_LessCommonSetup, ui_event_LessCommonSetup, LV_EVENT_ALL, NULL); +ui_LessCommonSetup = lv_obj_create(NULL); +lv_obj_add_state( ui_LessCommonSetup, LV_STATE_USER_1 ); /// States +lv_obj_clear_flag( ui_LessCommonSetup, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM ); /// Flags +lv_obj_set_scrollbar_mode(ui_LessCommonSetup, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_bg_color(ui_LessCommonSetup, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_LessCommonSetup, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_LessCommonSetup, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_LessCommonSetup, LV_GRAD_DIR_HOR, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_CalibrateBtn = lv_btn_create(ui_LessCommonSetup); +lv_obj_set_width( ui_CalibrateBtn, 100); +lv_obj_set_height( ui_CalibrateBtn, 36); +lv_obj_set_x( ui_CalibrateBtn, 4 ); +lv_obj_set_y( ui_CalibrateBtn, 4 ); +lv_obj_add_flag( ui_CalibrateBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_CalibrateBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_CalibrateBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_CalibrateBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_CalibrateBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_CalibrateBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_CalibrateLabel = lv_label_create(ui_LessCommonSetup); +lv_obj_set_width( ui_CalibrateLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_CalibrateLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_CalibrateLabel, 20 ); +lv_obj_set_y( ui_CalibrateLabel, 13 ); +lv_label_set_text(ui_CalibrateLabel,"Calibrate"); +lv_obj_set_style_text_color(ui_CalibrateLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_CalibrateLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_TimezoneLabel1 = lv_label_create(ui_LessCommonSetup); +lv_obj_set_width( ui_TimezoneLabel1, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_TimezoneLabel1, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_TimezoneLabel1, 7 ); +lv_obj_set_y( ui_TimezoneLabel1, -56 ); +lv_obj_set_align( ui_TimezoneLabel1, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_TimezoneLabel1,"Time Zone:"); + +ui_TimezoneDropdown = lv_dropdown_create(ui_LessCommonSetup); +lv_dropdown_set_options( ui_TimezoneDropdown, "GMT +11\nGMT +10\nGMT +9\nGMT +8\nGMT +7\nGMT +6\nGMT +5\nGMT +4\nGMT +3\nGMT +2\nGMT +1\nGMT\nGMT -1\nGMT -2\nGMT -3\nGMT -4\nGMT -5\nGMT -6\nGMT -7\nGMT -8\nGMT -9\nGMT -10\nGMT -11\nGMT -12" ); +lv_obj_set_width( ui_TimezoneDropdown, 104); +lv_obj_set_height( ui_TimezoneDropdown, 32); +lv_obj_set_x( ui_TimezoneDropdown, 133 ); +lv_obj_set_y( ui_TimezoneDropdown, -56 ); +lv_obj_set_align( ui_TimezoneDropdown, LV_ALIGN_LEFT_MID ); +lv_obj_add_flag( ui_TimezoneDropdown, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_set_style_bg_color(ui_TimezoneDropdown, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_TimezoneDropdown, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_border_width(ui_TimezoneDropdown, 1, LV_PART_MAIN| LV_STATE_DEFAULT); + + + +ui_UiSleepTextLabel = lv_label_create(ui_LessCommonSetup); +lv_obj_set_width( ui_UiSleepTextLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_UiSleepTextLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_UiSleepTextLabel, 7 ); +lv_obj_set_y( ui_UiSleepTextLabel, -15 ); +lv_obj_set_align( ui_UiSleepTextLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_UiSleepTextLabel,"Display Sleep:"); + +ui_UiSleepLabel = lv_label_create(ui_LessCommonSetup); +lv_obj_set_width( ui_UiSleepLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_UiSleepLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_UiSleepLabel, 138 ); +lv_obj_set_y( ui_UiSleepLabel, -15 ); +lv_obj_set_align( ui_UiSleepLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_UiSleepLabel,"30 s"); + +ui_UiSleepSlider = lv_slider_create(ui_LessCommonSetup); +lv_slider_set_range(ui_UiSleepSlider, 10,90); +lv_slider_set_value( ui_UiSleepSlider, 30, LV_ANIM_OFF); +if (lv_slider_get_mode(ui_UiSleepSlider)==LV_SLIDER_MODE_RANGE ) lv_slider_set_left_value( ui_UiSleepSlider, 0, LV_ANIM_OFF); +lv_obj_set_width( ui_UiSleepSlider, 127); +lv_obj_set_height( ui_UiSleepSlider, 10); +lv_obj_set_x( ui_UiSleepSlider, -9 ); +lv_obj_set_y( ui_UiSleepSlider, -15 ); +lv_obj_set_align( ui_UiSleepSlider, LV_ALIGN_RIGHT_MID ); + + +ui_DualStageHeatLabel = lv_label_create(ui_LessCommonSetup); +lv_obj_set_width( ui_DualStageHeatLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_DualStageHeatLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_DualStageHeatLabel, 7 ); +lv_obj_set_y( ui_DualStageHeatLabel, 31 ); +lv_obj_set_align( ui_DualStageHeatLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_DualStageHeatLabel,"2 Stage Heat:"); + +ui_Hvac2StageHeatCheckbox = lv_checkbox_create(ui_LessCommonSetup); +lv_checkbox_set_text(ui_Hvac2StageHeatCheckbox,""); +lv_obj_set_width( ui_Hvac2StageHeatCheckbox, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_Hvac2StageHeatCheckbox, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_Hvac2StageHeatCheckbox, 0 ); +lv_obj_set_y( ui_Hvac2StageHeatCheckbox, 31 ); +lv_obj_set_align( ui_Hvac2StageHeatCheckbox, LV_ALIGN_CENTER ); +lv_obj_add_flag( ui_Hvac2StageHeatCheckbox, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags + +ui_DisableLabel1 = lv_label_create(ui_LessCommonSetup); +lv_obj_set_width( ui_DisableLabel1, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_DisableLabel1, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_DisableLabel1, 7 ); +lv_obj_set_y( ui_DisableLabel1, 63 ); +lv_obj_set_align( ui_DisableLabel1, LV_ALIGN_LEFT_MID ); +lv_label_set_long_mode(ui_DisableLabel1,LV_LABEL_LONG_SCROLL); +lv_label_set_text(ui_DisableLabel1,"Reverse Valve:"); + +ui_RevValveCheckbox = lv_checkbox_create(ui_LessCommonSetup); +lv_checkbox_set_text(ui_RevValveCheckbox,""); +lv_obj_set_width( ui_RevValveCheckbox, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_RevValveCheckbox, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_RevValveCheckbox, 0 ); +lv_obj_set_y( ui_RevValveCheckbox, 63 ); +lv_obj_set_align( ui_RevValveCheckbox, LV_ALIGN_CENTER ); +lv_obj_add_flag( ui_RevValveCheckbox, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags + +ui_DisableBeepLabel = lv_label_create(ui_LessCommonSetup); +lv_obj_set_width( ui_DisableBeepLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_DisableBeepLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_DisableBeepLabel, 7 ); +lv_obj_set_y( ui_DisableBeepLabel, 95 ); +lv_obj_set_align( ui_DisableBeepLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_long_mode(ui_DisableBeepLabel,LV_LABEL_LONG_SCROLL); +lv_label_set_text(ui_DisableBeepLabel,"Audible Beep:"); + +ui_AudibleBeepCheckbox = lv_checkbox_create(ui_LessCommonSetup); +lv_checkbox_set_text(ui_AudibleBeepCheckbox,""); +lv_obj_set_width( ui_AudibleBeepCheckbox, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_AudibleBeepCheckbox, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_AudibleBeepCheckbox, 0 ); +lv_obj_set_y( ui_AudibleBeepCheckbox, 95 ); +lv_obj_set_align( ui_AudibleBeepCheckbox, LV_ALIGN_CENTER ); +lv_obj_add_flag( ui_AudibleBeepCheckbox, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags + +ui_SetupWifiBtn = lv_btn_create(ui_LessCommonSetup); +lv_obj_set_width( ui_SetupWifiBtn, 100); +lv_obj_set_height( ui_SetupWifiBtn, 36); +lv_obj_set_x( ui_SetupWifiBtn, -2 ); +lv_obj_set_y( ui_SetupWifiBtn, -45 ); +lv_obj_set_align( ui_SetupWifiBtn, LV_ALIGN_BOTTOM_RIGHT ); +lv_obj_add_flag( ui_SetupWifiBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_SetupWifiBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_SetupWifiBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_SetupWifiBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_SetupWifiBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_SetupWifiBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_SetupWifiLabel = lv_label_create(ui_LessCommonSetup); +lv_obj_set_width( ui_SetupWifiLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_SetupWifiLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_SetupWifiLabel, -36 ); +lv_obj_set_y( ui_SetupWifiLabel, -56 ); +lv_obj_set_align( ui_SetupWifiLabel, LV_ALIGN_BOTTOM_RIGHT ); +lv_label_set_text(ui_SetupWifiLabel,"Wifi"); +lv_obj_set_style_text_color(ui_SetupWifiLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_SetupWifiLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_SetupHomeBtn2 = lv_btn_create(ui_LessCommonSetup); +lv_obj_set_width( ui_SetupHomeBtn2, 100); +lv_obj_set_height( ui_SetupHomeBtn2, 36); +lv_obj_set_x( ui_SetupHomeBtn2, -2 ); +lv_obj_set_y( ui_SetupHomeBtn2, -3 ); +lv_obj_set_align( ui_SetupHomeBtn2, LV_ALIGN_BOTTOM_RIGHT ); +lv_obj_add_flag( ui_SetupHomeBtn2, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_SetupHomeBtn2, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_SetupHomeBtn2, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_SetupHomeBtn2, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_SetupHomeBtn2, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_SetupHomeBtn2, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_SetupHomeLabel2 = lv_label_create(ui_LessCommonSetup); +lv_obj_set_width( ui_SetupHomeLabel2, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_SetupHomeLabel2, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_SetupHomeLabel2, -30 ); +lv_obj_set_y( ui_SetupHomeLabel2, -14 ); +lv_obj_set_align( ui_SetupHomeLabel2, LV_ALIGN_BOTTOM_RIGHT ); +lv_label_set_text(ui_SetupHomeLabel2,"Home"); +lv_obj_set_style_text_color(ui_SetupHomeLabel2, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_SetupHomeLabel2, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +lv_obj_add_event_cb(ui_CalibrateBtn, ui_event_CalibrateBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_UiSleepSlider, ui_event_UiSleepSlider, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_SetupWifiBtn, ui_event_SetupWifiBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_SetupHomeBtn2, ui_event_SetupHomeBtn2, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_LessCommonSetup, ui_event_LessCommonSetup, LV_EVENT_ALL, NULL); } diff --git a/app/src/ui/screens/ui_MainScreen.c b/app/src/ui/screens/ui_MainScreen.c index 64ebd45..8ccb142 100644 --- a/app/src/ui/screens/ui_MainScreen.c +++ b/app/src/ui/screens/ui_MainScreen.c @@ -1,5 +1,5 @@ // This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.3.1 +// SquareLine Studio version: SquareLine Studio 1.3.2 // LVGL version: 8.3.6 // Project name: Thermostat @@ -7,257 +7,250 @@ void ui_MainScreen_screen_init(void) { - ui_MainScreen = lv_obj_create(NULL); - lv_obj_clear_flag(ui_MainScreen, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | - LV_OBJ_FLAG_SCROLL_MOMENTUM); /// Flags - lv_obj_set_scrollbar_mode(ui_MainScreen, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_bg_color(ui_MainScreen, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_MainScreen, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_MainScreen, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_MainScreen, LV_GRAD_DIR_HOR, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_MainScreen = lv_obj_create(NULL); +lv_obj_clear_flag( ui_MainScreen, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM ); /// Flags +lv_obj_set_scrollbar_mode(ui_MainScreen, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_bg_color(ui_MainScreen, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_MainScreen, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_MainScreen, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_MainScreen, LV_GRAD_DIR_HOR, LV_PART_MAIN| LV_STATE_DEFAULT); - ui_TimeLabel = lv_label_create(ui_MainScreen); - lv_obj_set_width(ui_TimeLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_TimeLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_TimeLabel, 3); - lv_obj_set_y(ui_TimeLabel, 3); - lv_label_set_long_mode(ui_TimeLabel, LV_LABEL_LONG_CLIP); - lv_label_set_text(ui_TimeLabel, "23:55:12"); - lv_obj_clear_flag(ui_TimeLabel, LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_CLICK_FOCUSABLE | LV_OBJ_FLAG_GESTURE_BUBBLE | - LV_OBJ_FLAG_SNAPPABLE | LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM | - LV_OBJ_FLAG_SCROLL_CHAIN); /// Flags - lv_obj_set_scrollbar_mode(ui_TimeLabel, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_text_font(ui_TimeLabel, &lv_font_montserrat_32, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_TimeLabel = lv_label_create(ui_MainScreen); +lv_obj_set_width( ui_TimeLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_TimeLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_TimeLabel, 3 ); +lv_obj_set_y( ui_TimeLabel, 3 ); +lv_label_set_long_mode(ui_TimeLabel,LV_LABEL_LONG_CLIP); +lv_label_set_text(ui_TimeLabel,"23:55:12"); +lv_obj_clear_flag( ui_TimeLabel, LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_CLICK_FOCUSABLE | LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SNAPPABLE | LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_SCROLL_CHAIN ); /// Flags +lv_obj_set_scrollbar_mode(ui_TimeLabel, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_text_font(ui_TimeLabel, &lv_font_montserrat_32, LV_PART_MAIN| LV_STATE_DEFAULT); - ui_StatusLabel = lv_label_create(ui_MainScreen); - lv_obj_set_width(ui_StatusLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_StatusLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_StatusLabel, 2); - lv_obj_set_y(ui_StatusLabel, -4); - lv_obj_set_align(ui_StatusLabel, LV_ALIGN_BOTTOM_LEFT); - lv_label_set_long_mode(ui_StatusLabel, LV_LABEL_LONG_CLIP); - lv_label_set_text(ui_StatusLabel, "Current:"); - lv_obj_clear_flag(ui_StatusLabel, LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_CLICK_FOCUSABLE | LV_OBJ_FLAG_GESTURE_BUBBLE | - LV_OBJ_FLAG_SNAPPABLE | LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM | - LV_OBJ_FLAG_SCROLL_CHAIN); /// Flags - lv_obj_set_scrollbar_mode(ui_StatusLabel, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_text_font(ui_StatusLabel, &lv_font_montserrat_24, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_StatusLabel = lv_label_create(ui_MainScreen); +lv_obj_set_width( ui_StatusLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_StatusLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_StatusLabel, 2 ); +lv_obj_set_y( ui_StatusLabel, -4 ); +lv_obj_set_align( ui_StatusLabel, LV_ALIGN_BOTTOM_LEFT ); +lv_label_set_long_mode(ui_StatusLabel,LV_LABEL_LONG_CLIP); +lv_label_set_text(ui_StatusLabel,"Current:"); +lv_obj_clear_flag( ui_StatusLabel, LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_CLICK_FOCUSABLE | LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SNAPPABLE | LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_SCROLL_CHAIN ); /// Flags +lv_obj_set_scrollbar_mode(ui_StatusLabel, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_text_font(ui_StatusLabel, &lv_font_montserrat_24, LV_PART_MAIN| LV_STATE_DEFAULT); - ui_TempLabel = lv_label_create(ui_MainScreen); - lv_obj_set_width(ui_TempLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_TempLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_TempLabel, -33); - lv_obj_set_y(ui_TempLabel, 103); - lv_obj_set_align(ui_TempLabel, LV_ALIGN_CENTER); - lv_label_set_long_mode(ui_TempLabel, LV_LABEL_LONG_CLIP); - lv_label_set_text(ui_TempLabel, "72°"); - lv_obj_set_style_text_align(ui_TempLabel, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_font(ui_TempLabel, &lv_font_montserrat_24, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_TempLabel = lv_label_create(ui_MainScreen); +lv_obj_set_width( ui_TempLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_TempLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_TempLabel, -33 ); +lv_obj_set_y( ui_TempLabel, 103 ); +lv_obj_set_align( ui_TempLabel, LV_ALIGN_CENTER ); +lv_label_set_long_mode(ui_TempLabel,LV_LABEL_LONG_CLIP); +lv_label_set_text(ui_TempLabel,"72°"); +lv_obj_set_style_text_align(ui_TempLabel, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_text_font(ui_TempLabel, &lv_font_montserrat_24, LV_PART_MAIN| LV_STATE_DEFAULT); - ui_HumidityLabel = lv_label_create(ui_MainScreen); - lv_obj_set_width(ui_HumidityLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_HumidityLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_HumidityLabel, 21); - lv_obj_set_y(ui_HumidityLabel, 103); - lv_obj_set_align(ui_HumidityLabel, LV_ALIGN_CENTER); - lv_label_set_long_mode(ui_HumidityLabel, LV_LABEL_LONG_CLIP); - lv_label_set_text(ui_HumidityLabel, "62%"); - lv_obj_set_style_text_align(ui_HumidityLabel, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_font(ui_HumidityLabel, &lv_font_montserrat_24, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_HumidityLabel = lv_label_create(ui_MainScreen); +lv_obj_set_width( ui_HumidityLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_HumidityLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_HumidityLabel, 21 ); +lv_obj_set_y( ui_HumidityLabel, 103 ); +lv_obj_set_align( ui_HumidityLabel, LV_ALIGN_CENTER ); +lv_label_set_long_mode(ui_HumidityLabel,LV_LABEL_LONG_CLIP); +lv_label_set_text(ui_HumidityLabel,"62%"); +lv_obj_set_style_text_align(ui_HumidityLabel, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_text_font(ui_HumidityLabel, &lv_font_montserrat_24, LV_PART_MAIN| LV_STATE_DEFAULT); - ui_ModeDropdown = lv_dropdown_create(ui_MainScreen); - lv_dropdown_set_options(ui_ModeDropdown, "Off\nIdle\nAuto\nHeat\nCool\nFan"); - lv_obj_set_width(ui_ModeDropdown, 99); - lv_obj_set_height(ui_ModeDropdown, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_ModeDropdown, 109); - lv_obj_set_y(ui_ModeDropdown, -101); - lv_obj_set_align(ui_ModeDropdown, LV_ALIGN_CENTER); - lv_obj_clear_flag(ui_ModeDropdown, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM | - LV_OBJ_FLAG_SCROLL_CHAIN); /// Flags - lv_obj_set_scrollbar_mode(ui_ModeDropdown, LV_SCROLLBAR_MODE_OFF); +ui_ModeDropdown = lv_dropdown_create(ui_MainScreen); +lv_dropdown_set_options( ui_ModeDropdown, "Off\nIdle\nAuto\nHeat\nCool\nFan" ); +lv_obj_set_width( ui_ModeDropdown, 99); +lv_obj_set_height( ui_ModeDropdown, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_ModeDropdown, 109 ); +lv_obj_set_y( ui_ModeDropdown, -101 ); +lv_obj_set_align( ui_ModeDropdown, LV_ALIGN_CENTER ); +lv_obj_clear_flag( ui_ModeDropdown, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_SCROLL_CHAIN ); /// Flags +lv_obj_set_scrollbar_mode(ui_ModeDropdown, LV_SCROLLBAR_MODE_OFF); - ui_SetupBtn = lv_btn_create(ui_MainScreen); - lv_obj_set_width(ui_SetupBtn, 90); - lv_obj_set_height(ui_SetupBtn, 36); - lv_obj_set_x(ui_SetupBtn, -2); - lv_obj_set_y(ui_SetupBtn, -3); - lv_obj_set_align(ui_SetupBtn, LV_ALIGN_BOTTOM_RIGHT); - lv_obj_add_flag(ui_SetupBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - lv_obj_clear_flag(ui_SetupBtn, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_scrollbar_mode(ui_SetupBtn, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_bg_color(ui_SetupBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_SetupBtn, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_SetupBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_SetupBtn, LV_GRAD_DIR_VER, LV_PART_MAIN | LV_STATE_DEFAULT); - ui_SetupLabel = lv_label_create(ui_MainScreen); - lv_obj_set_width(ui_SetupLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_SetupLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_SetupLabel, -25); - lv_obj_set_y(ui_SetupLabel, -14); - lv_obj_set_align(ui_SetupLabel, LV_ALIGN_BOTTOM_RIGHT); - lv_label_set_long_mode(ui_SetupLabel, LV_LABEL_LONG_CLIP); - lv_label_set_text(ui_SetupLabel, "Setup"); - lv_obj_add_flag(ui_SetupLabel, LV_OBJ_FLAG_IGNORE_LAYOUT); /// Flags - lv_obj_clear_flag(ui_SetupLabel, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_scrollbar_mode(ui_SetupLabel, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_text_color(ui_SetupLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_opa(ui_SetupLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - ui_SetTempBg1 = lv_obj_create(ui_MainScreen); - lv_obj_set_width(ui_SetTempBg1, 134); - lv_obj_set_height(ui_SetTempBg1, 134); - lv_obj_set_x(ui_SetTempBg1, -71); - lv_obj_set_y(ui_SetTempBg1, 11); - lv_obj_set_align(ui_SetTempBg1, LV_ALIGN_CENTER); - lv_obj_clear_flag(ui_SetTempBg1, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_radius(ui_SetTempBg1, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0x7D7D7D), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_SetTempBg1, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_SetTempBg1, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_width(ui_SetTempBg1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_SetupBtn = lv_btn_create(ui_MainScreen); +lv_obj_set_width( ui_SetupBtn, 90); +lv_obj_set_height( ui_SetupBtn, 36); +lv_obj_set_x( ui_SetupBtn, -2 ); +lv_obj_set_y( ui_SetupBtn, -3 ); +lv_obj_set_align( ui_SetupBtn, LV_ALIGN_BOTTOM_RIGHT ); +lv_obj_add_flag( ui_SetupBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_SetupBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_scrollbar_mode(ui_SetupBtn, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_bg_color(ui_SetupBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_SetupBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_SetupBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_SetupBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); - ui_SetTempBg = lv_obj_create(ui_MainScreen); - lv_obj_set_width(ui_SetTempBg, 110); - lv_obj_set_height(ui_SetTempBg, 110); - lv_obj_set_x(ui_SetTempBg, -71); - lv_obj_set_y(ui_SetTempBg, 11); - lv_obj_set_align(ui_SetTempBg, LV_ALIGN_CENTER); - lv_obj_clear_flag(ui_SetTempBg, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_radius(ui_SetTempBg, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_color(ui_SetTempBg, lv_color_hex(0x7A92B2), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_SetTempBg, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_SetTempBg, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_width(ui_SetTempBg, 0, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_SetupLabel = lv_label_create(ui_MainScreen); +lv_obj_set_width( ui_SetupLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_SetupLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_SetupLabel, -25 ); +lv_obj_set_y( ui_SetupLabel, -14 ); +lv_obj_set_align( ui_SetupLabel, LV_ALIGN_BOTTOM_RIGHT ); +lv_label_set_long_mode(ui_SetupLabel,LV_LABEL_LONG_CLIP); +lv_label_set_text(ui_SetupLabel,"Setup"); +lv_obj_add_flag( ui_SetupLabel, LV_OBJ_FLAG_IGNORE_LAYOUT ); /// Flags +lv_obj_clear_flag( ui_SetupLabel, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_scrollbar_mode(ui_SetupLabel, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_text_color(ui_SetupLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_SetupLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); - lv_obj_set_style_bg_color(ui_SetTempBg, lv_color_hex(0x5F4F4F), LV_PART_SCROLLBAR | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_SetTempBg, 255, LV_PART_SCROLLBAR | LV_STATE_DEFAULT); +ui_SetTempBg1 = lv_obj_create(ui_MainScreen); +lv_obj_set_width( ui_SetTempBg1, 134); +lv_obj_set_height( ui_SetTempBg1, 134); +lv_obj_set_x( ui_SetTempBg1, -71 ); +lv_obj_set_y( ui_SetTempBg1, 11 ); +lv_obj_set_align( ui_SetTempBg1, LV_ALIGN_CENTER ); +lv_obj_clear_flag( ui_SetTempBg1, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_radius(ui_SetTempBg1, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0x7D7D7D), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_SetTempBg1, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_SetTempBg1, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_border_width(ui_SetTempBg1, 0, LV_PART_MAIN| LV_STATE_DEFAULT); - ui_TempArc = lv_arc_create(ui_MainScreen); - lv_obj_set_width(ui_TempArc, 164); - lv_obj_set_height(ui_TempArc, 164); - lv_obj_set_x(ui_TempArc, -71); - lv_obj_set_y(ui_TempArc, 11); - lv_obj_set_align(ui_TempArc, LV_ALIGN_CENTER); - lv_arc_set_range(ui_TempArc, 450, 920); - lv_arc_set_value(ui_TempArc, 700); +ui_SetTempBg = lv_obj_create(ui_MainScreen); +lv_obj_set_width( ui_SetTempBg, 110); +lv_obj_set_height( ui_SetTempBg, 110); +lv_obj_set_x( ui_SetTempBg, -71 ); +lv_obj_set_y( ui_SetTempBg, 11 ); +lv_obj_set_align( ui_SetTempBg, LV_ALIGN_CENTER ); +lv_obj_clear_flag( ui_SetTempBg, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_radius(ui_SetTempBg, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_color(ui_SetTempBg, lv_color_hex(0x7A92B2), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_SetTempBg, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_SetTempBg, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_border_width(ui_SetTempBg, 0, LV_PART_MAIN| LV_STATE_DEFAULT); - ui_SetTemp = lv_label_create(ui_MainScreen); - lv_obj_set_width(ui_SetTemp, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_SetTemp, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_SetTemp, -71); - lv_obj_set_y(ui_SetTemp, 11); - lv_obj_set_align(ui_SetTemp, LV_ALIGN_CENTER); - lv_label_set_long_mode(ui_SetTemp, LV_LABEL_LONG_CLIP); - lv_label_set_text(ui_SetTemp, "82°"); - lv_obj_clear_flag(ui_SetTemp, LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_CLICK_FOCUSABLE | LV_OBJ_FLAG_GESTURE_BUBBLE | - LV_OBJ_FLAG_SNAPPABLE | LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM | - LV_OBJ_FLAG_SCROLL_CHAIN); /// Flags - lv_obj_set_scrollbar_mode(ui_SetTemp, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_text_font(ui_SetTemp, &lv_font_montserrat_44, LV_PART_MAIN | LV_STATE_DEFAULT); +lv_obj_set_style_bg_color(ui_SetTempBg, lv_color_hex(0x5F4F4F), LV_PART_SCROLLBAR | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_SetTempBg, 255, LV_PART_SCROLLBAR| LV_STATE_DEFAULT); - ui_SetTempFrac = lv_label_create(ui_MainScreen); - lv_obj_set_width(ui_SetTempFrac, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_SetTempFrac, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_SetTempFrac, -46); - lv_obj_set_y(ui_SetTempFrac, 22); - lv_obj_set_align(ui_SetTempFrac, LV_ALIGN_CENTER); - lv_label_set_long_mode(ui_SetTempFrac, LV_LABEL_LONG_CLIP); - lv_label_set_text(ui_SetTempFrac, "5"); - lv_obj_add_flag(ui_SetTempFrac, LV_OBJ_FLAG_HIDDEN); /// Flags - lv_obj_clear_flag(ui_SetTempFrac, LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_CLICK_FOCUSABLE | LV_OBJ_FLAG_GESTURE_BUBBLE | - LV_OBJ_FLAG_SNAPPABLE | LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM | - LV_OBJ_FLAG_SCROLL_CHAIN); /// Flags - lv_obj_set_scrollbar_mode(ui_SetTempFrac, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_text_align(ui_SetTempFrac, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_font(ui_SetTempFrac, &lv_font_montserrat_16, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_TempArc = lv_arc_create(ui_MainScreen); +lv_obj_set_width( ui_TempArc, 164); +lv_obj_set_height( ui_TempArc, 164); +lv_obj_set_x( ui_TempArc, -71 ); +lv_obj_set_y( ui_TempArc, 11 ); +lv_obj_set_align( ui_TempArc, LV_ALIGN_CENTER ); +lv_arc_set_range(ui_TempArc, 450,920); +lv_arc_set_value(ui_TempArc, 700); - ui_TempDecreaseBtn = lv_obj_create(ui_MainScreen); - lv_obj_set_width(ui_TempDecreaseBtn, 45); - lv_obj_set_height(ui_TempDecreaseBtn, 45); - lv_obj_set_x(ui_TempDecreaseBtn, 39); - lv_obj_set_y(ui_TempDecreaseBtn, 56); - lv_obj_set_align(ui_TempDecreaseBtn, LV_ALIGN_CENTER); - lv_obj_clear_flag(ui_TempDecreaseBtn, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_blend_mode(ui_TempDecreaseBtn, LV_BLEND_MODE_MULTIPLY, LV_PART_MAIN | LV_STATE_DEFAULT); - ui_TempDecreaseLabel = lv_label_create(ui_MainScreen); - lv_obj_set_width(ui_TempDecreaseLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_TempDecreaseLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_TempDecreaseLabel, 39); - lv_obj_set_y(ui_TempDecreaseLabel, 52); - lv_obj_set_align(ui_TempDecreaseLabel, LV_ALIGN_CENTER); - lv_label_set_long_mode(ui_TempDecreaseLabel, LV_LABEL_LONG_CLIP); - lv_label_set_text(ui_TempDecreaseLabel, "-"); - lv_obj_set_style_text_font(ui_TempDecreaseLabel, &lv_font_montserrat_48, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_SetTemp = lv_label_create(ui_MainScreen); +lv_obj_set_width( ui_SetTemp, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_SetTemp, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_SetTemp, -71 ); +lv_obj_set_y( ui_SetTemp, 11 ); +lv_obj_set_align( ui_SetTemp, LV_ALIGN_CENTER ); +lv_label_set_long_mode(ui_SetTemp,LV_LABEL_LONG_CLIP); +lv_label_set_text(ui_SetTemp,"82°"); +lv_obj_clear_flag( ui_SetTemp, LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_CLICK_FOCUSABLE | LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SNAPPABLE | LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_SCROLL_CHAIN ); /// Flags +lv_obj_set_scrollbar_mode(ui_SetTemp, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_text_font(ui_SetTemp, &lv_font_montserrat_44, LV_PART_MAIN| LV_STATE_DEFAULT); - ui_TempIncreaseBtn = lv_obj_create(ui_MainScreen); - lv_obj_set_width(ui_TempIncreaseBtn, 45); - lv_obj_set_height(ui_TempIncreaseBtn, 45); - lv_obj_set_x(ui_TempIncreaseBtn, 39); - lv_obj_set_y(ui_TempIncreaseBtn, -40); - lv_obj_set_align(ui_TempIncreaseBtn, LV_ALIGN_CENTER); - lv_obj_clear_flag(ui_TempIncreaseBtn, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_blend_mode(ui_TempIncreaseBtn, LV_BLEND_MODE_MULTIPLY, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_SetTempFrac = lv_label_create(ui_MainScreen); +lv_obj_set_width( ui_SetTempFrac, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_SetTempFrac, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_SetTempFrac, -46 ); +lv_obj_set_y( ui_SetTempFrac, 22 ); +lv_obj_set_align( ui_SetTempFrac, LV_ALIGN_CENTER ); +lv_label_set_long_mode(ui_SetTempFrac,LV_LABEL_LONG_CLIP); +lv_label_set_text(ui_SetTempFrac,"5"); +lv_obj_add_flag( ui_SetTempFrac, LV_OBJ_FLAG_HIDDEN ); /// Flags +lv_obj_clear_flag( ui_SetTempFrac, LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_CLICK_FOCUSABLE | LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SNAPPABLE | LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_SCROLL_CHAIN ); /// Flags +lv_obj_set_scrollbar_mode(ui_SetTempFrac, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_text_align(ui_SetTempFrac, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_text_font(ui_SetTempFrac, &lv_font_montserrat_16, LV_PART_MAIN| LV_STATE_DEFAULT); - ui_TempIncreaseLabel = lv_label_create(ui_MainScreen); - lv_obj_set_width(ui_TempIncreaseLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_TempIncreaseLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_TempIncreaseLabel, 39); - lv_obj_set_y(ui_TempIncreaseLabel, -40); - lv_obj_set_align(ui_TempIncreaseLabel, LV_ALIGN_CENTER); - lv_label_set_long_mode(ui_TempIncreaseLabel, LV_LABEL_LONG_CLIP); - lv_label_set_text(ui_TempIncreaseLabel, "+"); - lv_obj_set_style_text_font(ui_TempIncreaseLabel, &lv_font_montserrat_48, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_TempDecreaseBtn = lv_obj_create(ui_MainScreen); +lv_obj_set_width( ui_TempDecreaseBtn, 45); +lv_obj_set_height( ui_TempDecreaseBtn, 45); +lv_obj_set_x( ui_TempDecreaseBtn, 39 ); +lv_obj_set_y( ui_TempDecreaseBtn, 56 ); +lv_obj_set_align( ui_TempDecreaseBtn, LV_ALIGN_CENTER ); +lv_obj_clear_flag( ui_TempDecreaseBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_blend_mode(ui_TempDecreaseBtn, LV_BLEND_MODE_MULTIPLY, LV_PART_MAIN| LV_STATE_DEFAULT); - ui_InfoBtn = lv_btn_create(ui_MainScreen); - lv_obj_set_width(ui_InfoBtn, 90); - lv_obj_set_height(ui_InfoBtn, 36); - lv_obj_set_x(ui_InfoBtn, -2); - lv_obj_set_y(ui_InfoBtn, -45); - lv_obj_set_align(ui_InfoBtn, LV_ALIGN_BOTTOM_RIGHT); - lv_obj_add_flag(ui_InfoBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - lv_obj_clear_flag(ui_InfoBtn, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_scrollbar_mode(ui_InfoBtn, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_bg_color(ui_InfoBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_InfoBtn, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_InfoBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_InfoBtn, LV_GRAD_DIR_VER, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_TempDecreaseLabel = lv_label_create(ui_MainScreen); +lv_obj_set_width( ui_TempDecreaseLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_TempDecreaseLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_TempDecreaseLabel, 39 ); +lv_obj_set_y( ui_TempDecreaseLabel, 52 ); +lv_obj_set_align( ui_TempDecreaseLabel, LV_ALIGN_CENTER ); +lv_label_set_long_mode(ui_TempDecreaseLabel,LV_LABEL_LONG_CLIP); +lv_label_set_text(ui_TempDecreaseLabel,"-"); +lv_obj_set_style_text_font(ui_TempDecreaseLabel, &lv_font_montserrat_48, LV_PART_MAIN| LV_STATE_DEFAULT); - ui_InfoLabel = lv_label_create(ui_MainScreen); - lv_obj_set_width(ui_InfoLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_InfoLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_InfoLabel, -33); - lv_obj_set_y(ui_InfoLabel, -56); - lv_obj_set_align(ui_InfoLabel, LV_ALIGN_BOTTOM_RIGHT); - lv_label_set_long_mode(ui_InfoLabel, LV_LABEL_LONG_CLIP); - lv_label_set_text(ui_InfoLabel, "Info"); - lv_obj_add_flag(ui_InfoLabel, LV_OBJ_FLAG_IGNORE_LAYOUT); /// Flags - lv_obj_clear_flag(ui_InfoLabel, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_scrollbar_mode(ui_InfoLabel, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_text_color(ui_InfoLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_opa(ui_InfoLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_TempIncreaseBtn = lv_obj_create(ui_MainScreen); +lv_obj_set_width( ui_TempIncreaseBtn, 45); +lv_obj_set_height( ui_TempIncreaseBtn, 45); +lv_obj_set_x( ui_TempIncreaseBtn, 39 ); +lv_obj_set_y( ui_TempIncreaseBtn, -40 ); +lv_obj_set_align( ui_TempIncreaseBtn, LV_ALIGN_CENTER ); +lv_obj_clear_flag( ui_TempIncreaseBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_blend_mode(ui_TempIncreaseBtn, LV_BLEND_MODE_MULTIPLY, LV_PART_MAIN| LV_STATE_DEFAULT); - ui_WifiIndicatorLabel = lv_label_create(ui_MainScreen); - lv_obj_set_width(ui_WifiIndicatorLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_WifiIndicatorLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_WifiIndicatorLabel, 10); - lv_obj_set_y(ui_WifiIndicatorLabel, -100); - lv_obj_set_align(ui_WifiIndicatorLabel, LV_ALIGN_CENTER); - lv_label_set_text(ui_WifiIndicatorLabel, ""); - lv_label_set_recolor(ui_WifiIndicatorLabel, "true"); - lv_obj_set_style_text_font(ui_WifiIndicatorLabel, &lv_font_montserrat_24, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_TempIncreaseLabel = lv_label_create(ui_MainScreen); +lv_obj_set_width( ui_TempIncreaseLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_TempIncreaseLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_TempIncreaseLabel, 39 ); +lv_obj_set_y( ui_TempIncreaseLabel, -40 ); +lv_obj_set_align( ui_TempIncreaseLabel, LV_ALIGN_CENTER ); +lv_label_set_long_mode(ui_TempIncreaseLabel,LV_LABEL_LONG_CLIP); +lv_label_set_text(ui_TempIncreaseLabel,"+"); +lv_obj_set_style_text_font(ui_TempIncreaseLabel, &lv_font_montserrat_48, LV_PART_MAIN| LV_STATE_DEFAULT); - lv_obj_add_event_cb(ui_TimeLabel, ui_event_TimeLabel, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_StatusLabel, ui_event_StatusLabel, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_TempLabel, ui_event_TempLabel, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_HumidityLabel, ui_event_HumidityLabel, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_ModeDropdown, ui_event_ModeDropdown, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_SetupBtn, ui_event_SetupBtn, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_TempArc, ui_event_TempArc, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_TempDecreaseBtn, ui_event_TempDecreaseBtn, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_TempIncreaseBtn, ui_event_TempIncreaseBtn, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_InfoBtn, ui_event_InfoBtn, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_MainScreen, ui_event_MainScreen, LV_EVENT_ALL, NULL); +ui_InfoBtn = lv_btn_create(ui_MainScreen); +lv_obj_set_width( ui_InfoBtn, 90); +lv_obj_set_height( ui_InfoBtn, 36); +lv_obj_set_x( ui_InfoBtn, -2 ); +lv_obj_set_y( ui_InfoBtn, -45 ); +lv_obj_set_align( ui_InfoBtn, LV_ALIGN_BOTTOM_RIGHT ); +lv_obj_add_flag( ui_InfoBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_InfoBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_scrollbar_mode(ui_InfoBtn, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_bg_color(ui_InfoBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_InfoBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_InfoBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_InfoBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_InfoLabel = lv_label_create(ui_MainScreen); +lv_obj_set_width( ui_InfoLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_InfoLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_InfoLabel, -33 ); +lv_obj_set_y( ui_InfoLabel, -56 ); +lv_obj_set_align( ui_InfoLabel, LV_ALIGN_BOTTOM_RIGHT ); +lv_label_set_long_mode(ui_InfoLabel,LV_LABEL_LONG_CLIP); +lv_label_set_text(ui_InfoLabel,"Info"); +lv_obj_add_flag( ui_InfoLabel, LV_OBJ_FLAG_IGNORE_LAYOUT ); /// Flags +lv_obj_clear_flag( ui_InfoLabel, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_scrollbar_mode(ui_InfoLabel, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_text_color(ui_InfoLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_InfoLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_WifiIndicatorLabel = lv_label_create(ui_MainScreen); +lv_obj_set_width( ui_WifiIndicatorLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_WifiIndicatorLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_WifiIndicatorLabel, 10 ); +lv_obj_set_y( ui_WifiIndicatorLabel, -100 ); +lv_obj_set_align( ui_WifiIndicatorLabel, LV_ALIGN_CENTER ); +lv_label_set_text(ui_WifiIndicatorLabel,""); +lv_label_set_recolor(ui_WifiIndicatorLabel,"true"); +lv_obj_set_style_text_font(ui_WifiIndicatorLabel, &lv_font_montserrat_24, LV_PART_MAIN| LV_STATE_DEFAULT); + +lv_obj_add_event_cb(ui_TimeLabel, ui_event_TimeLabel, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_StatusLabel, ui_event_StatusLabel, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_TempLabel, ui_event_TempLabel, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_HumidityLabel, ui_event_HumidityLabel, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_ModeDropdown, ui_event_ModeDropdown, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_SetupBtn, ui_event_SetupBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_TempArc, ui_event_TempArc, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_TempDecreaseBtn, ui_event_TempDecreaseBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_TempIncreaseBtn, ui_event_TempIncreaseBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_InfoBtn, ui_event_InfoBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_MainScreen, ui_event_MainScreen, LV_EVENT_ALL, NULL); } diff --git a/app/src/ui/screens/ui_MatterConfig.c b/app/src/ui/screens/ui_MatterConfig.c index 84864e8..bfbc018 100644 --- a/app/src/ui/screens/ui_MatterConfig.c +++ b/app/src/ui/screens/ui_MatterConfig.c @@ -1,5 +1,5 @@ // This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.3.1 +// SquareLine Studio version: SquareLine Studio 1.3.2 // LVGL version: 8.3.6 // Project name: Thermostat @@ -7,58 +7,57 @@ void ui_MatterConfig_screen_init(void) { - ui_MatterConfig = lv_obj_create(NULL); - lv_obj_clear_flag(ui_MatterConfig, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | - LV_OBJ_FLAG_SCROLL_MOMENTUM); /// Flags - lv_obj_set_scrollbar_mode(ui_MatterConfig, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_bg_color(ui_MatterConfig, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_MatterConfig, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_MatterConfig, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_MatterConfig, LV_GRAD_DIR_HOR, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_QrHomeBtn = lv_btn_create(ui_MatterConfig); - lv_obj_set_width(ui_QrHomeBtn, 100); - lv_obj_set_height(ui_QrHomeBtn, 36); - lv_obj_set_x(ui_QrHomeBtn, -2); - lv_obj_set_y(ui_QrHomeBtn, -3); - lv_obj_set_align(ui_QrHomeBtn, LV_ALIGN_BOTTOM_RIGHT); - lv_obj_add_flag(ui_QrHomeBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - lv_obj_clear_flag(ui_QrHomeBtn, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_bg_color(ui_QrHomeBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_QrHomeBtn, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_QrHomeBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_QrHomeBtn, LV_GRAD_DIR_VER, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_SetupHomeLabel1 = lv_label_create(ui_MatterConfig); - lv_obj_set_width(ui_SetupHomeLabel1, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_SetupHomeLabel1, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_SetupHomeLabel1, -30); - lv_obj_set_y(ui_SetupHomeLabel1, -14); - lv_obj_set_align(ui_SetupHomeLabel1, LV_ALIGN_BOTTOM_RIGHT); - lv_label_set_text(ui_SetupHomeLabel1, "Home"); - lv_obj_set_style_text_color(ui_SetupHomeLabel1, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_opa(ui_SetupHomeLabel1, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_QRImage = lv_obj_create(ui_MatterConfig); - lv_obj_set_width(ui_QRImage, 150); - lv_obj_set_height(ui_QRImage, 150); - lv_obj_set_x(ui_QRImage, 0); - lv_obj_set_y(ui_QRImage, -20); - lv_obj_set_align(ui_QRImage, LV_ALIGN_CENTER); - lv_obj_clear_flag(ui_QRImage, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_opa(ui_QRImage, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_ManualPairingCode = lv_label_create(ui_MatterConfig); - lv_obj_set_width(ui_ManualPairingCode, 195); - lv_obj_set_height(ui_ManualPairingCode, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_ManualPairingCode, 13); - lv_obj_set_y(ui_ManualPairingCode, -10); - lv_obj_set_align(ui_ManualPairingCode, LV_ALIGN_BOTTOM_LEFT); - lv_label_set_long_mode(ui_ManualPairingCode, LV_LABEL_LONG_SCROLL_CIRCULAR); - lv_label_set_text(ui_ManualPairingCode, "Manual Pairing Code"); - lv_obj_set_style_text_font(ui_ManualPairingCode, &lv_font_montserrat_20, LV_PART_MAIN | LV_STATE_DEFAULT); - - lv_obj_add_event_cb(ui_QrHomeBtn, ui_event_QrHomeBtn, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_MatterConfig, ui_event_MatterConfig, LV_EVENT_ALL, NULL); +ui_MatterConfig = lv_obj_create(NULL); +lv_obj_clear_flag( ui_MatterConfig, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM ); /// Flags +lv_obj_set_scrollbar_mode(ui_MatterConfig, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_bg_color(ui_MatterConfig, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_MatterConfig, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_MatterConfig, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_MatterConfig, LV_GRAD_DIR_HOR, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_QrHomeBtn = lv_btn_create(ui_MatterConfig); +lv_obj_set_width( ui_QrHomeBtn, 100); +lv_obj_set_height( ui_QrHomeBtn, 36); +lv_obj_set_x( ui_QrHomeBtn, -2 ); +lv_obj_set_y( ui_QrHomeBtn, -3 ); +lv_obj_set_align( ui_QrHomeBtn, LV_ALIGN_BOTTOM_RIGHT ); +lv_obj_add_flag( ui_QrHomeBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_QrHomeBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_QrHomeBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_QrHomeBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_QrHomeBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_QrHomeBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_SetupHomeLabel1 = lv_label_create(ui_MatterConfig); +lv_obj_set_width( ui_SetupHomeLabel1, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_SetupHomeLabel1, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_SetupHomeLabel1, -30 ); +lv_obj_set_y( ui_SetupHomeLabel1, -14 ); +lv_obj_set_align( ui_SetupHomeLabel1, LV_ALIGN_BOTTOM_RIGHT ); +lv_label_set_text(ui_SetupHomeLabel1,"Home"); +lv_obj_set_style_text_color(ui_SetupHomeLabel1, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_SetupHomeLabel1, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_QRImage = lv_obj_create(ui_MatterConfig); +lv_obj_set_width( ui_QRImage, 150); +lv_obj_set_height( ui_QRImage, 150); +lv_obj_set_x( ui_QRImage, 0 ); +lv_obj_set_y( ui_QRImage, -20 ); +lv_obj_set_align( ui_QRImage, LV_ALIGN_CENTER ); +lv_obj_clear_flag( ui_QRImage, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_opa(ui_QRImage, 0, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_ManualPairingCode = lv_label_create(ui_MatterConfig); +lv_obj_set_width( ui_ManualPairingCode, 195); +lv_obj_set_height( ui_ManualPairingCode, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_ManualPairingCode, 13 ); +lv_obj_set_y( ui_ManualPairingCode, -10 ); +lv_obj_set_align( ui_ManualPairingCode, LV_ALIGN_BOTTOM_LEFT ); +lv_label_set_long_mode(ui_ManualPairingCode,LV_LABEL_LONG_SCROLL_CIRCULAR); +lv_label_set_text(ui_ManualPairingCode,"Manual Pairing Code"); +lv_obj_set_style_text_font(ui_ManualPairingCode, &lv_font_montserrat_20, LV_PART_MAIN| LV_STATE_DEFAULT); + +lv_obj_add_event_cb(ui_QrHomeBtn, ui_event_QrHomeBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_MatterConfig, ui_event_MatterConfig, LV_EVENT_ALL, NULL); } diff --git a/app/src/ui/screens/ui_MqttConfig.c b/app/src/ui/screens/ui_MqttConfig.c new file mode 100644 index 0000000..94ebb5c --- /dev/null +++ b/app/src/ui/screens/ui_MqttConfig.c @@ -0,0 +1,127 @@ +// This file was generated by SquareLine Studio +// SquareLine Studio version: SquareLine Studio 1.3.2 +// LVGL version: 8.3.6 +// Project name: Thermostat + +#include "../ui.h" + +void ui_MqttConfig_screen_init(void) +{ +ui_MqttConfig = lv_obj_create(NULL); +lv_obj_clear_flag( ui_MqttConfig, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM ); /// Flags +lv_obj_set_scrollbar_mode(ui_MqttConfig, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_bg_color(ui_MqttConfig, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_MqttConfig, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_MqttConfig, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_MqttConfig, LV_GRAD_DIR_HOR, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_MqttKeyboard = lv_keyboard_create(ui_MqttConfig); +lv_obj_set_width( ui_MqttKeyboard, 320); +lv_obj_set_height( ui_MqttKeyboard, 105); +lv_obj_set_x( ui_MqttKeyboard, 0 ); +lv_obj_set_y( ui_MqttKeyboard, 67 ); +lv_obj_set_align( ui_MqttKeyboard, LV_ALIGN_LEFT_MID ); +lv_obj_set_style_bg_color(ui_MqttKeyboard, lv_color_hex(0xBD6994), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_MqttKeyboard, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_MqttHostname = lv_textarea_create(ui_MqttConfig); +lv_obj_set_width( ui_MqttHostname, 205); +lv_obj_set_height( ui_MqttHostname, LV_SIZE_CONTENT); /// 20 +lv_obj_set_x( ui_MqttHostname, -50 ); +lv_obj_set_y( ui_MqttHostname, -97 ); +lv_obj_set_align( ui_MqttHostname, LV_ALIGN_CENTER ); +lv_textarea_set_text(ui_MqttHostname,"MQTT Host"); +lv_textarea_set_placeholder_text(ui_MqttHostname,"Placeholder..."); +lv_textarea_set_one_line(ui_MqttHostname,true); +lv_obj_set_style_text_font(ui_MqttHostname, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); + + + +ui_MqttUsername = lv_textarea_create(ui_MqttConfig); +lv_obj_set_width( ui_MqttUsername, 205); +lv_obj_set_height( ui_MqttUsername, LV_SIZE_CONTENT); /// 33 +lv_obj_set_x( ui_MqttUsername, -50 ); +lv_obj_set_y( ui_MqttUsername, -52 ); +lv_obj_set_align( ui_MqttUsername, LV_ALIGN_CENTER ); +lv_textarea_set_text(ui_MqttUsername,"Username"); +lv_textarea_set_placeholder_text(ui_MqttUsername,"Placeholder..."); +lv_textarea_set_one_line(ui_MqttUsername,true); +lv_obj_set_style_text_font(ui_MqttUsername, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); + + + +ui_MqttPassword = lv_textarea_create(ui_MqttConfig); +lv_obj_set_width( ui_MqttPassword, 205); +lv_obj_set_height( ui_MqttPassword, LV_SIZE_CONTENT); /// 33 +lv_obj_set_x( ui_MqttPassword, -50 ); +lv_obj_set_y( ui_MqttPassword, -7 ); +lv_obj_set_align( ui_MqttPassword, LV_ALIGN_CENTER ); +lv_textarea_set_text(ui_MqttPassword,"Password"); +lv_textarea_set_placeholder_text(ui_MqttPassword,"Placeholder..."); +lv_textarea_set_one_line(ui_MqttPassword,true); +lv_obj_set_style_text_font(ui_MqttPassword, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); + + + +ui_MqttPwdLabel = lv_label_create(ui_MqttConfig); +lv_obj_set_width( ui_MqttPwdLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_MqttPwdLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_MqttPwdLabel, 230 ); +lv_obj_set_y( ui_MqttPwdLabel, -99 ); +lv_obj_set_align( ui_MqttPwdLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_MqttPwdLabel,"Password:"); + +ui_MqttSaveBtn = lv_btn_create(ui_MqttConfig); +lv_obj_set_width( ui_MqttSaveBtn, 100); +lv_obj_set_height( ui_MqttSaveBtn, 36); +lv_obj_set_x( ui_MqttSaveBtn, -1 ); +lv_obj_set_y( ui_MqttSaveBtn, -20 ); +lv_obj_set_align( ui_MqttSaveBtn, LV_ALIGN_RIGHT_MID ); +lv_obj_add_flag( ui_MqttSaveBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_MqttSaveBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_MqttSaveBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_MqttSaveBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_MqttSaveBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_MqttSaveBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_MqttSaveLabel = lv_label_create(ui_MqttConfig); +lv_obj_set_width( ui_MqttSaveLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_MqttSaveLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_MqttSaveLabel, 109 ); +lv_obj_set_y( ui_MqttSaveLabel, -20 ); +lv_obj_set_align( ui_MqttSaveLabel, LV_ALIGN_CENTER ); +lv_label_set_text(ui_MqttSaveLabel,"Save"); +lv_obj_set_style_text_color(ui_MqttSaveLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_MqttSaveLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_MqttCancelBtn = lv_btn_create(ui_MqttConfig); +lv_obj_set_width( ui_MqttCancelBtn, 100); +lv_obj_set_height( ui_MqttCancelBtn, 36); +lv_obj_set_x( ui_MqttCancelBtn, -1 ); +lv_obj_set_y( ui_MqttCancelBtn, -60 ); +lv_obj_set_align( ui_MqttCancelBtn, LV_ALIGN_RIGHT_MID ); +lv_obj_add_flag( ui_MqttCancelBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_MqttCancelBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_MqttCancelBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_MqttCancelBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_MqttCancelBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_MqttCancelBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_MqttCancelLabel = lv_label_create(ui_MqttConfig); +lv_obj_set_width( ui_MqttCancelLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_MqttCancelLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_MqttCancelLabel, 109 ); +lv_obj_set_y( ui_MqttCancelLabel, -60 ); +lv_obj_set_align( ui_MqttCancelLabel, LV_ALIGN_CENTER ); +lv_label_set_text(ui_MqttCancelLabel,"Cancel"); +lv_obj_set_style_text_color(ui_MqttCancelLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_MqttCancelLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +lv_keyboard_set_textarea(ui_MqttKeyboard,ui_MqttHostname); +lv_obj_add_event_cb(ui_MqttHostname, ui_event_MqttHostname, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_MqttUsername, ui_event_MqttUsername, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_MqttPassword, ui_event_MqttPassword, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_MqttSaveBtn, ui_event_MqttSaveBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_MqttCancelBtn, ui_event_MqttCancelBtn, LV_EVENT_ALL, NULL); + +} diff --git a/app/src/ui/screens/ui_Setup.c b/app/src/ui/screens/ui_Setup.c index 990c50b..ccd3170 100644 --- a/app/src/ui/screens/ui_Setup.c +++ b/app/src/ui/screens/ui_Setup.c @@ -1,5 +1,5 @@ // This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.3.1 +// SquareLine Studio version: SquareLine Studio 1.3.2 // LVGL version: 8.3.6 // Project name: Thermostat @@ -7,206 +7,235 @@ void ui_Setup_screen_init(void) { - ui_Setup = lv_obj_create(NULL); - lv_obj_add_state(ui_Setup, LV_STATE_USER_1); /// States - lv_obj_clear_flag(ui_Setup, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | - LV_OBJ_FLAG_SCROLL_MOMENTUM); /// Flags - lv_obj_set_scrollbar_mode(ui_Setup, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_bg_color(ui_Setup, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_Setup, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_Setup, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_Setup, LV_GRAD_DIR_HOR, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_TempUnitsLabel = lv_label_create(ui_Setup); - lv_obj_set_width(ui_TempUnitsLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_TempUnitsLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_TempUnitsLabel, 7); - lv_obj_set_y(ui_TempUnitsLabel, -15); - lv_obj_set_align(ui_TempUnitsLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_TempUnitsLabel, "Temp Units: "); - - ui_FahrenheitLabel = lv_label_create(ui_Setup); - lv_obj_set_width(ui_FahrenheitLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_FahrenheitLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_FahrenheitLabel, 133); - lv_obj_set_y(ui_FahrenheitLabel, -15); - lv_obj_set_align(ui_FahrenheitLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_FahrenheitLabel, "F"); - - ui_TempUnitsSwitch = lv_switch_create(ui_Setup); - lv_obj_set_width(ui_TempUnitsSwitch, 50); - lv_obj_set_height(ui_TempUnitsSwitch, 22); - lv_obj_set_x(ui_TempUnitsSwitch, 13); - lv_obj_set_y(ui_TempUnitsSwitch, -15); - lv_obj_set_align(ui_TempUnitsSwitch, LV_ALIGN_CENTER); - lv_obj_add_state(ui_TempUnitsSwitch, LV_STATE_CHECKED); /// States - lv_obj_set_style_bg_color(ui_TempUnitsSwitch, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_TempUnitsSwitch, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_CelciusLabel = lv_label_create(ui_Setup); - lv_obj_set_width(ui_CelciusLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_CelciusLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_CelciusLabel, 203); - lv_obj_set_y(ui_CelciusLabel, -15); - lv_obj_set_align(ui_CelciusLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_CelciusLabel, "C"); - - ui_TempCorrectionTextLabel = lv_label_create(ui_Setup); - lv_obj_set_width(ui_TempCorrectionTextLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_TempCorrectionTextLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_TempCorrectionTextLabel, 7); - lv_obj_set_y(ui_TempCorrectionTextLabel, -100); - lv_obj_set_align(ui_TempCorrectionTextLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_TempCorrectionTextLabel, "Temp Correction:"); - - ui_TempCorrectionLabel = lv_label_create(ui_Setup); - lv_obj_set_width(ui_TempCorrectionLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_TempCorrectionLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_TempCorrectionLabel, 138); - lv_obj_set_y(ui_TempCorrectionLabel, -100); - lv_obj_set_align(ui_TempCorrectionLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_TempCorrectionLabel, "-3.8°"); - - ui_TempCorrectionSlider = lv_slider_create(ui_Setup); - lv_slider_set_range(ui_TempCorrectionSlider, -65, 10); - if(lv_slider_get_mode(ui_TempCorrectionSlider) == LV_SLIDER_MODE_RANGE) lv_slider_set_left_value( - ui_TempCorrectionSlider, -65, LV_ANIM_OFF); - lv_obj_set_width(ui_TempCorrectionSlider, 127); - lv_obj_set_height(ui_TempCorrectionSlider, 10); - lv_obj_set_x(ui_TempCorrectionSlider, -9); - lv_obj_set_y(ui_TempCorrectionSlider, -100); - lv_obj_set_align(ui_TempCorrectionSlider, LV_ALIGN_RIGHT_MID); - - ui_TempSwingTextLabel = lv_label_create(ui_Setup); - lv_obj_set_width(ui_TempSwingTextLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_TempSwingTextLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_TempSwingTextLabel, 7); - lv_obj_set_y(ui_TempSwingTextLabel, -58); - lv_obj_set_align(ui_TempSwingTextLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_TempSwingTextLabel, "Temp Swing:"); - - ui_TempSwingLabel = lv_label_create(ui_Setup); - lv_obj_set_width(ui_TempSwingLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_TempSwingLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_TempSwingLabel, 138); - lv_obj_set_y(ui_TempSwingLabel, -58); - lv_obj_set_align(ui_TempSwingLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_TempSwingLabel, "3.5°"); - - ui_TempSwingSlider = lv_slider_create(ui_Setup); - lv_slider_set_range(ui_TempSwingSlider, 0, 60); - lv_slider_set_value(ui_TempSwingSlider, 30, LV_ANIM_OFF); - if(lv_slider_get_mode(ui_TempSwingSlider) == LV_SLIDER_MODE_RANGE) lv_slider_set_left_value(ui_TempSwingSlider, 0, - LV_ANIM_OFF); - lv_obj_set_width(ui_TempSwingSlider, 127); - lv_obj_set_height(ui_TempSwingSlider, 10); - lv_obj_set_x(ui_TempSwingSlider, -9); - lv_obj_set_y(ui_TempSwingSlider, -58); - lv_obj_set_align(ui_TempSwingSlider, LV_ALIGN_RIGHT_MID); - - ui_HvacCoolLabel = lv_label_create(ui_Setup); - lv_obj_set_width(ui_HvacCoolLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_HvacCoolLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_HvacCoolLabel, 7); - lv_obj_set_y(ui_HvacCoolLabel, 31); - lv_obj_set_align(ui_HvacCoolLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_HvacCoolLabel, "HVAC Cool:"); - - ui_HvacCoolCheckbox = lv_checkbox_create(ui_Setup); - lv_checkbox_set_text(ui_HvacCoolCheckbox, ""); - lv_obj_set_width(ui_HvacCoolCheckbox, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_HvacCoolCheckbox, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_HvacCoolCheckbox, 0); - lv_obj_set_y(ui_HvacCoolCheckbox, 31); - lv_obj_set_align(ui_HvacCoolCheckbox, LV_ALIGN_CENTER); - lv_obj_add_flag(ui_HvacCoolCheckbox, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - - ui_HvacFanLabel = lv_label_create(ui_Setup); - lv_obj_set_width(ui_HvacFanLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_HvacFanLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_HvacFanLabel, 7); - lv_obj_set_y(ui_HvacFanLabel, 63); - lv_obj_set_align(ui_HvacFanLabel, LV_ALIGN_LEFT_MID); - lv_label_set_long_mode(ui_HvacFanLabel, LV_LABEL_LONG_SCROLL); - lv_label_set_text(ui_HvacFanLabel, "HVAC Fan:"); - - ui_HvacFanCheckbox = lv_checkbox_create(ui_Setup); - lv_checkbox_set_text(ui_HvacFanCheckbox, ""); - lv_obj_set_width(ui_HvacFanCheckbox, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_HvacFanCheckbox, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_HvacFanCheckbox, 0); - lv_obj_set_y(ui_HvacFanCheckbox, 63); - lv_obj_set_align(ui_HvacFanCheckbox, LV_ALIGN_CENTER); - lv_obj_add_flag(ui_HvacFanCheckbox, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - - ui_SetupUncommonBtn = lv_btn_create(ui_Setup); - lv_obj_set_width(ui_SetupUncommonBtn, 100); - lv_obj_set_height(ui_SetupUncommonBtn, 36); - lv_obj_set_x(ui_SetupUncommonBtn, -2); - lv_obj_set_y(ui_SetupUncommonBtn, -45); - lv_obj_set_align(ui_SetupUncommonBtn, LV_ALIGN_BOTTOM_RIGHT); - lv_obj_add_flag(ui_SetupUncommonBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - lv_obj_clear_flag(ui_SetupUncommonBtn, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_bg_color(ui_SetupUncommonBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_SetupUncommonBtn, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_SetupUncommonBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_SetupUncommonBtn, LV_GRAD_DIR_VER, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_SetupUncommonLabel = lv_label_create(ui_Setup); - lv_obj_set_width(ui_SetupUncommonLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_SetupUncommonLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_SetupUncommonLabel, -21); - lv_obj_set_y(ui_SetupUncommonLabel, -56); - lv_obj_set_align(ui_SetupUncommonLabel, LV_ALIGN_BOTTOM_RIGHT); - lv_label_set_text(ui_SetupUncommonLabel, "Unusual"); - lv_obj_set_style_text_color(ui_SetupUncommonLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_opa(ui_SetupUncommonLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_SetupHomeBtn = lv_btn_create(ui_Setup); - lv_obj_set_width(ui_SetupHomeBtn, 100); - lv_obj_set_height(ui_SetupHomeBtn, 36); - lv_obj_set_x(ui_SetupHomeBtn, -2); - lv_obj_set_y(ui_SetupHomeBtn, -3); - lv_obj_set_align(ui_SetupHomeBtn, LV_ALIGN_BOTTOM_RIGHT); - lv_obj_add_flag(ui_SetupHomeBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - lv_obj_clear_flag(ui_SetupHomeBtn, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_bg_color(ui_SetupHomeBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_SetupHomeBtn, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_SetupHomeBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_SetupHomeBtn, LV_GRAD_DIR_VER, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_SetupHomeLabel = lv_label_create(ui_Setup); - lv_obj_set_width(ui_SetupHomeLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_SetupHomeLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_SetupHomeLabel, -30); - lv_obj_set_y(ui_SetupHomeLabel, -14); - lv_obj_set_align(ui_SetupHomeLabel, LV_ALIGN_BOTTOM_RIGHT); - lv_label_set_text(ui_SetupHomeLabel, "Home"); - lv_obj_set_style_text_color(ui_SetupHomeLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_opa(ui_SetupHomeLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_MatterLabel = lv_label_create(ui_Setup); - lv_obj_set_width(ui_MatterLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_MatterLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_MatterLabel, 7); - lv_obj_set_y(ui_MatterLabel, 95); - lv_obj_set_align(ui_MatterLabel, LV_ALIGN_LEFT_MID); - lv_label_set_long_mode(ui_MatterLabel, LV_LABEL_LONG_SCROLL); - lv_label_set_text(ui_MatterLabel, "Matter Enable:"); - - ui_MatterCheckbox = lv_checkbox_create(ui_Setup); - lv_checkbox_set_text(ui_MatterCheckbox, ""); - lv_obj_set_width(ui_MatterCheckbox, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_MatterCheckbox, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_MatterCheckbox, 0); - lv_obj_set_y(ui_MatterCheckbox, 95); - lv_obj_set_align(ui_MatterCheckbox, LV_ALIGN_CENTER); - lv_obj_add_flag(ui_MatterCheckbox, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - - lv_obj_add_event_cb(ui_TempCorrectionSlider, ui_event_TempCorrectionSlider, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_TempSwingSlider, ui_event_TempSwingSlider, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_SetupUncommonBtn, ui_event_SetupUncommonBtn, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_SetupHomeBtn, ui_event_SetupHomeBtn, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_Setup, ui_event_Setup, LV_EVENT_ALL, NULL); +ui_Setup = lv_obj_create(NULL); +lv_obj_add_state( ui_Setup, LV_STATE_USER_1 ); /// States +lv_obj_clear_flag( ui_Setup, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM ); /// Flags +lv_obj_set_scrollbar_mode(ui_Setup, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_bg_color(ui_Setup, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_Setup, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_Setup, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_Setup, LV_GRAD_DIR_HOR, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_TempUnitsLabel = lv_label_create(ui_Setup); +lv_obj_set_width( ui_TempUnitsLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_TempUnitsLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_TempUnitsLabel, 7 ); +lv_obj_set_y( ui_TempUnitsLabel, -15 ); +lv_obj_set_align( ui_TempUnitsLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_TempUnitsLabel,"Temp Units: "); + +ui_FahrenheitLabel = lv_label_create(ui_Setup); +lv_obj_set_width( ui_FahrenheitLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_FahrenheitLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_FahrenheitLabel, 133 ); +lv_obj_set_y( ui_FahrenheitLabel, -15 ); +lv_obj_set_align( ui_FahrenheitLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_FahrenheitLabel,"F"); + +ui_TempUnitsSwitch = lv_switch_create(ui_Setup); +lv_obj_set_width( ui_TempUnitsSwitch, 50); +lv_obj_set_height( ui_TempUnitsSwitch, 22); +lv_obj_set_x( ui_TempUnitsSwitch, 13 ); +lv_obj_set_y( ui_TempUnitsSwitch, -15 ); +lv_obj_set_align( ui_TempUnitsSwitch, LV_ALIGN_CENTER ); +lv_obj_add_state( ui_TempUnitsSwitch, LV_STATE_CHECKED ); /// States +lv_obj_set_style_bg_color(ui_TempUnitsSwitch, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_TempUnitsSwitch, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + + +ui_CelciusLabel = lv_label_create(ui_Setup); +lv_obj_set_width( ui_CelciusLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_CelciusLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_CelciusLabel, 203 ); +lv_obj_set_y( ui_CelciusLabel, -15 ); +lv_obj_set_align( ui_CelciusLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_CelciusLabel,"C"); + +ui_TempCorrectionTextLabel = lv_label_create(ui_Setup); +lv_obj_set_width( ui_TempCorrectionTextLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_TempCorrectionTextLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_TempCorrectionTextLabel, 7 ); +lv_obj_set_y( ui_TempCorrectionTextLabel, -100 ); +lv_obj_set_align( ui_TempCorrectionTextLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_TempCorrectionTextLabel,"Temp Correction:"); + +ui_TempCorrectionLabel = lv_label_create(ui_Setup); +lv_obj_set_width( ui_TempCorrectionLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_TempCorrectionLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_TempCorrectionLabel, 138 ); +lv_obj_set_y( ui_TempCorrectionLabel, -100 ); +lv_obj_set_align( ui_TempCorrectionLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_TempCorrectionLabel,"-3.8°"); + +ui_TempCorrectionSlider = lv_slider_create(ui_Setup); +lv_slider_set_range(ui_TempCorrectionSlider, -65,10); +if (lv_slider_get_mode(ui_TempCorrectionSlider)==LV_SLIDER_MODE_RANGE ) lv_slider_set_left_value( ui_TempCorrectionSlider, -65, LV_ANIM_OFF); +lv_obj_set_width( ui_TempCorrectionSlider, 127); +lv_obj_set_height( ui_TempCorrectionSlider, 10); +lv_obj_set_x( ui_TempCorrectionSlider, -9 ); +lv_obj_set_y( ui_TempCorrectionSlider, -100 ); +lv_obj_set_align( ui_TempCorrectionSlider, LV_ALIGN_RIGHT_MID ); + + +ui_TempSwingTextLabel = lv_label_create(ui_Setup); +lv_obj_set_width( ui_TempSwingTextLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_TempSwingTextLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_TempSwingTextLabel, 7 ); +lv_obj_set_y( ui_TempSwingTextLabel, -58 ); +lv_obj_set_align( ui_TempSwingTextLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_TempSwingTextLabel,"Temp Swing:"); + +ui_TempSwingLabel = lv_label_create(ui_Setup); +lv_obj_set_width( ui_TempSwingLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_TempSwingLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_TempSwingLabel, 138 ); +lv_obj_set_y( ui_TempSwingLabel, -58 ); +lv_obj_set_align( ui_TempSwingLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_TempSwingLabel,"3.5°"); + +ui_TempSwingSlider = lv_slider_create(ui_Setup); +lv_slider_set_range(ui_TempSwingSlider, 0,60); +lv_slider_set_value( ui_TempSwingSlider, 30, LV_ANIM_OFF); +if (lv_slider_get_mode(ui_TempSwingSlider)==LV_SLIDER_MODE_RANGE ) lv_slider_set_left_value( ui_TempSwingSlider, 0, LV_ANIM_OFF); +lv_obj_set_width( ui_TempSwingSlider, 127); +lv_obj_set_height( ui_TempSwingSlider, 10); +lv_obj_set_x( ui_TempSwingSlider, -9 ); +lv_obj_set_y( ui_TempSwingSlider, -58 ); +lv_obj_set_align( ui_TempSwingSlider, LV_ALIGN_RIGHT_MID ); + + +ui_HvacCoolLabel = lv_label_create(ui_Setup); +lv_obj_set_width( ui_HvacCoolLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_HvacCoolLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_HvacCoolLabel, 7 ); +lv_obj_set_y( ui_HvacCoolLabel, 31 ); +lv_obj_set_align( ui_HvacCoolLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_HvacCoolLabel,"HVAC Cool:"); + +ui_HvacCoolCheckbox = lv_checkbox_create(ui_Setup); +lv_checkbox_set_text(ui_HvacCoolCheckbox,""); +lv_obj_set_width( ui_HvacCoolCheckbox, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_HvacCoolCheckbox, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_HvacCoolCheckbox, 0 ); +lv_obj_set_y( ui_HvacCoolCheckbox, 31 ); +lv_obj_set_align( ui_HvacCoolCheckbox, LV_ALIGN_CENTER ); +lv_obj_add_flag( ui_HvacCoolCheckbox, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags + +ui_HvacFanLabel = lv_label_create(ui_Setup); +lv_obj_set_width( ui_HvacFanLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_HvacFanLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_HvacFanLabel, 7 ); +lv_obj_set_y( ui_HvacFanLabel, 63 ); +lv_obj_set_align( ui_HvacFanLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_long_mode(ui_HvacFanLabel,LV_LABEL_LONG_SCROLL); +lv_label_set_text(ui_HvacFanLabel,"HVAC Fan:"); + +ui_HvacFanCheckbox = lv_checkbox_create(ui_Setup); +lv_checkbox_set_text(ui_HvacFanCheckbox,""); +lv_obj_set_width( ui_HvacFanCheckbox, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_HvacFanCheckbox, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_HvacFanCheckbox, 0 ); +lv_obj_set_y( ui_HvacFanCheckbox, 63 ); +lv_obj_set_align( ui_HvacFanCheckbox, LV_ALIGN_CENTER ); +lv_obj_add_flag( ui_HvacFanCheckbox, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags + +ui_SetupMqttBtn = lv_btn_create(ui_Setup); +lv_obj_set_width( ui_SetupMqttBtn, 100); +lv_obj_set_height( ui_SetupMqttBtn, 36); +lv_obj_set_x( ui_SetupMqttBtn, -2 ); +lv_obj_set_y( ui_SetupMqttBtn, -87 ); +lv_obj_set_align( ui_SetupMqttBtn, LV_ALIGN_BOTTOM_RIGHT ); +lv_obj_add_flag( ui_SetupMqttBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_SetupMqttBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_SetupMqttBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_SetupMqttBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_SetupMqttBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_SetupMqttBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_SetupMqttLabel = lv_label_create(ui_Setup); +lv_obj_set_width( ui_SetupMqttLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_SetupMqttLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_SetupMqttLabel, -30 ); +lv_obj_set_y( ui_SetupMqttLabel, -98 ); +lv_obj_set_align( ui_SetupMqttLabel, LV_ALIGN_BOTTOM_RIGHT ); +lv_label_set_text(ui_SetupMqttLabel,"MQTT"); +lv_obj_set_style_text_color(ui_SetupMqttLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_SetupMqttLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_SetupUncommonBtn = lv_btn_create(ui_Setup); +lv_obj_set_width( ui_SetupUncommonBtn, 100); +lv_obj_set_height( ui_SetupUncommonBtn, 36); +lv_obj_set_x( ui_SetupUncommonBtn, -2 ); +lv_obj_set_y( ui_SetupUncommonBtn, -45 ); +lv_obj_set_align( ui_SetupUncommonBtn, LV_ALIGN_BOTTOM_RIGHT ); +lv_obj_add_flag( ui_SetupUncommonBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_SetupUncommonBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_SetupUncommonBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_SetupUncommonBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_SetupUncommonBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_SetupUncommonBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_SetupUncommonLabel = lv_label_create(ui_Setup); +lv_obj_set_width( ui_SetupUncommonLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_SetupUncommonLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_SetupUncommonLabel, -21 ); +lv_obj_set_y( ui_SetupUncommonLabel, -56 ); +lv_obj_set_align( ui_SetupUncommonLabel, LV_ALIGN_BOTTOM_RIGHT ); +lv_label_set_text(ui_SetupUncommonLabel,"Unusual"); +lv_obj_set_style_text_color(ui_SetupUncommonLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_SetupUncommonLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_SetupHomeBtn = lv_btn_create(ui_Setup); +lv_obj_set_width( ui_SetupHomeBtn, 100); +lv_obj_set_height( ui_SetupHomeBtn, 36); +lv_obj_set_x( ui_SetupHomeBtn, -2 ); +lv_obj_set_y( ui_SetupHomeBtn, -3 ); +lv_obj_set_align( ui_SetupHomeBtn, LV_ALIGN_BOTTOM_RIGHT ); +lv_obj_add_flag( ui_SetupHomeBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_SetupHomeBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_SetupHomeBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_SetupHomeBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_SetupHomeBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_SetupHomeBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_SetupHomeLabel = lv_label_create(ui_Setup); +lv_obj_set_width( ui_SetupHomeLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_SetupHomeLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_SetupHomeLabel, -30 ); +lv_obj_set_y( ui_SetupHomeLabel, -14 ); +lv_obj_set_align( ui_SetupHomeLabel, LV_ALIGN_BOTTOM_RIGHT ); +lv_label_set_text(ui_SetupHomeLabel,"Home"); +lv_obj_set_style_text_color(ui_SetupHomeLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_SetupHomeLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_HomeAutomationLabel = lv_label_create(ui_Setup); +lv_obj_set_width( ui_HomeAutomationLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_HomeAutomationLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_HomeAutomationLabel, 7 ); +lv_obj_set_y( ui_HomeAutomationLabel, 95 ); +lv_obj_set_align( ui_HomeAutomationLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_long_mode(ui_HomeAutomationLabel,LV_LABEL_LONG_SCROLL); +#ifdef MATTER_ENABLED +lv_label_set_text(ui_HomeAutomationLabel,"Matter Enable:"); +#endif +#ifdef MQTT_ENABLED +lv_label_set_text(ui_HomeAutomationLabel,"MQTT Enable:"); +#endif + +ui_HomeAutomationCheckbox = lv_checkbox_create(ui_Setup); +lv_checkbox_set_text(ui_HomeAutomationCheckbox,""); +lv_obj_set_width( ui_HomeAutomationCheckbox, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_HomeAutomationCheckbox, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_HomeAutomationCheckbox, 0 ); +lv_obj_set_y( ui_HomeAutomationCheckbox, 95 ); +lv_obj_set_align( ui_HomeAutomationCheckbox, LV_ALIGN_CENTER ); +lv_obj_add_flag( ui_HomeAutomationCheckbox, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags + +lv_obj_add_event_cb(ui_TempCorrectionSlider, ui_event_TempCorrectionSlider, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_TempSwingSlider, ui_event_TempSwingSlider, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_SetupMqttBtn, ui_event_SetupMqttBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_SetupUncommonBtn, ui_event_SetupUncommonBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_SetupHomeBtn, ui_event_SetupHomeBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_Setup, ui_event_Setup, LV_EVENT_ALL, NULL); } diff --git a/app/src/ui/screens/ui_ThermostatRestart.c b/app/src/ui/screens/ui_ThermostatRestart.c index bdee363..4abaf3a 100644 --- a/app/src/ui/screens/ui_ThermostatRestart.c +++ b/app/src/ui/screens/ui_ThermostatRestart.c @@ -1,5 +1,5 @@ // This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.3.1 +// SquareLine Studio version: SquareLine Studio 1.3.2 // LVGL version: 8.3.6 // Project name: Thermostat @@ -7,39 +7,37 @@ void ui_ThermostatRestart_screen_init(void) { - ui_ThermostatRestart = lv_obj_create(NULL); - lv_obj_clear_flag(ui_ThermostatRestart, - LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | - LV_OBJ_FLAG_SCROLL_MOMENTUM); /// Flags - lv_obj_set_scrollbar_mode(ui_ThermostatRestart, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_bg_color(ui_ThermostatRestart, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_ThermostatRestart, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_ThermostatRestart, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_ThermostatRestart, LV_GRAD_DIR_HOR, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_ThermostatRestart = lv_obj_create(NULL); +lv_obj_clear_flag( ui_ThermostatRestart, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM ); /// Flags +lv_obj_set_scrollbar_mode(ui_ThermostatRestart, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_bg_color(ui_ThermostatRestart, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_ThermostatRestart, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_ThermostatRestart, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_ThermostatRestart, LV_GRAD_DIR_HOR, LV_PART_MAIN| LV_STATE_DEFAULT); - ui_Notification = lv_label_create(ui_ThermostatRestart); - lv_obj_set_width(ui_Notification, lv_pct(70)); - lv_obj_set_height(ui_Notification, lv_pct(13)); - lv_obj_set_align(ui_Notification, LV_ALIGN_CENTER); - lv_label_set_text(ui_Notification, "Restarting Thermostat"); - lv_obj_set_style_text_align(ui_Notification, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_radius(ui_Notification, 20, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_color(ui_Notification, lv_color_hex(0xFFD800), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_Notification, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_left(ui_Notification, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_right(ui_Notification, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_top(ui_Notification, 7, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_bottom(ui_Notification, 0, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_Notification = lv_label_create(ui_ThermostatRestart); +lv_obj_set_width( ui_Notification, lv_pct(70)); +lv_obj_set_height( ui_Notification, lv_pct(13)); +lv_obj_set_align( ui_Notification, LV_ALIGN_CENTER ); +lv_label_set_text(ui_Notification,"Restarting Thermostat"); +lv_obj_set_style_text_align(ui_Notification, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_radius(ui_Notification, 20, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_color(ui_Notification, lv_color_hex(0xFFD800), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_Notification, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_pad_left(ui_Notification, 0, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_pad_right(ui_Notification, 0, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_pad_top(ui_Notification, 7, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_pad_bottom(ui_Notification, 0, LV_PART_MAIN| LV_STATE_DEFAULT); - ui_RestartCountdown = lv_label_create(ui_ThermostatRestart); - lv_obj_set_width(ui_RestartCountdown, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_RestartCountdown, LV_SIZE_CONTENT); /// 1 - lv_obj_set_y(ui_RestartCountdown, 52); - lv_obj_set_x(ui_RestartCountdown, lv_pct(0)); - lv_obj_set_align(ui_RestartCountdown, LV_ALIGN_CENTER); - lv_label_set_text(ui_RestartCountdown, "30"); - lv_obj_set_style_text_font(ui_RestartCountdown, &lv_font_montserrat_24, LV_PART_MAIN | LV_STATE_DEFAULT); +ui_RestartCountdown = lv_label_create(ui_ThermostatRestart); +lv_obj_set_width( ui_RestartCountdown, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_RestartCountdown, LV_SIZE_CONTENT); /// 1 +lv_obj_set_y( ui_RestartCountdown, 52 ); +lv_obj_set_x( ui_RestartCountdown, lv_pct(0) ); +lv_obj_set_align( ui_RestartCountdown, LV_ALIGN_CENTER ); +lv_label_set_text(ui_RestartCountdown,"30"); +lv_obj_set_style_text_font(ui_RestartCountdown, &lv_font_montserrat_24, LV_PART_MAIN| LV_STATE_DEFAULT); - lv_obj_add_event_cb(ui_ThermostatRestart, ui_event_ThermostatRestart, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_ThermostatRestart, ui_event_ThermostatRestart, LV_EVENT_ALL, NULL); } diff --git a/app/src/ui/screens/ui_WifiConfig.c b/app/src/ui/screens/ui_WifiConfig.c index 4c2bdab..2d1268d 100644 --- a/app/src/ui/screens/ui_WifiConfig.c +++ b/app/src/ui/screens/ui_WifiConfig.c @@ -1,5 +1,5 @@ // This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.3.1 +// SquareLine Studio version: SquareLine Studio 1.3.2 // LVGL version: 8.3.6 // Project name: Thermostat @@ -7,137 +7,137 @@ void ui_WifiConfig_screen_init(void) { - ui_WifiConfig = lv_obj_create(NULL); - lv_obj_clear_flag(ui_WifiConfig, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | - LV_OBJ_FLAG_SCROLL_MOMENTUM); /// Flags - lv_obj_set_scrollbar_mode(ui_WifiConfig, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_bg_color(ui_WifiConfig, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_WifiConfig, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_WifiConfig, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_WifiConfig, LV_GRAD_DIR_HOR, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_Keyboard = lv_keyboard_create(ui_WifiConfig); - lv_obj_set_width(ui_Keyboard, 320); - lv_obj_set_height(ui_Keyboard, 120); - lv_obj_set_x(ui_Keyboard, 0); - lv_obj_set_y(ui_Keyboard, 60); - lv_obj_set_align(ui_Keyboard, LV_ALIGN_LEFT_MID); - lv_obj_set_style_bg_color(ui_Keyboard, lv_color_hex(0xBD6994), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_Keyboard, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_PSK = lv_textarea_create(ui_WifiConfig); - lv_obj_set_width(ui_PSK, 205); - lv_obj_set_height(ui_PSK, LV_SIZE_CONTENT); /// 33 - lv_obj_set_x(ui_PSK, -55); - lv_obj_set_y(ui_PSK, -21); - lv_obj_set_align(ui_PSK, LV_ALIGN_CENTER); - lv_textarea_set_placeholder_text(ui_PSK, "Placeholder..."); - lv_textarea_set_one_line(ui_PSK, true); - lv_obj_set_style_text_font(ui_PSK, &lv_font_montserrat_20, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_PwdLabel = lv_label_create(ui_WifiConfig); - lv_obj_set_width(ui_PwdLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_PwdLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_PwdLabel, 6); - lv_obj_set_y(ui_PwdLabel, -51); - lv_obj_set_align(ui_PwdLabel, LV_ALIGN_LEFT_MID); - lv_label_set_text(ui_PwdLabel, "Password:"); - - ui_SsidDropdown = lv_dropdown_create(ui_WifiConfig); - lv_dropdown_set_options(ui_SsidDropdown, ""); - lv_obj_set_width(ui_SsidDropdown, 165); - lv_obj_set_height(ui_SsidDropdown, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_SsidDropdown, -1); - lv_obj_set_y(ui_SsidDropdown, 1); - lv_obj_set_align(ui_SsidDropdown, LV_ALIGN_TOP_RIGHT); - lv_obj_add_flag(ui_SsidDropdown, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - - ui_ScanBtn = lv_btn_create(ui_WifiConfig); - lv_obj_set_width(ui_ScanBtn, 100); - lv_obj_set_height(ui_ScanBtn, 36); - lv_obj_set_x(ui_ScanBtn, 1); - lv_obj_set_y(ui_ScanBtn, 1); - lv_obj_add_flag(ui_ScanBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - lv_obj_clear_flag(ui_ScanBtn, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_bg_color(ui_ScanBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_ScanBtn, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_ScanBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_ScanBtn, LV_GRAD_DIR_VER, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_ScanLabel = lv_label_create(ui_WifiConfig); - lv_obj_set_width(ui_ScanLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_ScanLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_ScanLabel, -111); - lv_obj_set_y(ui_ScanLabel, -102); - lv_obj_set_align(ui_ScanLabel, LV_ALIGN_CENTER); - lv_label_set_text(ui_ScanLabel, "Scan"); - lv_obj_set_style_text_color(ui_ScanLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_opa(ui_ScanLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_SaveBtn = lv_btn_create(ui_WifiConfig); - lv_obj_set_width(ui_SaveBtn, 100); - lv_obj_set_height(ui_SaveBtn, 36); - lv_obj_set_x(ui_SaveBtn, -1); - lv_obj_set_y(ui_SaveBtn, -20); - lv_obj_set_align(ui_SaveBtn, LV_ALIGN_RIGHT_MID); - lv_obj_add_flag(ui_SaveBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - lv_obj_clear_flag(ui_SaveBtn, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_bg_color(ui_SaveBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_SaveBtn, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_SaveBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_SaveBtn, LV_GRAD_DIR_VER, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_SaveLabel = lv_label_create(ui_WifiConfig); - lv_obj_set_width(ui_SaveLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_SaveLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_SaveLabel, 109); - lv_obj_set_y(ui_SaveLabel, -20); - lv_obj_set_align(ui_SaveLabel, LV_ALIGN_CENTER); - lv_label_set_text(ui_SaveLabel, "Save"); - lv_obj_set_style_text_color(ui_SaveLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_opa(ui_SaveLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_CancelBtn = lv_btn_create(ui_WifiConfig); - lv_obj_set_width(ui_CancelBtn, 100); - lv_obj_set_height(ui_CancelBtn, 36); - lv_obj_set_x(ui_CancelBtn, -1); - lv_obj_set_y(ui_CancelBtn, -60); - lv_obj_set_align(ui_CancelBtn, LV_ALIGN_RIGHT_MID); - lv_obj_add_flag(ui_CancelBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags - lv_obj_clear_flag(ui_CancelBtn, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_bg_color(ui_CancelBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(ui_CancelBtn, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_color(ui_CancelBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_grad_dir(ui_CancelBtn, LV_GRAD_DIR_VER, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_CancelLabel = lv_label_create(ui_WifiConfig); - lv_obj_set_width(ui_CancelLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_CancelLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_CancelLabel, 109); - lv_obj_set_y(ui_CancelLabel, -60); - lv_obj_set_align(ui_CancelLabel, LV_ALIGN_CENTER); - lv_label_set_text(ui_CancelLabel, "Cancel"); - lv_obj_set_style_text_color(ui_CancelLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_opa(ui_CancelLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - - ui_WifiStatusLabel = lv_label_create(ui_WifiConfig); - lv_obj_set_width(ui_WifiStatusLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_height(ui_WifiStatusLabel, LV_SIZE_CONTENT); /// 1 - lv_obj_set_x(ui_WifiStatusLabel, 6); - lv_obj_set_y(ui_WifiStatusLabel, 42); - lv_label_set_long_mode(ui_WifiStatusLabel, LV_LABEL_LONG_CLIP); - lv_label_set_text(ui_WifiStatusLabel, ""); - lv_obj_clear_flag(ui_WifiStatusLabel, - LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_CLICK_FOCUSABLE | LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SNAPPABLE | - LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM | - LV_OBJ_FLAG_SCROLL_CHAIN); /// Flags - lv_obj_set_scrollbar_mode(ui_WifiStatusLabel, LV_SCROLLBAR_MODE_OFF); - - lv_keyboard_set_textarea(ui_Keyboard, ui_PSK); - lv_obj_add_event_cb(ui_SsidDropdown, ui_event_SsidDropdown, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_ScanBtn, ui_event_ScanBtn, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_SaveBtn, ui_event_SaveBtn, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_CancelBtn, ui_event_CancelBtn, LV_EVENT_ALL, NULL); - lv_obj_add_event_cb(ui_WifiStatusLabel, ui_event_WifiStatusLabel, LV_EVENT_ALL, NULL); +ui_WifiConfig = lv_obj_create(NULL); +lv_obj_clear_flag( ui_WifiConfig, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM ); /// Flags +lv_obj_set_scrollbar_mode(ui_WifiConfig, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_bg_color(ui_WifiConfig, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_WifiConfig, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_WifiConfig, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_WifiConfig, LV_GRAD_DIR_HOR, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_Keyboard = lv_keyboard_create(ui_WifiConfig); +lv_obj_set_width( ui_Keyboard, 320); +lv_obj_set_height( ui_Keyboard, 120); +lv_obj_set_x( ui_Keyboard, 0 ); +lv_obj_set_y( ui_Keyboard, 60 ); +lv_obj_set_align( ui_Keyboard, LV_ALIGN_LEFT_MID ); +lv_obj_set_style_bg_color(ui_Keyboard, lv_color_hex(0xBD6994), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_Keyboard, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_PSK = lv_textarea_create(ui_WifiConfig); +lv_obj_set_width( ui_PSK, 205); +lv_obj_set_height( ui_PSK, LV_SIZE_CONTENT); /// 33 +lv_obj_set_x( ui_PSK, -55 ); +lv_obj_set_y( ui_PSK, -21 ); +lv_obj_set_align( ui_PSK, LV_ALIGN_CENTER ); +lv_textarea_set_placeholder_text(ui_PSK,"Placeholder..."); +lv_textarea_set_one_line(ui_PSK,true); +lv_obj_set_style_text_font(ui_PSK, &lv_font_montserrat_20, LV_PART_MAIN| LV_STATE_DEFAULT); + + + +ui_PwdLabel = lv_label_create(ui_WifiConfig); +lv_obj_set_width( ui_PwdLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_PwdLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_PwdLabel, 6 ); +lv_obj_set_y( ui_PwdLabel, -51 ); +lv_obj_set_align( ui_PwdLabel, LV_ALIGN_LEFT_MID ); +lv_label_set_text(ui_PwdLabel,"Password:"); + +ui_SsidDropdown = lv_dropdown_create(ui_WifiConfig); +lv_dropdown_set_options( ui_SsidDropdown, "" ); +lv_obj_set_width( ui_SsidDropdown, 165); +lv_obj_set_height( ui_SsidDropdown, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_SsidDropdown, -1 ); +lv_obj_set_y( ui_SsidDropdown, 1 ); +lv_obj_set_align( ui_SsidDropdown, LV_ALIGN_TOP_RIGHT ); +lv_obj_add_flag( ui_SsidDropdown, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags + + + +ui_ScanBtn = lv_btn_create(ui_WifiConfig); +lv_obj_set_width( ui_ScanBtn, 100); +lv_obj_set_height( ui_ScanBtn, 36); +lv_obj_set_x( ui_ScanBtn, 1 ); +lv_obj_set_y( ui_ScanBtn, 1 ); +lv_obj_add_flag( ui_ScanBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_ScanBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_ScanBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_ScanBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_ScanBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_ScanBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_ScanLabel = lv_label_create(ui_WifiConfig); +lv_obj_set_width( ui_ScanLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_ScanLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_ScanLabel, -111 ); +lv_obj_set_y( ui_ScanLabel, -102 ); +lv_obj_set_align( ui_ScanLabel, LV_ALIGN_CENTER ); +lv_label_set_text(ui_ScanLabel,"Scan"); +lv_obj_set_style_text_color(ui_ScanLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_ScanLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_SaveBtn = lv_btn_create(ui_WifiConfig); +lv_obj_set_width( ui_SaveBtn, 100); +lv_obj_set_height( ui_SaveBtn, 36); +lv_obj_set_x( ui_SaveBtn, -1 ); +lv_obj_set_y( ui_SaveBtn, -20 ); +lv_obj_set_align( ui_SaveBtn, LV_ALIGN_RIGHT_MID ); +lv_obj_add_flag( ui_SaveBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_SaveBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_SaveBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_SaveBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_SaveBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_SaveBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_SaveLabel = lv_label_create(ui_WifiConfig); +lv_obj_set_width( ui_SaveLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_SaveLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_SaveLabel, 109 ); +lv_obj_set_y( ui_SaveLabel, -20 ); +lv_obj_set_align( ui_SaveLabel, LV_ALIGN_CENTER ); +lv_label_set_text(ui_SaveLabel,"Save"); +lv_obj_set_style_text_color(ui_SaveLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_SaveLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_CancelBtn = lv_btn_create(ui_WifiConfig); +lv_obj_set_width( ui_CancelBtn, 100); +lv_obj_set_height( ui_CancelBtn, 36); +lv_obj_set_x( ui_CancelBtn, -1 ); +lv_obj_set_y( ui_CancelBtn, -60 ); +lv_obj_set_align( ui_CancelBtn, LV_ALIGN_RIGHT_MID ); +lv_obj_add_flag( ui_CancelBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_CancelBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_CancelBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_CancelBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_CancelBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_CancelBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_CancelLabel = lv_label_create(ui_WifiConfig); +lv_obj_set_width( ui_CancelLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_CancelLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_CancelLabel, 109 ); +lv_obj_set_y( ui_CancelLabel, -60 ); +lv_obj_set_align( ui_CancelLabel, LV_ALIGN_CENTER ); +lv_label_set_text(ui_CancelLabel,"Cancel"); +lv_obj_set_style_text_color(ui_CancelLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_CancelLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_WifiStatusLabel = lv_label_create(ui_WifiConfig); +lv_obj_set_width( ui_WifiStatusLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_WifiStatusLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_WifiStatusLabel, 6 ); +lv_obj_set_y( ui_WifiStatusLabel, 42 ); +lv_label_set_long_mode(ui_WifiStatusLabel,LV_LABEL_LONG_CLIP); +lv_label_set_text(ui_WifiStatusLabel,""); +lv_obj_clear_flag( ui_WifiStatusLabel, LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_CLICK_FOCUSABLE | LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SNAPPABLE | LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_SCROLL_CHAIN ); /// Flags +lv_obj_set_scrollbar_mode(ui_WifiStatusLabel, LV_SCROLLBAR_MODE_OFF); + +lv_keyboard_set_textarea(ui_Keyboard,ui_PSK); +lv_obj_add_event_cb(ui_SsidDropdown, ui_event_SsidDropdown, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_ScanBtn, ui_event_ScanBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_SaveBtn, ui_event_SaveBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_CancelBtn, ui_event_CancelBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_WifiStatusLabel, ui_event_WifiStatusLabel, LV_EVENT_ALL, NULL); } diff --git a/app/src/ui/ui.c b/app/src/ui/ui.c index 8bd8b5d..2028d24 100644 --- a/app/src/ui/ui.c +++ b/app/src/ui/ui.c @@ -1,5 +1,5 @@ // This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.3.1 +// SquareLine Studio version: SquareLine Studio 1.3.2 // LVGL version: 8.3.6 // Project name: Thermostat @@ -8,469 +8,473 @@ ///////////////////// VARIABLES //////////////////// + // SCREEN: ui_MainScreen void ui_MainScreen_screen_init(void); -void ui_event_MainScreen(lv_event_t * e); -lv_obj_t * ui_MainScreen; -void ui_event_TimeLabel(lv_event_t * e); -lv_obj_t * ui_TimeLabel; -void ui_event_StatusLabel(lv_event_t * e); -lv_obj_t * ui_StatusLabel; -void ui_event_TempLabel(lv_event_t * e); -lv_obj_t * ui_TempLabel; -void ui_event_HumidityLabel(lv_event_t * e); -lv_obj_t * ui_HumidityLabel; -void ui_event_ModeDropdown(lv_event_t * e); -lv_obj_t * ui_ModeDropdown; -void ui_event_SetupBtn(lv_event_t * e); -lv_obj_t * ui_SetupBtn; -lv_obj_t * ui_SetupLabel; -lv_obj_t * ui_SetTempBg1; -lv_obj_t * ui_SetTempBg; -void ui_event_TempArc(lv_event_t * e); -lv_obj_t * ui_TempArc; -lv_obj_t * ui_SetTemp; -lv_obj_t * ui_SetTempFrac; -void ui_event_TempDecreaseBtn(lv_event_t * e); -lv_obj_t * ui_TempDecreaseBtn; -lv_obj_t * ui_TempDecreaseLabel; -void ui_event_TempIncreaseBtn(lv_event_t * e); -lv_obj_t * ui_TempIncreaseBtn; -lv_obj_t * ui_TempIncreaseLabel; -void ui_event_InfoBtn(lv_event_t * e); -lv_obj_t * ui_InfoBtn; -lv_obj_t * ui_InfoLabel; -lv_obj_t * ui_WifiIndicatorLabel; +void ui_event_MainScreen( lv_event_t * e); +lv_obj_t *ui_MainScreen; +void ui_event_TimeLabel( lv_event_t * e); +lv_obj_t *ui_TimeLabel; +void ui_event_StatusLabel( lv_event_t * e); +lv_obj_t *ui_StatusLabel; +void ui_event_TempLabel( lv_event_t * e); +lv_obj_t *ui_TempLabel; +void ui_event_HumidityLabel( lv_event_t * e); +lv_obj_t *ui_HumidityLabel; +void ui_event_ModeDropdown( lv_event_t * e); +lv_obj_t *ui_ModeDropdown; +void ui_event_SetupBtn( lv_event_t * e); +lv_obj_t *ui_SetupBtn; +lv_obj_t *ui_SetupLabel; +lv_obj_t *ui_SetTempBg1; +lv_obj_t *ui_SetTempBg; +void ui_event_TempArc( lv_event_t * e); +lv_obj_t *ui_TempArc; +lv_obj_t *ui_SetTemp; +lv_obj_t *ui_SetTempFrac; +void ui_event_TempDecreaseBtn( lv_event_t * e); +lv_obj_t *ui_TempDecreaseBtn; +lv_obj_t *ui_TempDecreaseLabel; +void ui_event_TempIncreaseBtn( lv_event_t * e); +lv_obj_t *ui_TempIncreaseBtn; +lv_obj_t *ui_TempIncreaseLabel; +void ui_event_InfoBtn( lv_event_t * e); +lv_obj_t *ui_InfoBtn; +lv_obj_t *ui_InfoLabel; +lv_obj_t *ui_WifiIndicatorLabel; + // SCREEN: ui_Info void ui_Info_screen_init(void); -void ui_event_Info(lv_event_t * e); -lv_obj_t * ui_Info; -lv_obj_t * ui_WifiConnectedLabel; -lv_obj_t * ui_WifiConnCheckBox; -lv_obj_t * ui_WifiSsidLabel; -lv_obj_t * ui_IPLabel; -lv_obj_t * ui_HostnameLabel; -lv_obj_t * ui_RssiLabel; -lv_obj_t * ui_FwVersionLabel; -lv_obj_t * ui_BuildDateLabel; -lv_obj_t * ui_CopyrightLabel; -void ui_event_ShowQR(lv_event_t * e); -lv_obj_t * ui_ShowQR; -lv_obj_t * ui_ShowQRLabel; -void ui_event_HomeBtn(lv_event_t * e); -lv_obj_t * ui_HomeBtn; -lv_obj_t * ui_HomeLabel; +void ui_event_Info( lv_event_t * e); +lv_obj_t *ui_Info; +lv_obj_t *ui_WifiConnectedLabel; +lv_obj_t *ui_WifiConnCheckBox; +lv_obj_t *ui_WifiSsidLabel; +lv_obj_t *ui_IPLabel; +lv_obj_t *ui_HostnameLabel; +lv_obj_t *ui_RssiLabel; +lv_obj_t *ui_FwVersionLabel; +lv_obj_t *ui_BuildDateLabel; +lv_obj_t *ui_CopyrightLabel; +void ui_event_ShowQR( lv_event_t * e); +lv_obj_t *ui_ShowQR; +lv_obj_t *ui_ShowQRLabel; +void ui_event_HomeBtn( lv_event_t * e); +lv_obj_t *ui_HomeBtn; +lv_obj_t *ui_HomeLabel; + // SCREEN: ui_Setup void ui_Setup_screen_init(void); -void ui_event_Setup(lv_event_t * e); -lv_obj_t * ui_Setup; -lv_obj_t * ui_TempUnitsLabel; -lv_obj_t * ui_FahrenheitLabel; -lv_obj_t * ui_TempUnitsSwitch; -lv_obj_t * ui_CelciusLabel; -lv_obj_t * ui_TempCorrectionTextLabel; -lv_obj_t * ui_TempCorrectionLabel; -void ui_event_TempCorrectionSlider(lv_event_t * e); -lv_obj_t * ui_TempCorrectionSlider; -lv_obj_t * ui_TempSwingTextLabel; -lv_obj_t * ui_TempSwingLabel; -void ui_event_TempSwingSlider(lv_event_t * e); -lv_obj_t * ui_TempSwingSlider; -lv_obj_t * ui_HvacCoolLabel; -lv_obj_t * ui_HvacCoolCheckbox; -lv_obj_t * ui_HvacFanLabel; -lv_obj_t * ui_HvacFanCheckbox; -void ui_event_SetupUncommonBtn(lv_event_t * e); -lv_obj_t * ui_SetupUncommonBtn; -lv_obj_t * ui_SetupUncommonLabel; -void ui_event_SetupHomeBtn(lv_event_t * e); -lv_obj_t * ui_SetupHomeBtn; -lv_obj_t * ui_SetupHomeLabel; -lv_obj_t * ui_MatterLabel; -lv_obj_t * ui_MatterCheckbox; +void ui_event_Setup( lv_event_t * e); +lv_obj_t *ui_Setup; +lv_obj_t *ui_TempUnitsLabel; +lv_obj_t *ui_FahrenheitLabel; +lv_obj_t *ui_TempUnitsSwitch; +lv_obj_t *ui_CelciusLabel; +lv_obj_t *ui_TempCorrectionTextLabel; +lv_obj_t *ui_TempCorrectionLabel; +void ui_event_TempCorrectionSlider( lv_event_t * e); +lv_obj_t *ui_TempCorrectionSlider; +lv_obj_t *ui_TempSwingTextLabel; +lv_obj_t *ui_TempSwingLabel; +void ui_event_TempSwingSlider( lv_event_t * e); +lv_obj_t *ui_TempSwingSlider; +lv_obj_t *ui_HvacCoolLabel; +lv_obj_t *ui_HvacCoolCheckbox; +lv_obj_t *ui_HvacFanLabel; +lv_obj_t *ui_HvacFanCheckbox; +void ui_event_SetupMqttBtn( lv_event_t * e); +lv_obj_t *ui_SetupMqttBtn; +lv_obj_t *ui_SetupMqttLabel; +void ui_event_SetupUncommonBtn( lv_event_t * e); +lv_obj_t *ui_SetupUncommonBtn; +lv_obj_t *ui_SetupUncommonLabel; +void ui_event_SetupHomeBtn( lv_event_t * e); +lv_obj_t *ui_SetupHomeBtn; +lv_obj_t *ui_SetupHomeLabel; +lv_obj_t *ui_HomeAutomationLabel; +lv_obj_t *ui_HomeAutomationCheckbox; + // SCREEN: ui_LessCommonSetup void ui_LessCommonSetup_screen_init(void); -void ui_event_LessCommonSetup(lv_event_t * e); -lv_obj_t * ui_LessCommonSetup; -void ui_event_CalibrateBtn(lv_event_t * e); -lv_obj_t * ui_CalibrateBtn; -lv_obj_t * ui_CalibrateLabel; -lv_obj_t * ui_TimezoneLabel1; -lv_obj_t * ui_TimezoneDropdown; -lv_obj_t * ui_UiSleepTextLabel; -lv_obj_t * ui_UiSleepLabel; -void ui_event_UiSleepSlider(lv_event_t * e); -lv_obj_t * ui_UiSleepSlider; -lv_obj_t * ui_DualStageHeatLabel; -lv_obj_t * ui_Hvac2StageHeatCheckbox; -lv_obj_t * ui_DisableLabel1; -lv_obj_t * ui_RevValveCheckbox; -lv_obj_t * ui_DisableBeepLabel; -lv_obj_t * ui_AudibleBeepCheckbox; -void ui_event_SetupWifiBtn(lv_event_t * e); -lv_obj_t * ui_SetupWifiBtn; -lv_obj_t * ui_SetupWifiLabel; -void ui_event_SetupHomeBtn2(lv_event_t * e); -lv_obj_t * ui_SetupHomeBtn2; -lv_obj_t * ui_SetupHomeLabel2; +void ui_event_LessCommonSetup( lv_event_t * e); +lv_obj_t *ui_LessCommonSetup; +void ui_event_CalibrateBtn( lv_event_t * e); +lv_obj_t *ui_CalibrateBtn; +lv_obj_t *ui_CalibrateLabel; +lv_obj_t *ui_TimezoneLabel1; +lv_obj_t *ui_TimezoneDropdown; +lv_obj_t *ui_UiSleepTextLabel; +lv_obj_t *ui_UiSleepLabel; +void ui_event_UiSleepSlider( lv_event_t * e); +lv_obj_t *ui_UiSleepSlider; +lv_obj_t *ui_DualStageHeatLabel; +lv_obj_t *ui_Hvac2StageHeatCheckbox; +lv_obj_t *ui_DisableLabel1; +lv_obj_t *ui_RevValveCheckbox; +lv_obj_t *ui_DisableBeepLabel; +lv_obj_t *ui_AudibleBeepCheckbox; +void ui_event_SetupWifiBtn( lv_event_t * e); +lv_obj_t *ui_SetupWifiBtn; +lv_obj_t *ui_SetupWifiLabel; +void ui_event_SetupHomeBtn2( lv_event_t * e); +lv_obj_t *ui_SetupHomeBtn2; +lv_obj_t *ui_SetupHomeLabel2; + // SCREEN: ui_WifiConfig void ui_WifiConfig_screen_init(void); -lv_obj_t * ui_WifiConfig; -lv_obj_t * ui_Keyboard; -lv_obj_t * ui_PSK; -lv_obj_t * ui_PwdLabel; -void ui_event_SsidDropdown(lv_event_t * e); -lv_obj_t * ui_SsidDropdown; -void ui_event_ScanBtn(lv_event_t * e); -lv_obj_t * ui_ScanBtn; -lv_obj_t * ui_ScanLabel; -void ui_event_SaveBtn(lv_event_t * e); -lv_obj_t * ui_SaveBtn; -lv_obj_t * ui_SaveLabel; -void ui_event_CancelBtn(lv_event_t * e); -lv_obj_t * ui_CancelBtn; -lv_obj_t * ui_CancelLabel; -void ui_event_WifiStatusLabel(lv_event_t * e); -lv_obj_t * ui_WifiStatusLabel; +lv_obj_t *ui_WifiConfig; +lv_obj_t *ui_Keyboard; +lv_obj_t *ui_PSK; +lv_obj_t *ui_PwdLabel; +void ui_event_SsidDropdown( lv_event_t * e); +lv_obj_t *ui_SsidDropdown; +void ui_event_ScanBtn( lv_event_t * e); +lv_obj_t *ui_ScanBtn; +lv_obj_t *ui_ScanLabel; +void ui_event_SaveBtn( lv_event_t * e); +lv_obj_t *ui_SaveBtn; +lv_obj_t *ui_SaveLabel; +void ui_event_CancelBtn( lv_event_t * e); +lv_obj_t *ui_CancelBtn; +lv_obj_t *ui_CancelLabel; +void ui_event_WifiStatusLabel( lv_event_t * e); +lv_obj_t *ui_WifiStatusLabel; + // SCREEN: ui_MatterConfig void ui_MatterConfig_screen_init(void); -void ui_event_MatterConfig(lv_event_t * e); -lv_obj_t * ui_MatterConfig; -void ui_event_QrHomeBtn(lv_event_t * e); -lv_obj_t * ui_QrHomeBtn; -lv_obj_t * ui_SetupHomeLabel1; -lv_obj_t * ui_QRImage; -lv_obj_t * ui_ManualPairingCode; +void ui_event_MatterConfig( lv_event_t * e); +lv_obj_t *ui_MatterConfig; +void ui_event_QrHomeBtn( lv_event_t * e); +lv_obj_t *ui_QrHomeBtn; +lv_obj_t *ui_SetupHomeLabel1; +lv_obj_t *ui_QRImage; +lv_obj_t *ui_ManualPairingCode; + // SCREEN: ui_ThermostatRestart void ui_ThermostatRestart_screen_init(void); -void ui_event_ThermostatRestart(lv_event_t * e); -lv_obj_t * ui_ThermostatRestart; -lv_obj_t * ui_Notification; -lv_obj_t * ui_RestartCountdown; -lv_obj_t * ui____initial_actions0; +void ui_event_ThermostatRestart( lv_event_t * e); +lv_obj_t *ui_ThermostatRestart; +lv_obj_t *ui_Notification; +lv_obj_t *ui_RestartCountdown; + + +// SCREEN: ui_MqttConfig +void ui_MqttConfig_screen_init(void); +lv_obj_t *ui_MqttConfig; +lv_obj_t *ui_MqttKeyboard; +void ui_event_MqttHostname( lv_event_t * e); +lv_obj_t *ui_MqttHostname; +void ui_event_MqttUsername( lv_event_t * e); +lv_obj_t *ui_MqttUsername; +void ui_event_MqttPassword( lv_event_t * e); +lv_obj_t *ui_MqttPassword; +lv_obj_t *ui_MqttPwdLabel; +void ui_event_MqttSaveBtn( lv_event_t * e); +lv_obj_t *ui_MqttSaveBtn; +lv_obj_t *ui_MqttSaveLabel; +void ui_event_MqttCancelBtn( lv_event_t * e); +lv_obj_t *ui_MqttCancelBtn; +lv_obj_t *ui_MqttCancelLabel; +lv_obj_t *ui____initial_actions0; ///////////////////// TEST LVGL SETTINGS //////////////////// #if LV_COLOR_DEPTH != 16 #error "LV_COLOR_DEPTH should be 16bit to match SquareLine Studio's settings" #endif #if LV_COLOR_16_SWAP !=1 - // #error "LV_COLOR_16_SWAP should be 1 to match SquareLine Studio's settings" +// #error "LV_COLOR_16_SWAP should be 1 to match SquareLine Studio's settings" #endif ///////////////////// ANIMATIONS //////////////////// ///////////////////// FUNCTIONS //////////////////// -void ui_event_MainScreen(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - tftAwaken(e); - } +void ui_event_MainScreen( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + tftAwaken( e ); } -void ui_event_TimeLabel(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - tftAwaken(e); - } } -void ui_event_StatusLabel(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - tftAwaken(e); - } +void ui_event_TimeLabel( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + tftAwaken( e ); } -void ui_event_TempLabel(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - tftAwaken(e); - } } -void ui_event_HumidityLabel(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - tftAwaken(e); - } +void ui_event_StatusLabel( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + tftAwaken( e ); } -void ui_event_ModeDropdown(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_VALUE_CHANGED) { - tftHvacModeChange(e); - tftBeep(e); - } - if(event_code == LV_EVENT_CLICKED) { - tftStopTouchTimer(e); - } -} -void ui_event_SetupBtn(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - _ui_screen_change(&ui_Setup, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0, &ui_Setup_screen_init); - tftStopTouchTimer(e); - tftBeep(e); - } -} -void ui_event_TempArc(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_RELEASED) { - tftUpdateTempSet(e); - } - if(event_code == LV_EVENT_VALUE_CHANGED) { - tftUpdateTempSet(e); - } - if(event_code == LV_EVENT_RELEASED) { - tftBeep(e); - } -} -void ui_event_TempDecreaseBtn(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - tftAwaken(e); - tftDecreaseSetTemp(e); - } -} -void ui_event_TempIncreaseBtn(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - tftAwaken(e); - tftIncreaseSetTemp(e); - } -} -void ui_event_InfoBtn(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - _ui_screen_change(&ui_Info, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0, &ui_Info_screen_init); - tftStopTouchTimer(e); - tftBeep(e); - } -} -void ui_event_Info(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_SCREEN_LOADED) { - LoadInfoStrings(e); - } } -void ui_event_ShowQR(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - tftBeep(e); - _ui_screen_change(&ui_MatterConfig, LV_SCR_LOAD_ANIM_FADE_ON, 500, 0, &ui_MatterConfig_screen_init); - } -} -void ui_event_HomeBtn(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - tftAwaken(e); - _ui_screen_change(&ui_MainScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_MainScreen_screen_init); - } -} -void ui_event_Setup(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_SCREEN_LOADED) { - LoadConfigSettings(e); - } +void ui_event_TempLabel( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + tftAwaken( e ); } -void ui_event_TempCorrectionSlider(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_VALUE_CHANGED) { - tftUpdateTempCorrectionValue(e); - } } -void ui_event_TempSwingSlider(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_VALUE_CHANGED) { - tftUpdateTempSwingValue(e); - } +void ui_event_HumidityLabel( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + tftAwaken( e ); } -void ui_event_SetupUncommonBtn(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - _ui_screen_change(&ui_LessCommonSetup, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0, &ui_LessCommonSetup_screen_init); - tftBeep(e); - LoadUncommonSettings(e); - } -} -void ui_event_SetupHomeBtn(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - tftAwaken(e); - _ui_screen_change(&ui_MainScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_MainScreen_screen_init); - SaveConfigSettings(e); - } -} -void ui_event_LessCommonSetup(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_SCREEN_LOADED) { - LoadConfigSettings(e); - } } -void ui_event_CalibrateBtn(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - tftCalibrate(e); - } +void ui_event_ModeDropdown( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_VALUE_CHANGED) { + tftHvacModeChange( e ); + tftBeep( e ); } -void ui_event_UiSleepSlider(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_VALUE_CHANGED) { - tftUpdateUiSleepValue(e); - } +if ( event_code == LV_EVENT_CLICKED) { + tftStopTouchTimer( e ); } -void ui_event_SetupWifiBtn(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - _ui_screen_change(&ui_WifiConfig, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0, &ui_WifiConfig_screen_init); - tftClearPsk(e); - tftBeep(e); - } -} -void ui_event_SetupHomeBtn2(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - tftAwaken(e); - _ui_screen_change(&ui_MainScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_MainScreen_screen_init); - SaveUncommonConfigSettings(e); - } -} -void ui_event_SsidDropdown(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_VALUE_CHANGED) { - tftBeep(e); - } } -void ui_event_ScanBtn(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - StartWifiScan(e); - } +void ui_event_SetupBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + _ui_screen_change( &ui_Setup, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0, &ui_Setup_screen_init); + tftStopTouchTimer( e ); + tftBeep( e ); } -void ui_event_SaveBtn(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - tftSetNewWifi(e); - _ui_screen_change(&ui_MainScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 2, &ui_MainScreen_screen_init); - tftAwaken(e); - } -} -void ui_event_CancelBtn(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - _ui_screen_change(&ui_Setup, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_Setup_screen_init); - tftBeep(e); - stopWifiScan(e); - } -} -void ui_event_WifiStatusLabel(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - tftAwaken(e); - } } -void ui_event_MatterConfig(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_SCREEN_LOADED) { -#ifdef MATTER_ENABLED - ShowQrOnScreen(e); -#endif - } +void ui_event_TempArc( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_RELEASED) { + tftUpdateTempSet( e ); +} +if ( event_code == LV_EVENT_VALUE_CHANGED) { + tftUpdateTempSet( e ); +} +if ( event_code == LV_EVENT_RELEASED) { + tftBeep( e ); +} +} +void ui_event_TempDecreaseBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + tftAwaken( e ); + tftDecreaseSetTemp( e ); +} +} +void ui_event_TempIncreaseBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + tftAwaken( e ); + tftIncreaseSetTemp( e ); +} +} +void ui_event_InfoBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + _ui_screen_change( &ui_Info, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0, &ui_Info_screen_init); + tftStopTouchTimer( e ); + tftBeep( e ); +} +} +void ui_event_Info( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_SCREEN_LOADED) { + LoadInfoStrings( e ); +} +} +void ui_event_ShowQR( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + tftBeep( e ); + _ui_screen_change( &ui_MatterConfig, LV_SCR_LOAD_ANIM_FADE_ON, 500, 0, &ui_MatterConfig_screen_init); +} +} +void ui_event_HomeBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + tftAwaken( e ); + _ui_screen_change( &ui_MainScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_MainScreen_screen_init); +} +} +void ui_event_Setup( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_SCREEN_LOADED) { + LoadConfigSettings( e ); +} +} +void ui_event_TempCorrectionSlider( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_VALUE_CHANGED) { + tftUpdateTempCorrectionValue( e ); +} +} +void ui_event_TempSwingSlider( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_VALUE_CHANGED) { + tftUpdateTempSwingValue( e ); +} +} +void ui_event_SetupMqttBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + _ui_screen_change( &ui_MqttConfig, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0, &ui_MqttConfig_screen_init); + tftBeep( e ); + loadMqttSettings( e ); +} +} +void ui_event_SetupUncommonBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + _ui_screen_change( &ui_LessCommonSetup, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0, &ui_LessCommonSetup_screen_init); + tftBeep( e ); + LoadUncommonSettings( e ); +} +} +void ui_event_SetupHomeBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + tftAwaken( e ); + _ui_screen_change( &ui_MainScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_MainScreen_screen_init); + SaveConfigSettings( e ); +} +} +void ui_event_LessCommonSetup( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_SCREEN_LOADED) { + LoadConfigSettings( e ); +} +} +void ui_event_CalibrateBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + tftCalibrate( e ); +} +} +void ui_event_UiSleepSlider( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_VALUE_CHANGED) { + tftUpdateUiSleepValue( e ); +} +} +void ui_event_SetupWifiBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + _ui_screen_change( &ui_WifiConfig, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0, &ui_WifiConfig_screen_init); + tftClearPsk( e ); + tftBeep( e ); +} +} +void ui_event_SetupHomeBtn2( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + tftAwaken( e ); + _ui_screen_change( &ui_MainScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_MainScreen_screen_init); + SaveUncommonConfigSettings( e ); +} +} +void ui_event_SsidDropdown( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_VALUE_CHANGED) { + tftBeep( e ); +} +} +void ui_event_ScanBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + StartWifiScan( e ); +} +} +void ui_event_SaveBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + tftSetNewWifi( e ); + _ui_screen_change( &ui_MainScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 2, &ui_MainScreen_screen_init); + tftAwaken( e ); +} +} +void ui_event_CancelBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + _ui_screen_change( &ui_Setup, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_Setup_screen_init); + tftBeep( e ); + stopWifiScan( e ); +} +} +void ui_event_WifiStatusLabel( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + tftAwaken( e ); +} +} +void ui_event_MatterConfig( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_SCREEN_LOADED) { + ShowQrOnScreen( e ); +} +} +void ui_event_QrHomeBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + tftAwaken( e ); + _ui_screen_change( &ui_MainScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_MainScreen_screen_init); +} +} +void ui_event_ThermostatRestart( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_SCREEN_LOADED) { + tftCountdown( e ); +} +} +void ui_event_MqttHostname( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + _ui_keyboard_set_target(ui_MqttKeyboard, ui_MqttHostname); +} +} +void ui_event_MqttUsername( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + _ui_keyboard_set_target(ui_MqttKeyboard, ui_MqttUsername); +} +} +void ui_event_MqttPassword( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + _ui_keyboard_set_target(ui_MqttKeyboard, ui_MqttPassword); +} +} +void ui_event_MqttSaveBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + saveMqttSettings( e ); + _ui_screen_change( &ui_MainScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 2, &ui_MainScreen_screen_init); + tftAwaken( e ); +} +} +void ui_event_MqttCancelBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + _ui_screen_change( &ui_Setup, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_Setup_screen_init); + tftBeep( e ); } -void ui_event_QrHomeBtn(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_CLICKED) { - tftAwaken(e); - _ui_screen_change(&ui_MainScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_MainScreen_screen_init); - } -} -void ui_event_ThermostatRestart(lv_event_t * e) -{ - lv_event_code_t event_code = lv_event_get_code(e); - lv_obj_t * target = lv_event_get_target(e); - if(event_code == LV_EVENT_SCREEN_LOADED) { - tftCountdown(e); - } } ///////////////////// SCREENS //////////////////// -void ui_init(void) -{ - lv_disp_t * dispp = lv_disp_get_default(); - lv_theme_t * theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), - false, LV_FONT_DEFAULT); - lv_disp_set_theme(dispp, theme); - ui_MainScreen_screen_init(); - ui_Info_screen_init(); - ui_Setup_screen_init(); - ui_LessCommonSetup_screen_init(); - ui_WifiConfig_screen_init(); - ui_MatterConfig_screen_init(); - ui_ThermostatRestart_screen_init(); - ui____initial_actions0 = lv_obj_create(NULL); - lv_disp_load_scr(ui_MainScreen); +void ui_init( void ) +{ +lv_disp_t *dispp = lv_disp_get_default(); +lv_theme_t *theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), false, LV_FONT_DEFAULT); +lv_disp_set_theme(dispp, theme); +ui_MainScreen_screen_init(); +ui_Info_screen_init(); +ui_Setup_screen_init(); +ui_LessCommonSetup_screen_init(); +ui_WifiConfig_screen_init(); +ui_MatterConfig_screen_init(); +ui_ThermostatRestart_screen_init(); +ui_MqttConfig_screen_init(); +ui____initial_actions0 = lv_obj_create(NULL); +lv_disp_load_scr( ui_MainScreen); } diff --git a/app/src/ui/ui.h b/app/src/ui/ui.h index 025eaed..6da245b 100644 --- a/app/src/ui/ui.h +++ b/app/src/ui/ui.h @@ -1,5 +1,5 @@ // This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.3.1 +// SquareLine Studio version: SquareLine Studio 1.3.2 // LVGL version: 8.3.6 // Project name: Thermostat @@ -10,150 +10,173 @@ extern "C" { #endif -#include "lvgl.h" + #include "lvgl.h" #include "ui_helpers.h" #include "ui_events.h" // SCREEN: ui_MainScreen void ui_MainScreen_screen_init(void); -void ui_event_MainScreen(lv_event_t * e); -extern lv_obj_t * ui_MainScreen; -void ui_event_TimeLabel(lv_event_t * e); -extern lv_obj_t * ui_TimeLabel; -void ui_event_StatusLabel(lv_event_t * e); -extern lv_obj_t * ui_StatusLabel; -void ui_event_TempLabel(lv_event_t * e); -extern lv_obj_t * ui_TempLabel; -void ui_event_HumidityLabel(lv_event_t * e); -extern lv_obj_t * ui_HumidityLabel; -void ui_event_ModeDropdown(lv_event_t * e); -extern lv_obj_t * ui_ModeDropdown; -void ui_event_SetupBtn(lv_event_t * e); -extern lv_obj_t * ui_SetupBtn; -extern lv_obj_t * ui_SetupLabel; -extern lv_obj_t * ui_SetTempBg1; -extern lv_obj_t * ui_SetTempBg; -void ui_event_TempArc(lv_event_t * e); -extern lv_obj_t * ui_TempArc; -extern lv_obj_t * ui_SetTemp; -extern lv_obj_t * ui_SetTempFrac; -void ui_event_TempDecreaseBtn(lv_event_t * e); -extern lv_obj_t * ui_TempDecreaseBtn; -extern lv_obj_t * ui_TempDecreaseLabel; -void ui_event_TempIncreaseBtn(lv_event_t * e); -extern lv_obj_t * ui_TempIncreaseBtn; -extern lv_obj_t * ui_TempIncreaseLabel; -void ui_event_InfoBtn(lv_event_t * e); -extern lv_obj_t * ui_InfoBtn; -extern lv_obj_t * ui_InfoLabel; -extern lv_obj_t * ui_WifiIndicatorLabel; +void ui_event_MainScreen( lv_event_t * e); +extern lv_obj_t *ui_MainScreen; +void ui_event_TimeLabel( lv_event_t * e); +extern lv_obj_t *ui_TimeLabel; +void ui_event_StatusLabel( lv_event_t * e); +extern lv_obj_t *ui_StatusLabel; +void ui_event_TempLabel( lv_event_t * e); +extern lv_obj_t *ui_TempLabel; +void ui_event_HumidityLabel( lv_event_t * e); +extern lv_obj_t *ui_HumidityLabel; +void ui_event_ModeDropdown( lv_event_t * e); +extern lv_obj_t *ui_ModeDropdown; +void ui_event_SetupBtn( lv_event_t * e); +extern lv_obj_t *ui_SetupBtn; +extern lv_obj_t *ui_SetupLabel; +extern lv_obj_t *ui_SetTempBg1; +extern lv_obj_t *ui_SetTempBg; +void ui_event_TempArc( lv_event_t * e); +extern lv_obj_t *ui_TempArc; +extern lv_obj_t *ui_SetTemp; +extern lv_obj_t *ui_SetTempFrac; +void ui_event_TempDecreaseBtn( lv_event_t * e); +extern lv_obj_t *ui_TempDecreaseBtn; +extern lv_obj_t *ui_TempDecreaseLabel; +void ui_event_TempIncreaseBtn( lv_event_t * e); +extern lv_obj_t *ui_TempIncreaseBtn; +extern lv_obj_t *ui_TempIncreaseLabel; +void ui_event_InfoBtn( lv_event_t * e); +extern lv_obj_t *ui_InfoBtn; +extern lv_obj_t *ui_InfoLabel; +extern lv_obj_t *ui_WifiIndicatorLabel; // SCREEN: ui_Info void ui_Info_screen_init(void); -void ui_event_Info(lv_event_t * e); -extern lv_obj_t * ui_Info; -extern lv_obj_t * ui_WifiConnectedLabel; -extern lv_obj_t * ui_WifiConnCheckBox; -extern lv_obj_t * ui_WifiSsidLabel; -extern lv_obj_t * ui_IPLabel; -extern lv_obj_t * ui_HostnameLabel; -extern lv_obj_t * ui_RssiLabel; -extern lv_obj_t * ui_FwVersionLabel; -extern lv_obj_t * ui_BuildDateLabel; -extern lv_obj_t * ui_CopyrightLabel; -void ui_event_ShowQR(lv_event_t * e); -extern lv_obj_t * ui_ShowQR; -extern lv_obj_t * ui_ShowQRLabel; -void ui_event_HomeBtn(lv_event_t * e); -extern lv_obj_t * ui_HomeBtn; -extern lv_obj_t * ui_HomeLabel; +void ui_event_Info( lv_event_t * e); +extern lv_obj_t *ui_Info; +extern lv_obj_t *ui_WifiConnectedLabel; +extern lv_obj_t *ui_WifiConnCheckBox; +extern lv_obj_t *ui_WifiSsidLabel; +extern lv_obj_t *ui_IPLabel; +extern lv_obj_t *ui_HostnameLabel; +extern lv_obj_t *ui_RssiLabel; +extern lv_obj_t *ui_FwVersionLabel; +extern lv_obj_t *ui_BuildDateLabel; +extern lv_obj_t *ui_CopyrightLabel; +void ui_event_ShowQR( lv_event_t * e); +extern lv_obj_t *ui_ShowQR; +extern lv_obj_t *ui_ShowQRLabel; +void ui_event_HomeBtn( lv_event_t * e); +extern lv_obj_t *ui_HomeBtn; +extern lv_obj_t *ui_HomeLabel; // SCREEN: ui_Setup void ui_Setup_screen_init(void); -void ui_event_Setup(lv_event_t * e); -extern lv_obj_t * ui_Setup; -extern lv_obj_t * ui_TempUnitsLabel; -extern lv_obj_t * ui_FahrenheitLabel; -extern lv_obj_t * ui_TempUnitsSwitch; -extern lv_obj_t * ui_CelciusLabel; -extern lv_obj_t * ui_TempCorrectionTextLabel; -extern lv_obj_t * ui_TempCorrectionLabel; -void ui_event_TempCorrectionSlider(lv_event_t * e); -extern lv_obj_t * ui_TempCorrectionSlider; -extern lv_obj_t * ui_TempSwingTextLabel; -extern lv_obj_t * ui_TempSwingLabel; -void ui_event_TempSwingSlider(lv_event_t * e); -extern lv_obj_t * ui_TempSwingSlider; -extern lv_obj_t * ui_HvacCoolLabel; -extern lv_obj_t * ui_HvacCoolCheckbox; -extern lv_obj_t * ui_HvacFanLabel; -extern lv_obj_t * ui_HvacFanCheckbox; -void ui_event_SetupUncommonBtn(lv_event_t * e); -extern lv_obj_t * ui_SetupUncommonBtn; -extern lv_obj_t * ui_SetupUncommonLabel; -void ui_event_SetupHomeBtn(lv_event_t * e); -extern lv_obj_t * ui_SetupHomeBtn; -extern lv_obj_t * ui_SetupHomeLabel; -extern lv_obj_t * ui_MatterLabel; -extern lv_obj_t * ui_MatterCheckbox; +void ui_event_Setup( lv_event_t * e); +extern lv_obj_t *ui_Setup; +extern lv_obj_t *ui_TempUnitsLabel; +extern lv_obj_t *ui_FahrenheitLabel; +extern lv_obj_t *ui_TempUnitsSwitch; +extern lv_obj_t *ui_CelciusLabel; +extern lv_obj_t *ui_TempCorrectionTextLabel; +extern lv_obj_t *ui_TempCorrectionLabel; +void ui_event_TempCorrectionSlider( lv_event_t * e); +extern lv_obj_t *ui_TempCorrectionSlider; +extern lv_obj_t *ui_TempSwingTextLabel; +extern lv_obj_t *ui_TempSwingLabel; +void ui_event_TempSwingSlider( lv_event_t * e); +extern lv_obj_t *ui_TempSwingSlider; +extern lv_obj_t *ui_HvacCoolLabel; +extern lv_obj_t *ui_HvacCoolCheckbox; +extern lv_obj_t *ui_HvacFanLabel; +extern lv_obj_t *ui_HvacFanCheckbox; +void ui_event_SetupMqttBtn( lv_event_t * e); +extern lv_obj_t *ui_SetupMqttBtn; +extern lv_obj_t *ui_SetupMqttLabel; +void ui_event_SetupUncommonBtn( lv_event_t * e); +extern lv_obj_t *ui_SetupUncommonBtn; +extern lv_obj_t *ui_SetupUncommonLabel; +void ui_event_SetupHomeBtn( lv_event_t * e); +extern lv_obj_t *ui_SetupHomeBtn; +extern lv_obj_t *ui_SetupHomeLabel; +extern lv_obj_t *ui_HomeAutomationLabel; +extern lv_obj_t *ui_HomeAutomationCheckbox; // SCREEN: ui_LessCommonSetup void ui_LessCommonSetup_screen_init(void); -void ui_event_LessCommonSetup(lv_event_t * e); -extern lv_obj_t * ui_LessCommonSetup; -void ui_event_CalibrateBtn(lv_event_t * e); -extern lv_obj_t * ui_CalibrateBtn; -extern lv_obj_t * ui_CalibrateLabel; -extern lv_obj_t * ui_TimezoneLabel1; -extern lv_obj_t * ui_TimezoneDropdown; -extern lv_obj_t * ui_UiSleepTextLabel; -extern lv_obj_t * ui_UiSleepLabel; -void ui_event_UiSleepSlider(lv_event_t * e); -extern lv_obj_t * ui_UiSleepSlider; -extern lv_obj_t * ui_DualStageHeatLabel; -extern lv_obj_t * ui_Hvac2StageHeatCheckbox; -extern lv_obj_t * ui_DisableLabel1; -extern lv_obj_t * ui_RevValveCheckbox; -extern lv_obj_t * ui_DisableBeepLabel; -extern lv_obj_t * ui_AudibleBeepCheckbox; -void ui_event_SetupWifiBtn(lv_event_t * e); -extern lv_obj_t * ui_SetupWifiBtn; -extern lv_obj_t * ui_SetupWifiLabel; -void ui_event_SetupHomeBtn2(lv_event_t * e); -extern lv_obj_t * ui_SetupHomeBtn2; -extern lv_obj_t * ui_SetupHomeLabel2; +void ui_event_LessCommonSetup( lv_event_t * e); +extern lv_obj_t *ui_LessCommonSetup; +void ui_event_CalibrateBtn( lv_event_t * e); +extern lv_obj_t *ui_CalibrateBtn; +extern lv_obj_t *ui_CalibrateLabel; +extern lv_obj_t *ui_TimezoneLabel1; +extern lv_obj_t *ui_TimezoneDropdown; +extern lv_obj_t *ui_UiSleepTextLabel; +extern lv_obj_t *ui_UiSleepLabel; +void ui_event_UiSleepSlider( lv_event_t * e); +extern lv_obj_t *ui_UiSleepSlider; +extern lv_obj_t *ui_DualStageHeatLabel; +extern lv_obj_t *ui_Hvac2StageHeatCheckbox; +extern lv_obj_t *ui_DisableLabel1; +extern lv_obj_t *ui_RevValveCheckbox; +extern lv_obj_t *ui_DisableBeepLabel; +extern lv_obj_t *ui_AudibleBeepCheckbox; +void ui_event_SetupWifiBtn( lv_event_t * e); +extern lv_obj_t *ui_SetupWifiBtn; +extern lv_obj_t *ui_SetupWifiLabel; +void ui_event_SetupHomeBtn2( lv_event_t * e); +extern lv_obj_t *ui_SetupHomeBtn2; +extern lv_obj_t *ui_SetupHomeLabel2; // SCREEN: ui_WifiConfig void ui_WifiConfig_screen_init(void); -extern lv_obj_t * ui_WifiConfig; -extern lv_obj_t * ui_Keyboard; -extern lv_obj_t * ui_PSK; -extern lv_obj_t * ui_PwdLabel; -void ui_event_SsidDropdown(lv_event_t * e); -extern lv_obj_t * ui_SsidDropdown; -void ui_event_ScanBtn(lv_event_t * e); -extern lv_obj_t * ui_ScanBtn; -extern lv_obj_t * ui_ScanLabel; -void ui_event_SaveBtn(lv_event_t * e); -extern lv_obj_t * ui_SaveBtn; -extern lv_obj_t * ui_SaveLabel; -void ui_event_CancelBtn(lv_event_t * e); -extern lv_obj_t * ui_CancelBtn; -extern lv_obj_t * ui_CancelLabel; -void ui_event_WifiStatusLabel(lv_event_t * e); -extern lv_obj_t * ui_WifiStatusLabel; +extern lv_obj_t *ui_WifiConfig; +extern lv_obj_t *ui_Keyboard; +extern lv_obj_t *ui_PSK; +extern lv_obj_t *ui_PwdLabel; +void ui_event_SsidDropdown( lv_event_t * e); +extern lv_obj_t *ui_SsidDropdown; +void ui_event_ScanBtn( lv_event_t * e); +extern lv_obj_t *ui_ScanBtn; +extern lv_obj_t *ui_ScanLabel; +void ui_event_SaveBtn( lv_event_t * e); +extern lv_obj_t *ui_SaveBtn; +extern lv_obj_t *ui_SaveLabel; +void ui_event_CancelBtn( lv_event_t * e); +extern lv_obj_t *ui_CancelBtn; +extern lv_obj_t *ui_CancelLabel; +void ui_event_WifiStatusLabel( lv_event_t * e); +extern lv_obj_t *ui_WifiStatusLabel; // SCREEN: ui_MatterConfig void ui_MatterConfig_screen_init(void); -void ui_event_MatterConfig(lv_event_t * e); -extern lv_obj_t * ui_MatterConfig; -void ui_event_QrHomeBtn(lv_event_t * e); -extern lv_obj_t * ui_QrHomeBtn; -extern lv_obj_t * ui_SetupHomeLabel1; -extern lv_obj_t * ui_QRImage; -extern lv_obj_t * ui_ManualPairingCode; +void ui_event_MatterConfig( lv_event_t * e); +extern lv_obj_t *ui_MatterConfig; +void ui_event_QrHomeBtn( lv_event_t * e); +extern lv_obj_t *ui_QrHomeBtn; +extern lv_obj_t *ui_SetupHomeLabel1; +extern lv_obj_t *ui_QRImage; +extern lv_obj_t *ui_ManualPairingCode; // SCREEN: ui_ThermostatRestart void ui_ThermostatRestart_screen_init(void); -void ui_event_ThermostatRestart(lv_event_t * e); -extern lv_obj_t * ui_ThermostatRestart; -extern lv_obj_t * ui_Notification; -extern lv_obj_t * ui_RestartCountdown; -extern lv_obj_t * ui____initial_actions0; +void ui_event_ThermostatRestart( lv_event_t * e); +extern lv_obj_t *ui_ThermostatRestart; +extern lv_obj_t *ui_Notification; +extern lv_obj_t *ui_RestartCountdown; +// SCREEN: ui_MqttConfig +void ui_MqttConfig_screen_init(void); +extern lv_obj_t *ui_MqttConfig; +extern lv_obj_t *ui_MqttKeyboard; +void ui_event_MqttHostname( lv_event_t * e); +extern lv_obj_t *ui_MqttHostname; +void ui_event_MqttUsername( lv_event_t * e); +extern lv_obj_t *ui_MqttUsername; +void ui_event_MqttPassword( lv_event_t * e); +extern lv_obj_t *ui_MqttPassword; +extern lv_obj_t *ui_MqttPwdLabel; +void ui_event_MqttSaveBtn( lv_event_t * e); +extern lv_obj_t *ui_MqttSaveBtn; +extern lv_obj_t *ui_MqttSaveLabel; +void ui_event_MqttCancelBtn( lv_event_t * e); +extern lv_obj_t *ui_MqttCancelBtn; +extern lv_obj_t *ui_MqttCancelLabel; +extern lv_obj_t *ui____initial_actions0; + + + void ui_init(void); diff --git a/app/src/ui/ui_events.cpp b/app/src/ui/ui_events.cpp index a455f07..702167f 100644 --- a/app/src/ui/ui_events.cpp +++ b/app/src/ui/ui_events.cpp @@ -66,7 +66,7 @@ void tftHvacModeChange(lv_event_t * e) // OperatingParameters.hvacSetMode = getHvacMode(); char mode[12]; lv_dropdown_get_selected_str(ui_ModeDropdown, mode, sizeof(mode)); - OperatingParameters.hvacSetMode = strToHvacMode(mode); + updateHvacMode(strToHvacMode(mode)); switch (OperatingParameters.hvacSetMode) { @@ -287,7 +287,7 @@ void SaveConfigSettings(lv_event_t * e) #ifdef MATTER_ENABLED bool prevMatter = OperatingParameters.MatterEnabled; - OperatingParameters.MatterEnabled = lv_obj_has_state(ui_MatterCheckbox, LV_STATE_CHECKED); + OperatingParameters.MatterEnabled = lv_obj_has_state(ui_HomeAutomationCheckbox, LV_STATE_CHECKED); if (OperatingParameters.MatterEnabled != prevMatter) { //@@@ Disable all HVAC activity before restarting @@ -300,6 +300,20 @@ void SaveConfigSettings(lv_event_t * e) } } #endif +#ifdef MQTT_ENABLED + bool prevMqtt = OperatingParameters.MqttEnabled; + OperatingParameters.MqttEnabled = lv_obj_has_state(ui_HomeAutomationCheckbox, LV_STATE_CHECKED); + if (OperatingParameters.MqttEnabled != prevMqtt) + { + //@@@ Disable all HVAC activity before restarting + printf ("MQTT enablement changed!\n"); +//@@@ wifiSwitchMatterMode(); + if (!OperatingParameters.MqttEnabled) + { + _ui_screen_change(&ui_ThermostatRestart, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_ThermostatRestart_screen_init); + } + } +#endif } void LoadConfigSettings(lv_event_t * e) @@ -322,9 +336,26 @@ void LoadConfigSettings(lv_event_t * e) lv_obj_clear_state(ui_HvacFanCheckbox, LV_STATE_CHECKED); #ifdef MATTER_ENABLED if (OperatingParameters.MatterEnabled) - lv_obj_add_state(ui_MatterCheckbox, LV_STATE_CHECKED); + lv_obj_add_state(ui_HomeAutomationCheckbox, LV_STATE_CHECKED); else - lv_obj_clear_state(ui_MatterCheckbox, LV_STATE_CHECKED); + lv_obj_clear_state(ui_HomeAutomationCheckbox, LV_STATE_CHECKED); + + lv_obj_add_flag(ui_SetupMqttBtn, LV_OBJ_FLAG_HIDDEN); + lv_obj_add_flag(ui_SetupMqttLabel, LV_OBJ_FLAG_HIDDEN); +#endif +#ifdef MQTT_ENABLED + if (OperatingParameters.MqttEnabled) + { + lv_obj_add_state(ui_HomeAutomationCheckbox, LV_STATE_CHECKED); + lv_obj_clear_flag(ui_SetupMqttBtn, LV_OBJ_FLAG_HIDDEN); + lv_obj_clear_flag(ui_SetupMqttLabel, LV_OBJ_FLAG_HIDDEN); + } + else + { + lv_obj_clear_state(ui_HomeAutomationCheckbox, LV_STATE_CHECKED); + lv_obj_add_flag(ui_SetupMqttBtn, LV_OBJ_FLAG_HIDDEN); + lv_obj_add_flag(ui_SetupMqttLabel, LV_OBJ_FLAG_HIDDEN); + } #endif } @@ -379,12 +410,14 @@ bool isCurrentScreenMain() } #ifdef MATTER_ENABLED +#endif /** * Create a QR Code */ void lv_example_qrcode_1() { +#ifdef MATTER_ENABLED lv_color_t bg_color = lv_palette_lighten(LV_PALETTE_LIGHT_BLUE, 5); lv_color_t fg_color = lv_palette_darken(LV_PALETTE_BLUE, 4); @@ -404,16 +437,18 @@ void lv_example_qrcode_1() /*Add a border with bg_color*/ lv_obj_set_style_border_color(qr, bg_color, 0); lv_obj_set_style_border_width(qr, 5, 0); +#endif } void ShowQrOnScreen(lv_event_t * e) { +#ifdef MATTER_ENABLED printf ("Loading QR and manual pairing codes\n"); lv_example_qrcode_1(); lv_label_set_text(ui_ManualPairingCode, OperatingParameters.MatterPairingCode); +#endif } -#endif void tftCountdown(lv_event_t * e) { @@ -444,6 +479,33 @@ void tftCountdown(lv_event_t * e) setWifiCreds(); printf ("Saving thermostat config\n"); updateThermostatParams(); - // printf ("Resetting Matter config and restarting ESP\n"); - // MatterFactoryReset(); // Will also restart the ESP +#ifdef MATTER_ENABLED + printf ("Resetting Matter config and restarting ESP\n"); + MatterFactoryReset(); // Will also restart the ESP +#endif +} + +void loadMqttSettings(lv_event_t * e) +{ + lv_textarea_set_text(ui_MqttHostname, OperatingParameters.MqttBrokerHost); + lv_textarea_set_text(ui_MqttUsername, OperatingParameters.MqttBrokerUsername); + lv_textarea_set_text(ui_MqttPassword, OperatingParameters.MqttBrokerPassword); + + printf ("On load:\n"); + printf (" MQTT Broker: %s\n", OperatingParameters.MqttBrokerHost); + printf (" MQTT Username: %s\n", OperatingParameters.MqttBrokerUsername); + printf (" MQTT Password: %s\n", OperatingParameters.MqttBrokerPassword); + +} + +void saveMqttSettings(lv_event_t * e) +{ + strcpy (OperatingParameters.MqttBrokerHost, lv_textarea_get_text(ui_MqttHostname)); + strcpy (OperatingParameters.MqttBrokerUsername, lv_textarea_get_text(ui_MqttUsername)); + strcpy (OperatingParameters.MqttBrokerPassword, lv_textarea_get_text(ui_MqttPassword)); + + printf ("On save:\n"); + printf (" MQTT Broker: %s\n", OperatingParameters.MqttBrokerHost); + printf (" MQTT Username: %s\n", OperatingParameters.MqttBrokerUsername); + printf (" MQTT Password: %s\n", OperatingParameters.MqttBrokerPassword); } diff --git a/app/src/ui/ui_events.h b/app/src/ui/ui_events.h index f339394..f5ba504 100644 --- a/app/src/ui/ui_events.h +++ b/app/src/ui/ui_events.h @@ -1,5 +1,5 @@ // This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.3.1 +// SquareLine Studio version: SquareLine Studio 1.3.2 // LVGL version: 8.3.6 // Project name: Thermostat @@ -21,6 +21,7 @@ void LoadInfoStrings(lv_event_t * e); void LoadConfigSettings(lv_event_t * e); void tftUpdateTempCorrectionValue(lv_event_t * e); void tftUpdateTempSwingValue(lv_event_t * e); +void loadMqttSettings(lv_event_t * e); void LoadUncommonSettings(lv_event_t * e); void SaveConfigSettings(lv_event_t * e); void tftCalibrate(lv_event_t * e); @@ -32,6 +33,7 @@ void tftSetNewWifi(lv_event_t * e); void stopWifiScan(lv_event_t * e); void ShowQrOnScreen(lv_event_t * e); void tftCountdown(lv_event_t * e); +void saveMqttSettings(lv_event_t * e); #ifdef __cplusplus } /*extern "C"*/ diff --git a/app/src/ui/ui_helpers.c b/app/src/ui/ui_helpers.c index 258601c..e71529b 100644 --- a/app/src/ui/ui_helpers.c +++ b/app/src/ui/ui_helpers.c @@ -1,251 +1,254 @@ // This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.3.1 +// SquareLine Studio version: SquareLine Studio 1.3.2 // LVGL version: 8.3.6 // Project name: Thermostat #include "ui_helpers.h" -void _ui_bar_set_property(lv_obj_t * target, int id, int val) +void _ui_bar_set_property( lv_obj_t *target, int id, int val) { - if(id == _UI_BAR_PROPERTY_VALUE_WITH_ANIM) lv_bar_set_value(target, val, LV_ANIM_ON); - if(id == _UI_BAR_PROPERTY_VALUE) lv_bar_set_value(target, val, LV_ANIM_OFF); + if (id == _UI_BAR_PROPERTY_VALUE_WITH_ANIM) lv_bar_set_value(target, val, LV_ANIM_ON); + if (id == _UI_BAR_PROPERTY_VALUE) lv_bar_set_value(target, val, LV_ANIM_OFF); } -void _ui_basic_set_property(lv_obj_t * target, int id, int val) +void _ui_basic_set_property( lv_obj_t *target, int id, int val) { - if(id == _UI_BASIC_PROPERTY_POSITION_X) lv_obj_set_x(target, val); - if(id == _UI_BASIC_PROPERTY_POSITION_Y) lv_obj_set_y(target, val); - if(id == _UI_BASIC_PROPERTY_WIDTH) lv_obj_set_width(target, val); - if(id == _UI_BASIC_PROPERTY_HEIGHT) lv_obj_set_height(target, val); + if (id == _UI_BASIC_PROPERTY_POSITION_X) lv_obj_set_x(target, val); + if (id == _UI_BASIC_PROPERTY_POSITION_Y) lv_obj_set_y(target, val); + if (id == _UI_BASIC_PROPERTY_WIDTH) lv_obj_set_width(target, val); + if (id == _UI_BASIC_PROPERTY_HEIGHT) lv_obj_set_height(target, val); } -void _ui_dropdown_set_property(lv_obj_t * target, int id, int val) +void _ui_dropdown_set_property( lv_obj_t *target, int id, int val) { - if(id == _UI_DROPDOWN_PROPERTY_SELECTED) lv_dropdown_set_selected(target, val); + if (id == _UI_DROPDOWN_PROPERTY_SELECTED) lv_dropdown_set_selected(target, val); } -void _ui_image_set_property(lv_obj_t * target, int id, uint8_t * val) +void _ui_image_set_property( lv_obj_t *target, int id, uint8_t *val) { - if(id == _UI_IMAGE_PROPERTY_IMAGE) lv_img_set_src(target, val); + if (id == _UI_IMAGE_PROPERTY_IMAGE) lv_img_set_src(target, val); } -void _ui_label_set_property(lv_obj_t * target, int id, const char * val) +void _ui_label_set_property( lv_obj_t *target, int id, const char *val) { - if(id == _UI_LABEL_PROPERTY_TEXT) lv_label_set_text(target, val); + if (id == _UI_LABEL_PROPERTY_TEXT) lv_label_set_text(target, val); } -void _ui_roller_set_property(lv_obj_t * target, int id, int val) +void _ui_roller_set_property( lv_obj_t *target, int id, int val) { - if(id == _UI_ROLLER_PROPERTY_SELECTED_WITH_ANIM) lv_roller_set_selected(target, val, LV_ANIM_ON); - if(id == _UI_ROLLER_PROPERTY_SELECTED) lv_roller_set_selected(target, val, LV_ANIM_OFF); + if (id == _UI_ROLLER_PROPERTY_SELECTED_WITH_ANIM) lv_roller_set_selected(target, val, LV_ANIM_ON); + if (id == _UI_ROLLER_PROPERTY_SELECTED) lv_roller_set_selected(target, val, LV_ANIM_OFF); } -void _ui_slider_set_property(lv_obj_t * target, int id, int val) +void _ui_slider_set_property( lv_obj_t *target, int id, int val) { - if(id == _UI_SLIDER_PROPERTY_VALUE_WITH_ANIM) lv_slider_set_value(target, val, LV_ANIM_ON); - if(id == _UI_SLIDER_PROPERTY_VALUE) lv_slider_set_value(target, val, LV_ANIM_OFF); + if (id == _UI_SLIDER_PROPERTY_VALUE_WITH_ANIM) lv_slider_set_value(target, val, LV_ANIM_ON); + if (id == _UI_SLIDER_PROPERTY_VALUE) lv_slider_set_value(target, val, LV_ANIM_OFF); } -void _ui_screen_change(lv_obj_t ** target, lv_scr_load_anim_t fademode, int spd, int delay, void (*target_init)(void)) +void _ui_screen_change( lv_obj_t ** target, lv_scr_load_anim_t fademode, int spd, int delay, void (*target_init)(void)) { - if(*target == NULL) - target_init(); - lv_scr_load_anim(*target, fademode, spd, delay, false); + if(*target == NULL) + target_init(); + lv_scr_load_anim(*target, fademode, spd, delay, false); } -void _ui_screen_delete(lv_obj_t ** target) +void _ui_screen_delete( lv_obj_t ** target ) { - if(*target == NULL) { - lv_obj_del(*target); - target = NULL; - } + if(*target == NULL) + { + lv_obj_del(*target); + target = NULL; + } } -void _ui_arc_increment(lv_obj_t * target, int val) +void _ui_arc_increment( lv_obj_t *target, int val) { - int old = lv_arc_get_value(target); - lv_arc_set_value(target, old + val); - lv_event_send(target, LV_EVENT_VALUE_CHANGED, 0); + int old = lv_arc_get_value(target); + lv_arc_set_value(target, old+val); + lv_event_send(target,LV_EVENT_VALUE_CHANGED, 0); } -void _ui_bar_increment(lv_obj_t * target, int val, int anm) +void _ui_bar_increment( lv_obj_t *target, int val, int anm) { - int old = lv_bar_get_value(target); - lv_bar_set_value(target, old + val, anm); + int old = lv_bar_get_value(target); + lv_bar_set_value(target, old+val, anm); } -void _ui_slider_increment(lv_obj_t * target, int val, int anm) +void _ui_slider_increment( lv_obj_t *target, int val, int anm) { - int old = lv_slider_get_value(target); - lv_slider_set_value(target, old + val, anm); - lv_event_send(target, LV_EVENT_VALUE_CHANGED, 0); + int old = lv_slider_get_value(target); + lv_slider_set_value(target, old+val, anm); + lv_event_send(target,LV_EVENT_VALUE_CHANGED, 0); } -void _ui_keyboard_set_target(lv_obj_t * keyboard, lv_obj_t * textarea) +void _ui_keyboard_set_target( lv_obj_t *keyboard, lv_obj_t *textarea) { - lv_keyboard_set_textarea(keyboard, textarea); + lv_keyboard_set_textarea(keyboard, textarea); } -void _ui_flag_modify(lv_obj_t * target, int32_t flag, int value) +void _ui_flag_modify( lv_obj_t *target, int32_t flag, int value) { - if(value == _UI_MODIFY_FLAG_TOGGLE) { - if(lv_obj_has_flag(target, flag)) lv_obj_clear_flag(target, flag); - else lv_obj_add_flag(target, flag); + if (value==_UI_MODIFY_FLAG_TOGGLE) + { + if ( lv_obj_has_flag(target,flag) ) lv_obj_clear_flag(target,flag); + else lv_obj_add_flag(target,flag); } - else if(value == _UI_MODIFY_FLAG_ADD) lv_obj_add_flag(target, flag); - else lv_obj_clear_flag(target, flag); + else if (value==_UI_MODIFY_FLAG_ADD) lv_obj_add_flag(target,flag); + else lv_obj_clear_flag(target,flag); } -void _ui_state_modify(lv_obj_t * target, int32_t state, int value) +void _ui_state_modify( lv_obj_t *target, int32_t state, int value) { - if(value == _UI_MODIFY_STATE_TOGGLE) { - if(lv_obj_has_state(target, state)) lv_obj_clear_state(target, state); - else lv_obj_add_state(target, state); + if (value==_UI_MODIFY_STATE_TOGGLE) + { + if ( lv_obj_has_state(target,state) ) lv_obj_clear_state(target,state); + else lv_obj_add_state(target,state); } - else if(value == _UI_MODIFY_STATE_ADD) lv_obj_add_state(target, state); - else lv_obj_clear_state(target, state); + else if (value==_UI_MODIFY_STATE_ADD) lv_obj_add_state(target,state); + else lv_obj_clear_state(target,state); } -void scr_unloaded_delete_cb(lv_event_t * e) -{ - lv_obj_t ** var = lv_event_get_user_data(e); - lv_obj_del(*var); - (*var) = NULL; +void scr_unloaded_delete_cb(lv_event_t * e) +{ + lv_obj_t ** var = lv_event_get_user_data(e); + lv_obj_del(*var); + (*var) = NULL; } -void _ui_opacity_set(lv_obj_t * target, int val) +void _ui_opacity_set( lv_obj_t *target, int val) { - lv_obj_set_style_opa(target, val, 0); + lv_obj_set_style_opa(target, val, 0); } -void _ui_anim_callback_free_user_data(lv_anim_t * a) +void _ui_anim_callback_free_user_data(lv_anim_t *a) { - lv_mem_free(a->user_data); - a->user_data = NULL; + lv_mem_free(a->user_data); + a->user_data=NULL; } -void _ui_anim_callback_set_x(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - lv_obj_set_x(usr->target, v); -} +void _ui_anim_callback_set_x(lv_anim_t* a, int32_t v) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + lv_obj_set_x(usr->target, v); +} -void _ui_anim_callback_set_y(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - lv_obj_set_y(usr->target, v); -} +void _ui_anim_callback_set_y(lv_anim_t* a, int32_t v) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + lv_obj_set_y(usr->target, v); +} -void _ui_anim_callback_set_width(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - lv_obj_set_width(usr->target, v); -} +void _ui_anim_callback_set_width(lv_anim_t* a, int32_t v) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + lv_obj_set_width(usr->target, v); +} -void _ui_anim_callback_set_height(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - lv_obj_set_height(usr->target, v); -} +void _ui_anim_callback_set_height(lv_anim_t* a, int32_t v) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + lv_obj_set_height(usr->target, v); +} -void _ui_anim_callback_set_opacity(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - lv_obj_set_style_opa(usr->target, v, 0); -} +void _ui_anim_callback_set_opacity(lv_anim_t* a, int32_t v) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + lv_obj_set_style_opa(usr->target, v, 0); +} -void _ui_anim_callback_set_image_zoom(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - lv_img_set_zoom(usr->target, v); -} +void _ui_anim_callback_set_image_zoom(lv_anim_t* a, int32_t v) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + lv_img_set_zoom(usr->target, v); +} -void _ui_anim_callback_set_image_angle(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - lv_img_set_angle(usr->target, v); -} +void _ui_anim_callback_set_image_angle(lv_anim_t* a, int32_t v) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + lv_img_set_angle(usr->target, v); +} -void _ui_anim_callback_set_image_frame(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - usr->val = v; - if(v < 0) v = 0; - if(v >= usr->imgset_size) v = usr->imgset_size - 1; +void _ui_anim_callback_set_image_frame(lv_anim_t* a, int32_t v) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + usr->val = v; + if ( v<0 ) v=0; + if ( v>=usr->imgset_size ) v=usr->imgset_size-1; lv_img_set_src(usr->target, usr->imgset[v]); } -int32_t _ui_anim_callback_get_x(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return lv_obj_get_x_aligned(usr->target); -} +int32_t _ui_anim_callback_get_x(lv_anim_t* a) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + return lv_obj_get_x_aligned(usr->target); +} -int32_t _ui_anim_callback_get_y(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return lv_obj_get_y_aligned(usr->target); -} +int32_t _ui_anim_callback_get_y(lv_anim_t* a) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + return lv_obj_get_y_aligned(usr->target); +} -int32_t _ui_anim_callback_get_width(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return lv_obj_get_width(usr->target); -} +int32_t _ui_anim_callback_get_width(lv_anim_t* a) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + return lv_obj_get_width(usr->target); +} -int32_t _ui_anim_callback_get_height(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return lv_obj_get_height(usr->target); -} +int32_t _ui_anim_callback_get_height(lv_anim_t* a) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + return lv_obj_get_height(usr->target); +} -int32_t _ui_anim_callback_get_opacity(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return lv_obj_get_style_opa(usr->target, 0); +int32_t _ui_anim_callback_get_opacity(lv_anim_t* a) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + return lv_obj_get_style_opa(usr->target, 0); } -int32_t _ui_anim_callback_get_image_zoom(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return lv_img_get_zoom(usr->target); +int32_t _ui_anim_callback_get_image_zoom(lv_anim_t* a) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + return lv_img_get_zoom(usr->target); } -int32_t _ui_anim_callback_get_image_angle(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return lv_img_get_angle(usr->target); +int32_t _ui_anim_callback_get_image_angle(lv_anim_t* a) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + return lv_img_get_angle(usr->target); } -int32_t _ui_anim_callback_get_image_frame(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return usr->val; +int32_t _ui_anim_callback_get_image_frame(lv_anim_t* a) +{ + ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; + return usr->val; } -void _ui_arc_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * prefix, const char * postfix) +void _ui_arc_set_text_value( lv_obj_t *trg, lv_obj_t *src, const char *prefix, const char *postfix) { - char buf[_UI_TEMPORARY_STRING_BUFFER_SIZE]; - lv_snprintf(buf, sizeof(buf), "%s%d%s", prefix, (int)lv_arc_get_value(src), postfix); - lv_label_set_text(trg, buf); + char buf[_UI_TEMPORARY_STRING_BUFFER_SIZE]; + lv_snprintf(buf, sizeof(buf), "%s%d%s", prefix, (int)lv_arc_get_value(src), postfix); + lv_label_set_text(trg, buf); } -void _ui_slider_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * prefix, const char * postfix) +void _ui_slider_set_text_value( lv_obj_t *trg, lv_obj_t *src, const char *prefix, const char *postfix) { - char buf[_UI_TEMPORARY_STRING_BUFFER_SIZE]; - lv_snprintf(buf, sizeof(buf), "%s%d%s", prefix, (int)lv_slider_get_value(src), postfix); - lv_label_set_text(trg, buf); + char buf[_UI_TEMPORARY_STRING_BUFFER_SIZE]; + lv_snprintf(buf, sizeof(buf), "%s%d%s", prefix, (int)lv_slider_get_value(src), postfix); + lv_label_set_text(trg, buf); } -void _ui_checked_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * txt_on, const char * txt_off) +void _ui_checked_set_text_value( lv_obj_t *trg, lv_obj_t *src, const char *txt_on, const char *txt_off) { - if(lv_obj_has_state(src, LV_STATE_CHECKED)) lv_label_set_text(trg, txt_on); - else lv_label_set_text(trg, txt_off); + if (lv_obj_has_state(src,LV_STATE_CHECKED)) lv_label_set_text(trg,txt_on); + else lv_label_set_text(trg,txt_off); } -void _ui_spinbox_step(lv_obj_t * target, int val) -{ - if(val > 0) lv_spinbox_increment(target); - else lv_spinbox_decrement(target); +void _ui_spinbox_step(lv_obj_t * target, int val) +{ + if(val > 0) lv_spinbox_increment(target); + else lv_spinbox_decrement(target); - lv_event_send(target, LV_EVENT_VALUE_CHANGED, 0); + lv_event_send(target,LV_EVENT_VALUE_CHANGED, 0); } diff --git a/app/src/ui/ui_helpers.h b/app/src/ui/ui_helpers.h index 33d78f9..9fd21f3 100644 --- a/app/src/ui/ui_helpers.h +++ b/app/src/ui/ui_helpers.h @@ -1,5 +1,5 @@ // This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.3.1 +// SquareLine Studio version: SquareLine Studio 1.3.2 // LVGL version: 8.3.6 // Project name: Thermostat @@ -15,106 +15,105 @@ extern "C" { #define _UI_TEMPORARY_STRING_BUFFER_SIZE 32 #define _UI_BAR_PROPERTY_VALUE 0 #define _UI_BAR_PROPERTY_VALUE_WITH_ANIM 1 -void _ui_bar_set_property(lv_obj_t * target, int id, int val); +void _ui_bar_set_property( lv_obj_t *target, int id, int val); #define _UI_BASIC_PROPERTY_POSITION_X 0 #define _UI_BASIC_PROPERTY_POSITION_Y 1 #define _UI_BASIC_PROPERTY_WIDTH 2 #define _UI_BASIC_PROPERTY_HEIGHT 3 -void _ui_basic_set_property(lv_obj_t * target, int id, int val); +void _ui_basic_set_property( lv_obj_t *target, int id, int val); #define _UI_DROPDOWN_PROPERTY_SELECTED 0 -void _ui_dropdown_set_property(lv_obj_t * target, int id, int val); +void _ui_dropdown_set_property( lv_obj_t *target, int id, int val); #define _UI_IMAGE_PROPERTY_IMAGE 0 -void _ui_image_set_property(lv_obj_t * target, int id, uint8_t * val); +void _ui_image_set_property( lv_obj_t *target, int id, uint8_t *val); #define _UI_LABEL_PROPERTY_TEXT 0 -void _ui_label_set_property(lv_obj_t * target, int id, const char * val); +void _ui_label_set_property( lv_obj_t *target, int id, const char *val); #define _UI_ROLLER_PROPERTY_SELECTED 0 #define _UI_ROLLER_PROPERTY_SELECTED_WITH_ANIM 1 -void _ui_roller_set_property(lv_obj_t * target, int id, int val); +void _ui_roller_set_property( lv_obj_t *target, int id, int val); #define _UI_SLIDER_PROPERTY_VALUE 0 #define _UI_SLIDER_PROPERTY_VALUE_WITH_ANIM 1 -void _ui_slider_set_property(lv_obj_t * target, int id, int val); +void _ui_slider_set_property( lv_obj_t *target, int id, int val); -void _ui_screen_change(lv_obj_t ** target, lv_scr_load_anim_t fademode, int spd, int delay, void (*target_init)(void)); +void _ui_screen_change( lv_obj_t ** target, lv_scr_load_anim_t fademode, int spd, int delay, void (*target_init)(void)); -void _ui_screen_delete(lv_obj_t ** target); +void _ui_screen_delete( lv_obj_t ** target ); -void _ui_arc_increment(lv_obj_t * target, int val); +void _ui_arc_increment( lv_obj_t *target, int val); -void _ui_bar_increment(lv_obj_t * target, int val, int anm); +void _ui_bar_increment( lv_obj_t *target, int val, int anm); -void _ui_slider_increment(lv_obj_t * target, int val, int anm); +void _ui_slider_increment( lv_obj_t *target, int val, int anm); -void _ui_keyboard_set_target(lv_obj_t * keyboard, lv_obj_t * textarea); +void _ui_keyboard_set_target( lv_obj_t *keyboard, lv_obj_t *textarea); #define _UI_MODIFY_FLAG_ADD 0 #define _UI_MODIFY_FLAG_REMOVE 1 #define _UI_MODIFY_FLAG_TOGGLE 2 -void _ui_flag_modify(lv_obj_t * target, int32_t flag, int value); +void _ui_flag_modify( lv_obj_t *target, int32_t flag, int value); #define _UI_MODIFY_STATE_ADD 0 #define _UI_MODIFY_STATE_REMOVE 1 #define _UI_MODIFY_STATE_TOGGLE 2 -void _ui_state_modify(lv_obj_t * target, int32_t state, int value); +void _ui_state_modify( lv_obj_t *target, int32_t state, int value); void scr_unloaded_delete_cb(lv_event_t * e); -void _ui_opacity_set(lv_obj_t * target, int val); +void _ui_opacity_set( lv_obj_t *target, int val); /** Describes an animation*/ typedef struct _ui_anim_user_data_t { - lv_obj_t * target; - lv_img_dsc_t ** imgset; + lv_obj_t *target; + lv_img_dsc_t **imgset; int32_t imgset_size; int32_t val; } ui_anim_user_data_t; -void _ui_anim_callback_free_user_data(lv_anim_t * a); +void _ui_anim_callback_free_user_data(lv_anim_t *a); -void _ui_anim_callback_set_x(lv_anim_t * a, int32_t v); +void _ui_anim_callback_set_x(lv_anim_t* a, int32_t v); -void _ui_anim_callback_set_y(lv_anim_t * a, int32_t v); +void _ui_anim_callback_set_y(lv_anim_t* a, int32_t v); -void _ui_anim_callback_set_width(lv_anim_t * a, int32_t v); +void _ui_anim_callback_set_width(lv_anim_t* a, int32_t v); -void _ui_anim_callback_set_height(lv_anim_t * a, int32_t v); +void _ui_anim_callback_set_height(lv_anim_t* a, int32_t v); -void _ui_anim_callback_set_opacity(lv_anim_t * a, int32_t v); +void _ui_anim_callback_set_opacity(lv_anim_t* a, int32_t v); -void _ui_anim_callback_set_image_zoom(lv_anim_t * a, int32_t v); +void _ui_anim_callback_set_image_zoom(lv_anim_t* a, int32_t v); -void _ui_anim_callback_set_image_angle(lv_anim_t * a, int32_t v); +void _ui_anim_callback_set_image_angle(lv_anim_t* a, int32_t v); -void _ui_anim_callback_set_image_frame(lv_anim_t * a, int32_t v); +void _ui_anim_callback_set_image_frame(lv_anim_t* a, int32_t v); -int32_t _ui_anim_callback_get_x(lv_anim_t * a); +int32_t _ui_anim_callback_get_x(lv_anim_t* a); -int32_t _ui_anim_callback_get_y(lv_anim_t * a); +int32_t _ui_anim_callback_get_y(lv_anim_t* a); -int32_t _ui_anim_callback_get_width(lv_anim_t * a); +int32_t _ui_anim_callback_get_width(lv_anim_t* a); -int32_t _ui_anim_callback_get_height(lv_anim_t * a); +int32_t _ui_anim_callback_get_height(lv_anim_t* a); -int32_t _ui_anim_callback_get_opacity(lv_anim_t * a); +int32_t _ui_anim_callback_get_opacity(lv_anim_t* a); -int32_t _ui_anim_callback_get_image_zoom(lv_anim_t * a); +int32_t _ui_anim_callback_get_image_zoom(lv_anim_t* a); -int32_t _ui_anim_callback_get_image_angle(lv_anim_t * a); +int32_t _ui_anim_callback_get_image_angle(lv_anim_t* a); -int32_t _ui_anim_callback_get_image_frame(lv_anim_t * a); +int32_t _ui_anim_callback_get_image_frame(lv_anim_t* a); -void _ui_arc_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * prefix, const char * postfix); +void _ui_arc_set_text_value( lv_obj_t *trg, lv_obj_t *src, const char *prefix, const char *postfix); -void _ui_slider_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * prefix, const char * postfix); +void _ui_slider_set_text_value( lv_obj_t *trg, lv_obj_t *src, const char *prefix, const char *postfix); -void _ui_checked_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * txt_on, const char * txt_off); +void _ui_checked_set_text_value( lv_obj_t *trg, lv_obj_t *src, const char *txt_on, const char *txt_off); -void _ui_spinbox_step(lv_obj_t * target, int val) -; +void _ui_spinbox_step(lv_obj_t * target, int val) ; #ifdef __cplusplus } /*extern "C"*/ From 180add2dae92d60755da8fba4d04125eaf59d2b8 Mon Sep 17 00:00:00 2001 From: Steve Meisner Date: Wed, 4 Oct 2023 21:24:27 -0400 Subject: [PATCH 02/10] Add support for MQTT & Matter --- README.md | 6 + app/.gitignore | 2 + app/.unotes/unotes_meta.json | 10 +- app/include/thermostat.hpp | 28 +++ app/platformio.ini | 4 + app/src/main.cpp | 23 +- app/src/matter.cpp | 402 ++++++++++++++++++++++++++++++++ app/src/mqtt.cpp | 428 +++++++++++++++++++++++++++++++++++ app/src/sensors.cpp | 24 +- app/src/state_machine.cpp | 5 + app/src/tft.cpp | 8 +- app/src/web.cpp | 25 +- app/src/wifi.cpp | 178 +++++++++++---- 13 files changed, 1062 insertions(+), 81 deletions(-) create mode 100644 app/src/matter.cpp create mode 100644 app/src/mqtt.cpp diff --git a/README.md b/README.md index 9573178..565883d 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,12 @@ Basic layout of thermostat: +# October 4, 2023 addition of Matter support + +Getting started: https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html + +Matter support is delayed until the SDK can be added as a library to PlatformIO. Currently, the actions required to create a dev environment is too extreme. + # September 8, 2023 update - V0.6 The thermostat app code is now 100% ESP-IDF based. All dependencies on the Arduino framework have been removed. This provides for much better control of the code and better integration with the upcoming Matter implementation. diff --git a/app/.gitignore b/app/.gitignore index 89cc49c..e7a2c57 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -3,3 +3,5 @@ .vscode/c_cpp_properties.json .vscode/launch.json .vscode/ipch +lib +Matter \ No newline at end of file diff --git a/app/.unotes/unotes_meta.json b/app/.unotes/unotes_meta.json index 32c2fd2..f530073 100644 --- a/app/.unotes/unotes_meta.json +++ b/app/.unotes/unotes_meta.json @@ -51,12 +51,6 @@ }, "files": {} }, - "test": { - "name": "test", - "isOrdered": true, - "folders": {}, - "files": {} - }, "boards": { "name": "boards", "isOrdered": true, @@ -70,7 +64,5 @@ "files": {} } }, - "files": { - "GettingStarted": 0 - } + "files": {} } \ No newline at end of file diff --git a/app/include/thermostat.hpp b/app/include/thermostat.hpp index db5c722..5186133 100644 --- a/app/include/thermostat.hpp +++ b/app/include/thermostat.hpp @@ -37,6 +37,8 @@ typedef enum typedef struct { + char DeviceName[32]; + uint8_t mac[6]; HVAC_MODE hvacOpMode; HVAC_MODE hvacSetMode; float tempSet; @@ -62,6 +64,21 @@ typedef struct char *timezone; uint16_t timezone_sel; +#ifdef MQTT_ENABLED + bool MqttEnabled; + bool MqttStarted; + bool MqttConnected; + char *MqttBrokerHost; + uint16_t MqttBrokerPort; + char *MqttBrokerUsername; + char *MqttBrokerPassword; + void *MqttClient; +#endif + +#ifdef MATTER_ENABLED + bool MatterEnabled; + bool MatterStarted; +#endif //@@@ Zipcode for outside temp?? //@@@ Calibration data for touchscreen? @@ -121,6 +138,15 @@ int32_t millis(); // Defined in main.cpp void showConfigurationData(); void scanI2cBus(); +#ifdef MATTER_ENABLED +bool MatterInit(); +#endif + +#ifdef MQTT_ENABLED +void MqttInit(); +void MqttUpdateStatusTopic(); +#endif + // State Machine void stateCreateTask(); void serialStart(); @@ -176,6 +202,8 @@ void tftDimDisplay(); #endif // Sensors +void updateHvacMode(HVAC_MODE mode); +void updateHvacSetTemp(float setTemp); // float roundValue(float value, int places = 0); float roundValue(float value, int places); float getRoundedFrac(float value); diff --git a/app/platformio.ini b/app/platformio.ini index 4b3e205..d4f65be 100644 --- a/app/platformio.ini +++ b/app/platformio.ini @@ -30,7 +30,10 @@ build_unflags = build_flags = -std=gnu++14 -I include/ +;;; -I ~/.platformio/packages/framework-espidf/components/mqtt/esp-mqtt/include/ -D LV_CONF_INCLUDE_SIMPLE + -D MQTT_ENABLED +;; -D MATTER_ENABLED lib_compat_mode = off ;; To enable Arduino LD2410 library to be included lib_deps = rzeldent/micro-timezonedb@^1.0.2 @@ -38,6 +41,7 @@ lib_deps = lvgl/lvgl@^8.3.9 lovyan03/LovyanGFX@^1.1.9 ncmreynolds/ld2410@^0.1.3 + bblanchon/ArduinoJson@^6.21.3 debug_init_break = tbreak app_main monitor_filters = esp32_exception_decoder diff --git a/app/src/main.cpp b/app/src/main.cpp index 1877d42..a249d18 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -17,16 +17,20 @@ */ #include "thermostat.hpp" - #include "esp_timer.h" int32_t millis() { return esp_timer_get_time() / 1000;} void app_main() { + printf ("IDF version: %s\n", esp_get_idf_version()); + printf ("- Free memory: %d bytes\n", esp_get_free_heap_size()); + // Load configuration from EEPROM printf ("Reading EEPROM\n"); eepromInit(); + strcpy (OperatingParameters.DeviceName, "BasementTest"); + // Initialize the TFT display printf ("Initializing TFT\n"); tftInit(); @@ -34,10 +38,25 @@ void app_main() printf ("Starting TFT task\n"); tftCreateTask(); +#ifdef MATTER_ENABLED + // Start Matter + printf ("Starting Matter\n"); + OperatingParameters.MatterStarted = MatterInit(); +#endif + // Start wifi printf ("Starting wifi (\"%s\", \"%s\")\n", WifiCreds.ssid, WifiCreds.password); OperatingParameters.wifiConnected = - wifiStart(WifiCreds.hostname, WifiCreds.ssid, WifiCreds.password); + // wifiStart(WifiCreds.hostname, WifiCreds.ssid, WifiCreds.password); + wifiStart(OperatingParameters.DeviceName, WifiCreds.ssid, WifiCreds.password); + + +#ifdef MQTT_ENABLED + // Start Matter + printf ("Starting MQTT\n"); + MqttInit(); +#endif + // Initialize indicators (relays, LEDs, buzzer) printf ("Initializing indicators\n"); diff --git a/app/src/matter.cpp b/app/src/matter.cpp new file mode 100644 index 0000000..1b47e4e --- /dev/null +++ b/app/src/matter.cpp @@ -0,0 +1,402 @@ +#ifdef MATTER_ENABLED + +#include "thermostat.hpp" + +/** + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING + * + * A string identifying the software version running on the device. + */ +//#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "V1.0" + +/** + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION + * + * A monothonic number identifying the software version running on the device. + */ +//#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 1 + +/** + * CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION + * + * The hardware version number assigned to device or product by the device vendor. This + * number is scoped to the device product id, and typically corresponds to a revision of the + * physical device, a change to its packaging, and/or a change to its marketing presentation. + * This value is generally *not* incremented for device software versions. + */ +//#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION 5 + +/** + * @brief Fallback value for the basic information cluster's Vendor name attribute + * if the actual vendor name is not provisioned in the device memory. + */ +#define CHIP_DEVICE_CONFIG_VENDOR_NAME "Steve Meisner" +#define CONFIG_CHIP_DEVICE_VENDOR_NAME "1Steve Meisner" + +/** + * @brief Set the name of the product. This will be written to node0 + * and used as the product name. + */ +#define CHIP_DEVICE_CONFIG_PRODUCT_NAME "RealSmartThermostat" + +// Use a default pairing code if one hasn't been provisioned in flash. +// #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 +// #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 +#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME "Steve Meisner" +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME "Smart prod" +#define CONFIG_CHIP_DEVICE_PRODUCT_NAME "Smart chip prod" +#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION_STRING "v1.0" +#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING "v2.0" + +#include "Matter.h" +#include +#include +#include +#include + +using namespace chip; +using namespace chip::app::Clusters; +using namespace esp_matter; +using namespace esp_matter::endpoint; + +using chip::DeviceLayer::ConfigurationMgr; + +#define TAG "Thermostat" + +/** + * This program presents example Matter light device with OnOff cluster by + * controlling LED with Matter and toggle button. + * + * If your ESP does not have buildin LED, please connect it to LED_PIN + * + * You can toggle light by both: + * - Matter (via CHIPTool or other Matter controller) + * - toggle button (by default attached to GPIO0 - reset button, with debouncing) + */ + +// Please configure your PINs +// const int LED_PIN = 2; +// const int TOGGLE_BUTTON_PIN = 0; + +// Debounce for toggle button +// const int DEBOUNCE_DELAY = 500; +// int last_toggle; + +constexpr auto k_timeout_seconds = 300; + +// Cluster and attribute ID used by Matter light device +const uint32_t CLUSTER_ID = OnOff::Id; +const uint32_t ATTRIBUTE_ID = OnOff::Attributes::OnOff::Id; + +// Endpoint and attribute ref that will be assigned to Matter device +uint16_t light_endpoint_id = 0; +attribute_t *attribute_ref; + +// There is possibility to listen for various device events, related for example to setup process +// Leaved as empty for simplicity +static void on_device_event(const ChipDeviceEvent *event, intptr_t arg) +{ + Serial.printf ("IN on_device_event() : event->Type = %d\n", event->Type); + + switch (event->Type) + { + case chip::DeviceLayer::DeviceEventType::kInterfaceIpAddressChanged: + ESP_LOGI(TAG, "Interface IP Address changed"); + break; + + case chip::DeviceLayer::DeviceEventType::kCommissioningComplete: + ESP_LOGI(TAG, "Commissioning complete"); + break; + + case chip::DeviceLayer::DeviceEventType::kFailSafeTimerExpired: + ESP_LOGI(TAG, "Commissioning failed, fail safe timer expired"); + break; + + case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStarted: + ESP_LOGI(TAG, "Commissioning session started"); + break; + + case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStopped: + ESP_LOGI(TAG, "Commissioning session stopped"); + break; + + case chip::DeviceLayer::DeviceEventType::kCommissioningWindowOpened: + ESP_LOGI(TAG, "Commissioning window opened"); + break; + + case chip::DeviceLayer::DeviceEventType::kCommissioningWindowClosed: + ESP_LOGI(TAG, "Commissioning window closed"); + break; + + case chip::DeviceLayer::DeviceEventType::kFabricRemoved: + { + ESP_LOGI(TAG, "Fabric removed successfully"); +#if 0 + if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0) + { + chip::CommissioningWindowManager & commissionMgr = chip::Server::GetInstance().GetCommissioningWindowManager(); + constexpr auto kTimeoutSeconds = chip::System::Clock::Seconds16(k_timeout_seconds); + if (!commissionMgr.IsCommissioningWindowOpen()) + { + /* After removing last fabric, this example does not remove the Wi-Fi credentials + * and still has IP connectivity so, only advertising on DNS-SD. + */ + CHIP_ERROR err = commissionMgr.OpenBasicCommissioningWindow(kTimeoutSeconds, + chip::CommissioningWindowAdvertisement::kDnssdOnly); + if (err != CHIP_NO_ERROR) + { + ESP_LOGE(TAG, "Failed to open commissioning window, err:%" CHIP_ERROR_FORMAT, err.Format()); + } + } + } +#endif + break; + } + + case chip::DeviceLayer::DeviceEventType::kFabricWillBeRemoved: + ESP_LOGI(TAG, "Fabric will be removed"); + break; + + case chip::DeviceLayer::DeviceEventType::kFabricUpdated: + ESP_LOGI(TAG, "Fabric is updated"); + break; + + case chip::DeviceLayer::DeviceEventType::kFabricCommitted: + ESP_LOGI(TAG, "Fabric is committed"); + break; + + default: + break; + } +} + +static esp_err_t on_identification(identification::callback_type_t type, uint16_t endpoint_id, + uint8_t effect_id, uint8_t effect_variant, void *priv_data) { + return ESP_OK; +} + +// Listener on attribute update requests. +// In this example, when update is requested, path (endpoint, cluster and attribute) is checked +// if it matches light attribute. If yes, LED changes state to new one. +static esp_err_t on_attribute_update(attribute::callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id, + uint32_t attribute_id, esp_matter_attr_val_t *val, void *priv_data) { + if (type == attribute::PRE_UPDATE && endpoint_id == light_endpoint_id && + cluster_id == CLUSTER_ID && attribute_id == ATTRIBUTE_ID) { + // We got an light on/off attribute update! + bool new_state = val->val.b; +// digitalWrite(LED_PIN, new_state); + } + return ESP_OK; +} + +bool MatterInit() +{ + // Enable debug logging + esp_log_level_set("*", ESP_LOG_DEBUG); + // esp_log_level_set("*", ESP_LOG_WARN); + + if (!OperatingParameters.MatterEnabled) + { + Serial.printf ("MatterInit() called when Matter not enabled\n"); + return false; + } + + // If no creds in EEPROM, do not start Matter. + // There may be creds stored in wifi NVS. + if (strlen(WifiCreds.ssid) == 0) + { + Serial.printf ("No wifi credentials set -- not starting matter\n"); + return false; + } + + // Set wifi credentials + wifiSetCredentials(WifiCreds.ssid, WifiCreds.password); + + // Setup Matter node + node::config_t node_config; + node_t *node = node::create(&node_config, on_attribute_update, on_identification); + + // Set product name (stored in node 0) + auto endpoint = esp_matter::endpoint::get(node, 0); + auto cluster = esp_matter::cluster::get(endpoint, chip::app::Clusters::BasicInformation::Id); + auto attribute = esp_matter::attribute::get(cluster, chip::app::Clusters::BasicInformation::Attributes::NodeLabel::Id); + std::string data = CHIP_DEVICE_CONFIG_PRODUCT_NAME; + auto val = esp_matter_char_str(data.data(), data.length()); + esp_matter::attribute::set_val(attribute, &val); + + + +#if 0 +{ + esp_err_t error; + esp_matter_attr_val_t val = esp_matter_char_str((char *)"Lowpan", sizeof("Lowpan")); + error = attribute::update( + 0, + chip::app::Clusters::BasicInformation::Id, + chip::app::Clusters::BasicInformation::Attributes::VendorName::Id, + &val); +} + + // THE FOLLOWING DO NOT WORK + attribute = esp_matter::attribute::get(cluster, chip::app::Clusters::BasicInformation::Attributes::ProductName::Id); + data = CHIP_DEVICE_CONFIG_PRODUCT_NAME; + val = esp_matter_char_str(data.data(), data.length()); + esp_matter::attribute::set_val(attribute, &val); + + attribute = esp_matter::attribute::get(cluster, chip::app::Clusters::BasicInformation::Attributes::VendorName::Id); + data = CHIP_DEVICE_CONFIG_VENDOR_NAME; + val = esp_matter_char_str(data.data(), data.length()); + esp_matter::attribute::set_val(attribute, &val); + + attribute = esp_matter::attribute::get(cluster, chip::app::Clusters::BasicInformation::Attributes::HardwareVersionString::Id); + data = CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION_STRING; + val = esp_matter_char_str(data.data(), data.length()); + esp_matter::attribute::set_val(attribute, &val); + // THE ABOVE DO NOT WORK +#endif + + // Add enpoint to the node + thermostat::config_t thermostat_config; + thermostat_config.thermostat.local_temperature = 19; + thermostat_config.thermostat.system_mode = 0; // OFF state + endpoint_t *thermostat_endpoint = thermostat::create(node, &thermostat_config, ENDPOINT_FLAG_NONE, NULL); + + uint16_t thermostat_endpoint_id = endpoint::get_id(thermostat_endpoint); + ESP_LOGI(TAG, "Thermostat endpoint_id = %d", thermostat_endpoint_id); + + // Add additional feature + cluster_t *thermostat_cluster = cluster::get(thermostat_endpoint, Thermostat::Id); + cluster::thermostat::feature::heating::config_t heating_config; + heating_config.abs_max_heat_setpoint_limit = 3000; + heating_config.abs_min_heat_setpoint_limit = 1500; + heating_config.max_heat_setpoint_limit = 2800; + heating_config.min_heat_setpoint_limit = 2000; + heating_config.occupied_heating_setpoint = 2300; + heating_config.pi_heating_demand = 0; + ESP_LOGE(TAG, "Thermostat heating cluster id = %d", cluster::thermostat::feature::heating::get_id()); + cluster::thermostat::feature::heating::add(thermostat_cluster, &heating_config); + + // Add additional cooling cluster +// cluster_t *thermostat_cluster = cluster::get(thermostat_endpoint, Thermostat::Id); + esp_matter::cluster::thermostat::feature::cooling::config_t cooling_config; + //cooling_config.config();MutableCharSpan + cooling_config.abs_min_cool_setpoint_limit = 1600; + cooling_config.abs_max_cool_setpoint_limit = 3200; + cooling_config.pi_cooling_demand = 50; // 50% + cooling_config.occupied_cooling_setpoint = 2600; + cooling_config.min_cool_setpoint_limit = 1600; + cooling_config.max_cool_setpoint_limit = 3200; + ESP_LOGE(TAG, "Thermostat cooling cluster id = %d", esp_matter::cluster::thermostat::feature::cooling::get_id()); + esp_matter::cluster::thermostat::feature::cooling::add(thermostat_cluster, &cooling_config); + + + + + + + + + + + + +// // Setup Light endpoint / cluster / attributes with default values +// on_off_light::config_t light_config; +// light_config.on_off.on_off = false; +// light_config.on_off.lighting.start_up_on_off = false; +// endpoint_t *endpoint = on_off_light::create(node, &light_config, ENDPOINT_FLAG_NONE, NULL); + +// // Save on/off attribute reference. It will be used to read attribute value later. +// attribute_ref = attribute::get(cluster::get(endpoint, CLUSTER_ID), ATTRIBUTE_ID); + +// // Save generated endpoint id +// light_endpoint_id = endpoint::get_id(endpoint); + + // Setup DAC (this is good place to also set custom commission data, passcodes etc.) + esp_matter::set_custom_dac_provider(Credentials::Examples::GetExampleDACProvider()); + + + + + ESP_LOGE(TAG, "Calling esp_matter::start()\n"); + // Start Matter device + esp_matter::start(on_device_event); + + // Get QR Code + std::string QRCode = " "; // 33 chars + CHIP_ERROR err; + + ESP_LOGE(TAG, "Calling PrintOnboardingCodes()\n"); + // Print codes needed to setup Matter device + #if 0 + PrintOnboardingCodes(RendezvousInformationFlags(RendezvousInformationFlag::kOnNetwork)); + #else + err = GetQRCode((MutableCharSpan &)QRCode, RendezvousInformationFlag::kOnNetwork); + if (err == CHIP_NO_ERROR) + { + // strcpy (OperatingParameters.MatterQR, QRCode.data()); + strcpy (OperatingParameters.MatterQR, QRCode.c_str()); + ESP_LOGE(TAG, "QR Pairing Code: '%s'\n", OperatingParameters.MatterQR); + } else { + ESP_LOGE(TAG, "Failed to GetQRCode() -- Error: %d\n", err.AsInteger()); + } + err = GetManualPairingCode((MutableCharSpan &)QRCode, RendezvousInformationFlag::kOnNetwork); + if (err == CHIP_NO_ERROR) + { + strcpy (OperatingParameters.MatterPairingCode, QRCode.c_str()); + ESP_LOGE(TAG, "Manual Pairing Code: '%s'\n", OperatingParameters.MatterPairingCode); + } else { + ESP_LOGE(TAG, "Failed to GetManualPairingCode() -- Error: %d\n", err.AsInteger()); + } + #endif + + OperatingParameters.MatterStarted = true; + + // Call into wifi module to set flags appropriately to + // indicate Matter is running and register wifi callbacks. + wifiMatterStarted(); + + return true; +} + + +void MatterFactoryReset() +{ + ESP_LOGI(TAG, "Calling ESP factory_reset()\n"); +#if 1 + esp_matter::factory_reset(); +#else + chip::DeviceLayer::ConfigurationMgr().InitiateFactoryReset(); +#endif +} + +// Reads light on/off attribute value +esp_matter_attr_val_t get_onoff_attribute_value() { + esp_matter_attr_val_t onoff_value = esp_matter_invalid(NULL); + attribute::get_val(attribute_ref, &onoff_value); + return onoff_value; +} + +// Sets light on/off attribute value +void set_onoff_attribute_value(esp_matter_attr_val_t* onoff_value) { + attribute::update(light_endpoint_id, CLUSTER_ID, ATTRIBUTE_ID, onoff_value); +} + +// When toggle light button is pressed (with debouncing), +// light attribute value is changed +void MatterLoop() +{ +// if ((millis() - last_toggle) > DEBOUNCE_DELAY) +// { +// if (!digitalRead(TOGGLE_BUTTON_PIN)) +// { +// last_toggle = millis(); +// // Read actual on/off value, invert it and set +// esp_matter_attr_val_t onoff_value = get_onoff_attribute_value(); +// onoff_value.val.b = !onoff_value.val.b; +// set_onoff_attribute_value(&onoff_value); +// } +// } +} + +#endif // #ifdef MATTER_ENABLED diff --git a/app/src/mqtt.cpp b/app/src/mqtt.cpp new file mode 100644 index 0000000..2428177 --- /dev/null +++ b/app/src/mqtt.cpp @@ -0,0 +1,428 @@ +#ifdef MQTT_ENABLED + +#include // for string class +#include "thermostat.hpp" +#include "version.h" +#include +#include +#include "freertos/semphr.h" +#include "freertos/queue.h" +#include "mqtt_client.h" +#include + +static const char *TAG = "MQTT"; + +// Variable used for MQTT Discovery +const char* g_deviceModel = "Truly Smart Thermostat"; // Hardware Model +const char* g_swVersion = VERSION_STRING; // Firmware Version +const char* g_manufacturer = "Steve Meisner"; // Manufacturer Name +std::string g_deviceName; // = OperatingParameters.DeviceName; // Device Name +std::string g_mqttStatusTopic; // = "SmartThermostat/" + g_deviceName; // MQTT Topic + +struct CustomWriter { + std::string str; + + size_t write(uint8_t c) { + str.append(1, static_cast(c)); + // ESP_LOGI(TAG, "(char) -> %c", c); + return 1; + } + + size_t write(const uint8_t *s, size_t n) { + str.append(reinterpret_cast(s), n); + // ESP_LOGI(TAG, "(str) -> %s", str.c_str()); + return n; + } +}; + +#define MQTT_EVENT_CONNECTED_BIT BIT0 +#define MQTT_EVENT_DISCONNECTED_BIT BIT1 +#define MQTT_EVENT_PUB_BIT BIT2 +#define MQTT_ERROR_BIT BIT3 +static EventGroupHandle_t s_mqtt_event_group = NULL; +const TickType_t xTicksToWait = 10000 / portTICK_PERIOD_MS; + +static void MqttEventHandler(void* handler_args, esp_event_base_t base, int32_t event_id, void* event_data) +{ + esp_mqtt_event_handle_t event = (esp_mqtt_event_handle_t)event_data; + esp_mqtt_client_handle_t client = event->client; + // int msg_id; + // your_context_t *context = event->context; + switch (event->event_id) { + case MQTT_EVENT_CONNECTED: + ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED"); + OperatingParameters.MqttConnected = true; + xEventGroupSetBits(s_mqtt_event_group, MQTT_EVENT_CONNECTED_BIT); + break; + case MQTT_EVENT_DISCONNECTED: + ESP_LOGI(TAG, "MQTT_EVENT_DISCONNECTED"); + OperatingParameters.MqttConnected = false; + xEventGroupSetBits(s_mqtt_event_group, MQTT_EVENT_DISCONNECTED_BIT); + break; + case MQTT_EVENT_SUBSCRIBED: + ESP_LOGI(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d", event->msg_id); + // msg_id = esp_mqtt_client_publish(client, "/topic/qos0", "data", 0, 0, 0); + // ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id); + break; + case MQTT_EVENT_UNSUBSCRIBED: + ESP_LOGI(TAG, "MQTT_EVENT_UNSUBSCRIBED, msg_id=%d", event->msg_id); + break; + case MQTT_EVENT_PUBLISHED: + ESP_LOGI(TAG, "MQTT_EVENT_PUBLISHED, msg_id=%d", event->msg_id); + // xEventGroupSetBits(s_mqtt_event_group, MQTT_EVENT_PUB_BIT); + break; + case MQTT_EVENT_DATA: + ESP_LOGI(TAG, "MQTT_EVENT_DATA"); + printf("TOPIC=%.*s\r\n", event->topic_len, event->topic); + printf("DATA=%.*s\r\n", event->data_len, event->data); + if (strstr(event->topic, "mode")) + { + char m[event->data_len + 1]; + strncpy (m, event->data, event->data_len); + m[event->data_len] = '\0'; + // Make first letter uppercase to match our string representation + m[0] = toupper(m[0]); + printf ("Looking up %s\n", m); + updateHvacMode (strToHvacMode(m)); + } + if (strstr(event->topic, "temp")) + { + updateHvacSetTemp (atof(event->data)); + } + break; + case MQTT_EVENT_ERROR: + ESP_LOGI(TAG, "MQTT_EVENT_ERROR"); + xEventGroupSetBits(s_mqtt_event_group, MQTT_ERROR_BIT); + break; + } +} + +void MqttPublish(const char *topic, const char *payload) +{ + int msg_id; + if (!OperatingParameters.MqttConnected) + { + ESP_LOGW(TAG, "Trying to MQTT publish while not connected"); + return; + } + msg_id = esp_mqtt_client_publish( + (esp_mqtt_client_handle_t)(OperatingParameters.MqttClient), topic, payload, 0, 0, 0); + ESP_LOGV(TAG, "Sent MQTT publish -- msg_id=%d", msg_id); + xEventGroupSetBits(s_mqtt_event_group, MQTT_EVENT_PUB_BIT); +} + +void makeLower(const char *string) +{ + char *p = (char *)string; + while (*p) + { + *p = tolower(*p); + p++; + } +} + +void MqttUpdateStatusTopic() +{ + if (OperatingParameters.MqttEnabled && OperatingParameters.MqttConnected) + { + std::string mode = hvacModeToString(OperatingParameters.hvacSetMode); + StaticJsonDocument<200> payload; + // payload["inputstatus"] = "ON"; + payload["Humidity"] = OperatingParameters.humidCurrent + OperatingParameters.humidityCorrection; + payload["Temperature"] = OperatingParameters.tempCurrent + OperatingParameters.tempCorrection; + payload["Setpoint"] = OperatingParameters.tempSet; + makeLower(mode.c_str()); + payload["Mode"] = mode; + + std::string strPayload; + serializeJson(payload, strPayload); + ESP_LOGI (TAG, "%s", strPayload.c_str()); + + std::string topic; + topic = g_mqttStatusTopic + "/status"; + // if(g_mqttPubSub.connected()) + // { + MqttPublish(topic.c_str(), strPayload.c_str()); + // } + } +} + +void MqttHomeAssistantDiscovery() +{ + CustomWriter writer; + static char mac[24]; + // std::string UniqueId; + std::string discoveryTopic; + std::string payload; + std::string strPayload; + + // if(g_mqttPubSub.connected()) + { + ESP_LOGI(TAG, "Send Home Assistant Discovery..."); + StaticJsonDocument<700> payload; + JsonObject device; + JsonArray modes; + JsonArray identifiers; + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Temperature + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // discoveryTopic = "homeassistant/sensor/esp32iotsensor/" + g_deviceName + "_temp" + "/config"; + // discoveryTopic = "homeassistant/climate/thermostat/" + g_deviceName + "_temp" + "/config"; + discoveryTopic = "homeassistant/climate/" + g_deviceName + "/thermostat/config"; + + snprintf (mac, sizeof(mac), "%02x%02x%02x%02x%02x%02x", + OperatingParameters.mac[0], + OperatingParameters.mac[1], + OperatingParameters.mac[2], + OperatingParameters.mac[3], + OperatingParameters.mac[4], + OperatingParameters.mac[5]); + // UniqueId = mac; + // printf ("Mac: %s\n", mac); + + // payload["name"] = g_deviceName + ".temp"; + payload["name"] = g_deviceName; + // payload["uniq_id"] = UniqueId + "_temp"; + payload["uniq_id"] = mac; + // payload["power_command_topic"] = g_deviceName + "/power/set"; + + modes = payload.createNestedArray("modes"); + modes.add("off"); + modes.add("heat"); + if (OperatingParameters.hvacCoolEnable) + modes.add("cool"); + if (OperatingParameters.hvacFanEnable) + modes.add("fan"); + if ((OperatingParameters.hvacCoolEnable) || (OperatingParameters.hvacFanEnable)) + modes.add("auto"); + + // payload["stat_t"] = g_mqttStatusTopic + "/temperature"; + payload["curr_temp_t"] = g_mqttStatusTopic + "/status"; + payload["curr_temp_tpl"] = "{{ value_json.Temperature|float }}"; + payload["temp_stat_t"] = g_mqttStatusTopic + "/status"; + payload["temp_stat_tpl"] = "{{ value_json.Setpoint }}"; + payload["mode_stat_t"] = g_mqttStatusTopic + "/status"; + payload["mode_stat_tpl"] = "{{ value_json.Mode }}"; + payload["current_humidity_topic"] = g_mqttStatusTopic + "/status"; + payload["current_humidity_template"] = "{{ value_json.Humidity|float }}"; + + payload["mode_cmd_t"] = g_deviceName + "/set/mode"; + payload["temp_cmd_t"] = g_deviceName + "/set/temp"; + + // payload["dev_cla"] = "temperature"; + // payload["val_tpl"] = "{{ value_json.temp | is_defined }}"; + // payload["unit_of_meas"] = "°C"; + payload["temp_unit"] = &OperatingParameters.tempUnits; + + device = payload.createNestedObject("device"); + device["name"] = g_deviceName; + device["model"] = g_deviceModel; + device["sw_version"] = g_swVersion; + device["manufacturer"] = g_manufacturer; + + identifiers = device.createNestedArray("identifiers"); + identifiers.add(mac); + + serializeJsonPretty(payload, writer); + serializeJson(payload, strPayload); + ESP_LOGI (TAG, "Payload: %s", strPayload.c_str()); + + // g_mqttPubSub.publish(discoveryTopic.c_str(), strPayload.c_str()); + MqttPublish(discoveryTopic.c_str(), strPayload.c_str()); + + EventBits_t bits = xEventGroupWaitBits(s_mqtt_event_group, + MQTT_EVENT_PUB_BIT | MQTT_ERROR_BIT, + pdFALSE, + pdFALSE, + xTicksToWait); + + if (bits & MQTT_ERROR_BIT) + ESP_LOGE(TAG, "Publish failed"); + + +#if 0 + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Humidity + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + payload.clear(); + device.clear(); + identifiers.clear(); + strPayload.clear(); + + discoveryTopic = "homeassistant/climate/thermostat/" + g_deviceName + "_hum" + "/config"; + + payload["name"] = g_deviceName + ".hum"; + // payload["uniq_id"] = UniqueId + "_hum"; + payload["stat_t"] = g_mqttStatusTopic; + payload["dev_cla"] = "humidity"; + payload["val_tpl"] = "{{ value_json.hum | is_defined }}"; + payload["unit_of_meas"] = "%"; + device = payload.createNestedObject("device"); + device["name"] = g_deviceName; + device["model"] = g_deviceModel; + device["sw_version"] = g_swVersion; + device["manufacturer"] = g_manufacturer; + identifiers = device.createNestedArray("identifiers"); + identifiers.add("UniqueId2"); + + serializeJsonPretty(payload, writer); + ESP_LOGI (TAG, "test2"); + serializeJson(payload, strPayload); + printf ("Payload: %s\n", strPayload.c_str()); + + // g_mqttPubSub.publish(discoveryTopic.c_str(), strPayload.c_str()); + MqttPublish(discoveryTopic.c_str(), strPayload.c_str()); + + bits = xEventGroupWaitBits(s_mqtt_event_group, + MQTT_EVENT_PUB_BIT | MQTT_ERROR_BIT, + pdFALSE, + pdFALSE, + xTicksToWait); + + if (bits & MQTT_ERROR_BIT) + ESP_LOGE(TAG, "Publish failed"); + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Binary Door + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + payload.clear(); + device.clear(); + identifiers.clear(); + strPayload.clear(); + + discoveryTopic = "homeassistant/climate/thermostat/" + g_deviceName + "_door" + "/config"; + + payload["name"] = g_deviceName + ".door"; + payload["uniq_id"] = UniqueId + "_door"; + payload["stat_t"] = g_mqttStatusTopic; + payload["dev_cla"] = "door"; + payload["val_tpl"] = "{{ value_json.inputstatus | is_defined }}"; + device = payload.createNestedObject("device"); + device["name"] = g_deviceName; + device["model"] = g_deviceModel; + device["sw_version"] = g_swVersion; + device["manufacturer"] = g_manufacturer; + identifiers = device.createNestedArray("identifiers"); + identifiers.add(UniqueId); + + // serializeJsonPretty(payload, writer); + ESP_LOGI (TAG, "test3"); + serializeJson(payload, strPayload); + + // g_mqttPubSub.publish(discoveryTopic.c_str(), strPayload.c_str()); +#endif + + } +} + +void MqttSubscribeTopic(esp_mqtt_client_handle_t client, std::string topic) +{ + int msg_id; + msg_id = esp_mqtt_client_subscribe(client, topic.c_str(), 1); + if (msg_id < 0) + ESP_LOGE (TAG, "Send subscribe FAILED, Topic=%s, msg_id=%d", topic.c_str(), msg_id); + else + ESP_LOGI (TAG, "Send subscribe successful, Topic=%s, msg_id=%d", topic.c_str(), msg_id); +} + + +static void MqttConnect(void) +{ + ESP_LOGI(__FUNCTION__, "Waiting for MQTT..."); + esp_mqtt_client_config_t mqtt_cfg; + memset(&mqtt_cfg, 0, sizeof(esp_mqtt_client_config_t)); + + OperatingParameters.MqttBrokerHost = (char *)malloc(64); + strcpy (OperatingParameters.MqttBrokerHost, "mqtt://hass.meisners.net:1883"); + OperatingParameters.MqttBrokerUsername = (char *)malloc(16); + strcpy (OperatingParameters.MqttBrokerUsername, "homeassistant"); + OperatingParameters.MqttBrokerPassword = (char *)malloc(72); + strcpy (OperatingParameters.MqttBrokerPassword, "einiiZeiphah4ish0Rowae7doh0OhNg6wahngohmie4iNae1meipainaeyijai5i"); + + printf ("Broker: %s\n", OperatingParameters.MqttBrokerHost); + printf ("Username: %s\n", OperatingParameters.MqttBrokerUsername); + printf ("Password: %s\n", OperatingParameters.MqttBrokerPassword); + // mqtt_cfg.broker.address.uri = "mqtt://iot.eclipse.org"; + // mqtt_cfg.broker.address.uri = "mqtt://test.mosquitto.org:1883"; + // mqtt_cfg.broker.address.transport = MQTT_TRANSPORT_OVER_TCP; + mqtt_cfg.broker.address.uri = OperatingParameters.MqttBrokerHost; + // mqtt_cfg.broker.address.hostname = "mqtt://homeassistant.meisners.net:1883"; + // mqtt_cfg.broker.address.port = 1883; + // mqtt_cfg.credentials.username = "mqtt"; + mqtt_cfg.credentials.username = OperatingParameters.MqttBrokerUsername; + mqtt_cfg.credentials.set_null_client_id = true; + // mqtt_cfg.credentials.authentication.password = "mqtt"; + mqtt_cfg.credentials.authentication.password = OperatingParameters.MqttBrokerPassword; + + + // = { + // .uri = "mqtt://iot.eclipse.org", + // .event_handle = mqtt_event_handler, + // // .user_context = (void *)your_context + // }; + + /* Initialize event group */ + s_mqtt_event_group = xEventGroupCreate(); + + esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg); + OperatingParameters.MqttClient = client; + + esp_mqtt_client_register_event (client, MQTT_EVENT_ANY, MqttEventHandler, client); + esp_mqtt_client_start(client); + + EventBits_t bits = xEventGroupWaitBits(s_mqtt_event_group, + MQTT_EVENT_CONNECTED_BIT | MQTT_ERROR_BIT, + pdFALSE, + pdFALSE, + xTicksToWait); + + if (bits & MQTT_ERROR_BIT) + ESP_LOGE (TAG, "MQTT Connect failed"); + + if (bits & MQTT_EVENT_CONNECTED_BIT) + { + // MqttSubscribeTopic(client, g_mqttStatusTopic); + // MqttSubscribeTopic(client, g_deviceName + "/set/mode"); + // MqttSubscribeTopic(client, g_deviceName + "/set/temp"); + MqttSubscribeTopic(client, g_deviceName + "/set/#"); + } +} + +//@@@ Need a reconnect function + +//@@@ Need a disconnect function + + +void MqttInit() +{ + if (!OperatingParameters.MqttEnabled) + { + ESP_LOGW(TAG, "MQTT is not enabled!"); + return; + } + ESP_LOGI(TAG, "MQTT Startup..."); + if (!wifiConnected()) + { + ESP_LOGE(TAG, "Attempting to start MQTT when wifi connection down"); + return; + } + + esp_log_level_set("*", ESP_LOG_INFO); + esp_log_level_set("MQTT_CLIENT", ESP_LOG_VERBOSE); + esp_log_level_set("TRANSPORT_TCP", ESP_LOG_VERBOSE); + esp_log_level_set("TRANSPORT_SSL", ESP_LOG_VERBOSE); + esp_log_level_set("TRANSPORT", ESP_LOG_VERBOSE); + esp_log_level_set("OUTBOX", ESP_LOG_VERBOSE); + + g_deviceName = OperatingParameters.DeviceName; + g_mqttStatusTopic = g_deviceName + "/status"; + + MqttConnect(); + + MqttHomeAssistantDiscovery(); + + // MqttUpdateStatusTopic(); +} + +#endif // #ifdef MQTT_ENABLED diff --git a/app/src/sensors.cpp b/app/src/sensors.cpp index eab34ab..89d6304 100644 --- a/app/src/sensors.cpp +++ b/app/src/sensors.cpp @@ -49,7 +49,26 @@ Smoothed sensorHumidity; adc_unit_t adcUnit; adc_channel_t adcChannel; adc_oneshot_unit_handle_t adcHandle; -#define EXAMPLE_ADC_ATTEN ADC_ATTEN_DB_11 +#define EXAMPLE_ADC_ATTEN ADC_ATTEN_DB_11 + + +void updateHvacMode(HVAC_MODE mode) +{ + OperatingParameters.hvacSetMode = mode; + eepromUpdateHvacSetMode(); +#ifdef MQTT_ENABLED + MqttUpdateStatusTopic(); +#endif +} + +void updateHvacSetTemp(float setTemp) +{ + OperatingParameters.tempSet = setTemp; + eepromUpdateHvacSetTemp(); +#ifdef MQTT_ENABLED + MqttUpdateStatusTopic(); +#endif +} /*--------------------------------------------------------------- ADC Code (for light sensor) @@ -272,6 +291,9 @@ void updateAht(void *parameter) ESP_LOGI(TAG, "Temp: %0.1f (raw: %0.2f %c) Humidity: %0.1f (raw: %0.2f)", sensorTemp.get(), temperature, OperatingParameters.tempUnits, sensorHumidity.get(), humidity); +#ifdef MQTT_ENABLED + MqttUpdateStatusTopic(); +#endif } else ESP_LOGE(TAG, "Error reading data: %d (%s)", res, esp_err_to_name(res)); diff --git a/app/src/state_machine.cpp b/app/src/state_machine.cpp index 6e9870d..325a9f7 100644 --- a/app/src/state_machine.cpp +++ b/app/src/state_machine.cpp @@ -192,6 +192,11 @@ void stateMachine(void *parameter) OperatingParameters.wifiConnected = wifiConnected(); +#ifdef MQTT_ENABLED + if ((!OperatingParameters.MqttConnected) && (OperatingParameters.MqttEnabled) && (OperatingParameters.wifiConnected)) + MqttInit(); +#endif + // Check wifi #ifdef MATTER_ENABLED if ((!OperatingParameters.wifiConnected) && (strlen(WifiCreds.ssid)) && (!OperatingParameters.MatterStarted)) diff --git a/app/src/tft.cpp b/app/src/tft.cpp index 1174d8e..d45e938 100644 --- a/app/src/tft.cpp +++ b/app/src/tft.cpp @@ -216,13 +216,13 @@ HVAC_MODE convertSelectedHvacMode() // Check to see if the selected HVAC mode is now disabled (after config menu) if ((OperatingParameters.hvacSetMode == AUTO) && !OperatingParameters.hvacCoolEnable) - OperatingParameters.hvacSetMode = OFF; + updateHvacMode(OFF); if ((OperatingParameters.hvacSetMode == FAN) && !OperatingParameters.hvacFanEnable) - OperatingParameters.hvacSetMode = OFF; + updateHvacMode(OFF); if ((OperatingParameters.hvacSetMode == COOL) && !OperatingParameters.hvacCoolEnable) - OperatingParameters.hvacSetMode = OFF; + updateHvacMode(OFF); if ((OperatingParameters.hvacSetMode == AUX_HEAT) && !OperatingParameters.hvac2StageHeatEnable) - OperatingParameters.hvacSetMode = OFF; + updateHvacMode(OFF); // Retrieve currently selected HVAC mode strncpy (selMode, hvacModeToString(OperatingParameters.hvacSetMode), sizeof(selMode)); diff --git a/app/src/web.cpp b/app/src/web.cpp index 8fc5d79..c4e986c 100644 --- a/app/src/web.cpp +++ b/app/src/web.cpp @@ -31,12 +31,11 @@ esp_err_t tempUp(httpd_req_t *req) if (OperatingParameters.tempUnits == 'C') { OperatingParameters.tempSet += 0.5; - OperatingParameters.tempSet = roundValue(OperatingParameters.tempSet, 1); + updateHvacSetTemp(roundValue(OperatingParameters.tempSet, 1)); } else { OperatingParameters.tempSet += 1.0; - OperatingParameters.tempSet = roundValue(OperatingParameters.tempSet, 0); + updateHvacSetTemp(roundValue(OperatingParameters.tempSet, 0)); } - eepromUpdateHvacSetTemp(); return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); } @@ -45,12 +44,11 @@ esp_err_t tempDown(httpd_req_t *req) if (OperatingParameters.tempUnits == 'C') { OperatingParameters.tempSet -= 0.5; - OperatingParameters.tempSet = roundValue(OperatingParameters.tempSet, 1); + updateHvacSetTemp(roundValue(OperatingParameters.tempSet, 1)); } else { OperatingParameters.tempSet -= 1.0; - OperatingParameters.tempSet = roundValue(OperatingParameters.tempSet, 0); + updateHvacSetTemp(roundValue(OperatingParameters.tempSet, 0)); } - eepromUpdateHvacSetTemp(); return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); } @@ -82,36 +80,31 @@ esp_err_t clearFirmware(httpd_req_t *req) esp_err_t hvacModeOff(httpd_req_t *req) { - OperatingParameters.hvacSetMode = OFF; - eepromUpdateHvacSetMode(); + updateHvacMode(OFF); return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); } esp_err_t hvacModeAuto(httpd_req_t *req) { - OperatingParameters.hvacSetMode = AUTO; - eepromUpdateHvacSetMode(); + updateHvacMode(AUTO); return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); } esp_err_t hvacModeHeat(httpd_req_t *req) { - OperatingParameters.hvacSetMode = HEAT; - eepromUpdateHvacSetMode(); + updateHvacMode(HEAT); return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); } esp_err_t hvacModeCool(httpd_req_t *req) { - OperatingParameters.hvacSetMode = COOL; - eepromUpdateHvacSetMode(); + updateHvacMode(COOL); return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); } esp_err_t hvacModeFan(httpd_req_t *req) { - OperatingParameters.hvacSetMode = FAN; - eepromUpdateHvacSetMode(); + updateHvacMode(FAN); return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); } diff --git a/app/src/wifi.cpp b/app/src/wifi.cpp index 9f53fc8..3ef4f1c 100644 --- a/app/src/wifi.cpp +++ b/app/src/wifi.cpp @@ -25,7 +25,7 @@ #include // for string class #include "thermostat.hpp" - +#include // for esp_read_mac() #if 0 // This isn't working correctly yet. I believe due to relying on the @@ -145,7 +145,8 @@ void WiFi_ScanSSID(void) .channel = 0, .show_hidden = false, .scan_type = WIFI_SCAN_TYPE_ACTIVE, - .scan_time = scan_time + .scan_time = scan_time, + .home_chan_dwell_time = 0 }; wifiScanActive = true; @@ -227,39 +228,50 @@ static void event_handler(void* arg, esp_event_base_t event_base, return; } - if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) + if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) { ESP_LOGD(TAG, " event = STA_START"); - esp_wifi_connect(); - } +#ifdef MATTER_ENABLED + if (!OperatingParameters.MatterStarted) +#endif + esp_wifi_connect(); + } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { ESP_LOGI(TAG, " event = STA_DISCONECTED - retry # %d (MAX %d)", s_retry_num, CONFIG_ESP_MAXIMUM_RETRY); WifiStatus.Connected = false; OperatingParameters.wifiConnected = false; - if (s_retry_num < CONFIG_ESP_MAXIMUM_RETRY) + if (s_retry_num < CONFIG_ESP_MAXIMUM_RETRY) { - ESP_LOGW(TAG, " connect to the AP failed - retrying"); - esp_wifi_connect(); - s_retry_num++; - } +#ifdef MATTER_ENABLED + if (!OperatingParameters.MatterStarted) + { +#endif + esp_wifi_connect(); + s_retry_num++; + ESP_LOGW(TAG, " connect to the AP failed - retrying"); +#ifdef MATTER_ENABLED + } +#endif + } else { ESP_LOGE(TAG, " retry count exceeded"); xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT); - } - } + wifiConnecting = false; + } + } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { - ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; - ESP_LOGI(TAG, " event = IP_EVENT_STA_GOT_IP - ip: " IPSTR, IP2STR(&event->ip_info.ip)); - s_retry_num = 0; - xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); + ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; + ESP_LOGI(TAG, " event = IP_EVENT_STA_GOT_IP - ip: " IPSTR, IP2STR(&event->ip_info.ip)); + s_retry_num = 0; + xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); WifiStatus.Connected = true; OperatingParameters.wifiConnected = true; WifiStatus.ip = event->ip_info.ip; wifiConnecting = false; - } + } } void wifiSetHostname(const char *hostname) @@ -289,10 +301,10 @@ void wifiSetCredentials(const char *ssid, const char *pass) } // Set the wifi parameters - wifi_config_t wifi_config; - bzero(&wifi_config, sizeof(wifi_config_t)); - strcpy((char *)wifi_config.sta.ssid, ssid); - strcpy((char *)wifi_config.sta.password, pass); + wifi_config_t wifi_config; + bzero(&wifi_config, sizeof(wifi_config_t)); + strcpy((char *)wifi_config.sta.ssid, ssid); + strcpy((char *)wifi_config.sta.password, pass); if (!wasInitialized) { wifi_config.sta.threshold.authmode = WIFI_AUTH_WPA2_PSK; @@ -302,7 +314,7 @@ void wifiSetCredentials(const char *ssid, const char *pass) /* Initialize STA */ ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_LOGD(TAG, "- Calling esp_wifi_set_config()"); - ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); // // After creating the driver stack to save the wifi credentials, we @@ -357,6 +369,49 @@ void wifiDeregisterEventCallbacks() s_wifi_event_group = NULL; } +#ifdef MATTER_ENABLED +void wifiSwitchMatterMode() +{ + if (OperatingParameters.MatterEnabled) + { + // Setting MatterStarted keeps networkReconnect task from running + OperatingParameters.MatterStarted = true; + Serial.printf ("Enabling Matter\n"); + // Since we are shutting down wifi to enable Matter, + // do not allow callbacks to take any action. + wifiDeregisterEventCallbacks(); + Serial.printf ("Shutting down wifi connection\n"); + WifiDisconnect(); + Serial.printf ("Unloading wifi driver\n"); + WifiDeinit(); + Serial.printf ("Starting Matter API\n"); + OperatingParameters.MatterStarted = MatterInit(); + // Serial.printf ("Connecting to wifi\n"); + // OperatingParameters.wifiConnected = + // wifiStart(WifiCreds.hostname, WifiCreds.ssid, WifiCreds.password); + } + else + { + Serial.printf ("Disabling Matter\n"); + updateThermostatParams(); + // ESP restart will happen as part of UI code (see ui_events.cpp) + } +} + +void wifiMatterStarted() +{ + // wifiSetHostname(WifiCreds.hostname); + + // Add additional wifi details... + WifiStatus.wifi_started = true; + WifiStatus.if_init = true; + WifiStatus.driver_started = true; + WifiStatus.Connected = true; + // Register callbacks for wifi events + // wifiRegisterEventCallbacks(); +} +#endif + bool wifiStart(const char *hostname, const char *ssid, const char *pass) { // This code needs to be revisited later after Arduino framework removed. @@ -365,15 +420,23 @@ bool wifiStart(const char *hostname, const char *ssid, const char *pass) // Enable debug logging // esp_log_level_set("*", ESP_LOG_NONE); // esp_log_level_set(TAG, ESP_LOG_WARN); - esp_log_level_set("*", ESP_LOG_INFO); + esp_log_level_set("*", ESP_LOG_INFO); // - ESP_LOGI(TAG, "wifiStart()"); + ESP_LOGI(TAG, "wifiStart()"); nvs_flash_init(); wifiConnecting = true; - + +#ifdef MATTER_ENABLED + if (OperatingParameters.MatterStarted) + { + ESP_LOGI(TAG, "Matter is already running -- abort wifiStart()"); + return true; + } +#endif + if (!WifiStatus.driver_started) { ESP_LOGW(TAG, " Wifi driver not started; Calling init and create funcs"); @@ -420,6 +483,16 @@ bool wifiStart(const char *hostname, const char *ssid, const char *pass) ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); } + // Retrieve the MAC address of the interface + esp_read_mac(OperatingParameters.mac, ESP_MAC_WIFI_STA); + ESP_LOGI (TAG, "MAC Address: %02x:%02x:%02x:%02x:%02x:%02x", + OperatingParameters.mac[0], + OperatingParameters.mac[1], + OperatingParameters.mac[2], + OperatingParameters.mac[3], + OperatingParameters.mac[4], + OperatingParameters.mac[5]); + ESP_LOGI(TAG, " Calling esp_wifi_start()"); ESP_ERROR_CHECK(esp_wifi_start()); WifiStatus.wifi_started = true; @@ -430,45 +503,45 @@ bool wifiStart(const char *hostname, const char *ssid, const char *pass) return true; } - /* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum - * number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above) */ - esp_err_t ret_value = ESP_OK; + /* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum + * number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above) */ + esp_err_t ret_value = ESP_OK; ESP_LOGI(TAG, " Waiting for event callback..."); - EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group, - WIFI_CONNECTED_BIT | WIFI_FAIL_BIT | WIFI_FAIL_ABORTED, - pdFALSE, - pdFALSE, - xTicksToWait); - - /* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually - * happened. */ - if (bits & WIFI_CONNECTED_BIT) - { - ESP_LOGI(TAG, "connected to ap SSID:%s password:****", WifiCreds.ssid); - } + EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group, + WIFI_CONNECTED_BIT | WIFI_FAIL_BIT | WIFI_FAIL_ABORTED, + pdFALSE, + pdFALSE, + xTicksToWait); + + /* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually + * happened. */ + if (bits & WIFI_CONNECTED_BIT) + { + ESP_LOGI(TAG, "connected to ap SSID:%s password:****", WifiCreds.ssid); + } else if (bits & WIFI_FAIL_BIT) { - ESP_LOGE(TAG, "Failed to connect to SSID:%s, password:****", WifiCreds.ssid); - ret_value = ESP_FAIL; - } + ESP_LOGE(TAG, "Failed to connect to SSID:%s, password:****", WifiCreds.ssid); + ret_value = ESP_FAIL; + } else if (bits & WIFI_FAIL_ABORTED) { ESP_LOGE(TAG, "Aborted connect to SSID:%s, password:****", WifiCreds.ssid); - ret_value = ESP_FAIL; + ret_value = ESP_FAIL; } else { - ESP_LOGE(TAG, "UNEXPECTED EVENT"); - ret_value = ESP_FAIL; - } + ESP_LOGE(TAG, "UNEXPECTED EVENT"); + ret_value = ESP_FAIL; + } // // Intentionally leave the callbacks in place as they are used to update // statuses such as connection status and ip address. // - ESP_LOGD(TAG, "wifi_connect_sta finished."); - return (ret_value == ESP_OK); + ESP_LOGD(TAG, "wifi_connect_sta finished."); + return (ret_value == ESP_OK); } bool wifiConnected() @@ -592,6 +665,13 @@ void networkReconnectTask(void *pvParameters) void startReconnectTask() { +#ifdef MATTER_ENABLED + if (OperatingParameters.MatterStarted) + { + ESP_LOGW(TAG, "Network reconnect task -- Matter running ... Exiting"); + return; + } +#endif if (ntReconnectTaskHandler) { ESP_LOGE(TAG, "Network reconnect task already running ... Exiting"); From 3b5107f741af73aec259d7344d327f8e4479c442 Mon Sep 17 00:00:00 2001 From: Steve Meisner Date: Wed, 4 Oct 2023 21:39:23 -0400 Subject: [PATCH 03/10] Update .gitignore --- .gitignore | 2 ++ app/.gitignore | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b5ba8fb..1fb50dd 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ backups pcb/production/.nfs* *backup *.DONOTCOMPILE +*DO_NOT_COMPILE* +Matter/ \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore index e7a2c57..95034cf 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -4,4 +4,3 @@ .vscode/launch.json .vscode/ipch lib -Matter \ No newline at end of file From d0945784835122b6390ecb76ed839d3f6d521fbb Mon Sep 17 00:00:00 2001 From: Steve Meisner Date: Mon, 16 Oct 2023 10:24:59 -0400 Subject: [PATCH 04/10] 0.7 - Use friendly name; improve screen UI (device name) --- app/include/gpio_defs.hpp | 1 + app/include/thermostat.hpp | 26 +-- app/include/version.h | 2 +- app/smart-thermostat.code-workspace | 65 +++++++- app/src/eeprom.cpp | 44 ++++- app/src/indicators.cpp | 19 +++ app/src/main.cpp | 38 +++-- app/src/mqtt.cpp | 207 ++++++++++++++++++------ app/src/state_machine.cpp | 21 ++- app/src/tft.cpp | 44 +++-- app/src/ui/CMakeLists.txt | 3 +- app/src/ui/filelist.txt | 3 +- app/src/ui/screens/ui_DeviceName.c | 90 +++++++++++ app/src/ui/screens/ui_LessCommonSetup.c | 54 ++++++- app/src/ui/screens/ui_MqttConfig.c | 25 +-- app/src/ui/screens/ui_Setup.c | 53 ++++-- app/src/ui/screens/ui_WifiConfig.c | 2 +- app/src/ui/ui.c | 99 ++++++++++-- app/src/ui/ui.h | 34 +++- app/src/ui/ui_events.cpp | 104 ++++++++++-- app/src/ui/ui_events.h | 4 +- app/src/web.cpp | 3 +- app/src/wifi.cpp | 6 +- 23 files changed, 759 insertions(+), 188 deletions(-) create mode 100644 app/src/ui/screens/ui_DeviceName.c diff --git a/app/include/gpio_defs.hpp b/app/include/gpio_defs.hpp index a113fb9..3f37935 100644 --- a/app/include/gpio_defs.hpp +++ b/app/include/gpio_defs.hpp @@ -38,6 +38,7 @@ #define HVAC_FAN_PIN 4 #define HVAC_HEAT_PIN 5 #define HVAC_COOL_PIN 6 +#define HVAC_RVALV_PIN 7 #define BUZZER_PIN 17 #define MOTION_PIN 18 #define LIGHT_SENS_PIN 8 diff --git a/app/include/thermostat.hpp b/app/include/thermostat.hpp index 5186133..875842d 100644 --- a/app/include/thermostat.hpp +++ b/app/include/thermostat.hpp @@ -17,7 +17,6 @@ #define LOW 0 - ///////////////////////////////////////////////////////////////////// // Shared data structures ///////////////////////////////////////////////////////////////////// @@ -28,7 +27,7 @@ typedef enum AUTO, HEAT, COOL, - FAN, + FAN_ONLY, AUX_HEAT, ERROR, IDLE @@ -37,6 +36,10 @@ typedef enum typedef struct { + // FriendlyName and DeviceName must be + // the same size due to copy operation + // in ui_events.cpp, saveDeviceName() + char FriendlyName[32]; char DeviceName[32]; uint8_t mac[6]; HVAC_MODE hvacOpMode; @@ -66,13 +69,13 @@ typedef struct #ifdef MQTT_ENABLED bool MqttEnabled; - bool MqttStarted; + // bool MqttStarted; bool MqttConnected; - char *MqttBrokerHost; + char MqttBrokerHost[32]; uint16_t MqttBrokerPort; - char *MqttBrokerUsername; - char *MqttBrokerPassword; - void *MqttClient; + char MqttBrokerUsername[32]; + char MqttBrokerPassword[72]; + void *MqttClient; // Used during MQTT publish #endif #ifdef MATTER_ENABLED @@ -86,7 +89,7 @@ typedef struct typedef struct { - char hostname[24]; + // char hostname[24]; ...replaced by OperatingParameters.DeviceName char ssid[24]; char password[16]; @@ -144,7 +147,9 @@ bool MatterInit(); #ifdef MQTT_ENABLED void MqttInit(); +bool MqttConnect(); void MqttUpdateStatusTopic(); +void MqttHomeAssistantDiscovery(); #endif // State Machine @@ -183,6 +188,9 @@ void tftCreateTask(); HVAC_MODE strToHvacMode(char *mode); HVAC_MODE convertSelectedHvacMode(); void setHvacModesDropdown(); +#ifdef MQTT_ENABLED +const char *hvacModeToMqttCurrMode(HVAC_MODE mode); +#endif const char *hvacModeToString(HVAC_MODE mode); extern volatile bool tftMotionTrigger; @@ -213,7 +221,7 @@ float getRoundedFrac(float value); // float degFtoC(float degF); void resetTempSmooth(); bool sensorsInit(); -void testToggleRelays(); +void initRelays(); int getTemp(); int getHumidity(); void ld2410_loop(); diff --git a/app/include/version.h b/app/include/version.h index 6c46eaa..632749a 100644 --- a/app/include/version.h +++ b/app/include/version.h @@ -1,6 +1,6 @@ #define VERSION_MAJOR 0 -#define VERSION_MINOR 6 +#define VERSION_MINOR 7 #define VERSION_BUILD 0 #define VERSION_BUILD_DATE __DATE__ diff --git a/app/smart-thermostat.code-workspace b/app/smart-thermostat.code-workspace index 2fbfdb3..2299493 100644 --- a/app/smart-thermostat.code-workspace +++ b/app/smart-thermostat.code-workspace @@ -5,5 +5,68 @@ "path": "." } ], - "settings": {} + "settings": { + "files.associations": { + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "chrono": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "compare": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "string": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "netfwd": "cpp", + "numeric": "cpp", + "random": "cpp", + "ratio": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "istream": "cpp", + "limits": "cpp", + "mutex": "cpp", + "new": "cpp", + "numbers": "cpp", + "ostream": "cpp", + "semaphore": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "stop_token": "cpp", + "streambuf": "cpp", + "thread": "cpp", + "cinttypes": "cpp", + "typeinfo": "cpp" + } + } } \ No newline at end of file diff --git a/app/src/eeprom.cpp b/app/src/eeprom.cpp index 7643182..30fe290 100644 --- a/app/src/eeprom.cpp +++ b/app/src/eeprom.cpp @@ -14,6 +14,8 @@ * History * 17-Aug-2023: Steve Meisner (steve@meisners.net) - Initial version * 30-Aug-2023: Steve Meisner (steve@meisners.net) - Rewrote to support ESP-IDF framework instead of Arduino + * 11-Oct-2023: Steve Meisner (steve@meisners.net) - Add suport for home automation (MQTT & Matter) + * 16-Oct-2023: Steve Meisner (steve@meisners.net) - Add support for friendly names & saving MQTT broker info * */ @@ -40,6 +42,11 @@ #define DEF_SLEEP_TIME 30 #define DEF_TZ_SEL 15 #define DEF_BEEP_ENABLE true +#define DEF_MQTT_ENABLE false +#define DEF_MQTT_BROKER "mqtt" +#define DEF_MQTT_USER "mqtt" +#define DEF_MQTT_PASS "mqtt" +#define DEF_MQTT_PORT 1883 #define DEF_MATTER_ENABLE false //@@@ @@ -285,6 +292,7 @@ void setDefaultThermostatParams() ESP_LOGE(TAG, "Failed to open handle to NVS partition"); return; } + strncpy (OperatingParameters.FriendlyName, "Thermostat", sizeof(OperatingParameters.FriendlyName)); nvs_writeMode(my_handle, "currMode", DEF_CURR_MODE); nvs_writeMode(my_handle, "setMode", DEF_SET_MODE); nvs_writeFloat(my_handle, "setTemp", DEF_SET_TEMP); @@ -299,6 +307,13 @@ void setDefaultThermostatParams() nvs_writeInt16(my_handle, "sleepTime", DEF_SLEEP_TIME); nvs_writeInt16(my_handle, "timezoneSel", DEF_TZ_SEL); nvs_writeBool(my_handle, "Beep", DEF_BEEP_ENABLE); +#ifdef MQTT_ENABLED + nvs_writeBool(my_handle, "MqttEn", DEF_MQTT_ENABLE); + nvs_writeString(my_handle, "MqttBroker", DEF_MQTT_BROKER); + nvs_writeString(my_handle, "MqttUsername", DEF_MQTT_USER); + nvs_writeString(my_handle, "MqttPassword", DEF_MQTT_PASS); + nvs_writeInt16(my_handle, "MqttBrokerPort", DEF_MQTT_PORT); +#endif #ifdef MATTER_ENABLED nvs_writeBool(my_handle, "MatterEn", DEF_MATTER_ENABLE); #endif @@ -319,6 +334,13 @@ void setDefaultThermostatParams() OperatingParameters.thermostatSleepTime = DEF_SLEEP_TIME; OperatingParameters.timezone_sel = DEF_TZ_SEL; OperatingParameters.thermostatBeepEnable = DEF_BEEP_ENABLE; +#ifdef MQTT_ENABLED + OperatingParameters.MqttEnabled = DEF_MQTT_ENABLE; + strncpy (OperatingParameters.MqttBrokerHost, DEF_MQTT_BROKER, sizeof(OperatingParameters.MqttBrokerHost)); + strncpy (OperatingParameters.MqttBrokerUsername, DEF_MQTT_USER, sizeof(OperatingParameters.MqttBrokerUsername)); + strncpy (OperatingParameters.MqttBrokerPassword, DEF_MQTT_PASS, sizeof(OperatingParameters.MqttBrokerPassword)); + OperatingParameters.MqttBrokerPort = DEF_MQTT_PORT; +#endif #ifdef MATTER_ENABLED OperatingParameters.MatterEnabled = DEF_MATTER_ENABLE; #endif @@ -329,6 +351,7 @@ void updateThermostatParams() nvs_handle_t my_handle; ESP_LOGI(TAG, "Updating Thermostat parameters in NVS"); openNVS(&my_handle, NVS_TAG); + nvs_writeString(my_handle, "friendlyname", OperatingParameters.FriendlyName); nvs_writeMode(my_handle, "currMode", OperatingParameters.hvacOpMode); nvs_writeMode(my_handle, "setMode", OperatingParameters.hvacSetMode); nvs_writeFloat(my_handle, "setTemp", OperatingParameters.tempSet); @@ -343,6 +366,13 @@ void updateThermostatParams() nvs_writeInt16(my_handle, "sleepTime", OperatingParameters.thermostatSleepTime); nvs_writeInt16(my_handle, "timezoneSel", OperatingParameters.timezone_sel); nvs_writeBool(my_handle, "Beep", OperatingParameters.thermostatBeepEnable); +#ifdef MQTT_ENABLED + nvs_writeBool(my_handle, "MqttEn", &OperatingParameters.MqttEnabled); + nvs_writeString(my_handle, "MqttBroker", OperatingParameters.MqttBrokerHost); + nvs_writeString(my_handle, "MqttUsername", OperatingParameters.MqttBrokerUsername); + nvs_writeString(my_handle, "MqttPassword", OperatingParameters.MqttBrokerPassword); + nvs_writeInt16(my_handle, "MqttBrokerPort", OperatingParameters.MqttBrokerPort); +#endif #ifdef MATTER_ENABLED nvs_writeBool(my_handle, "MatterEn", &OperatingParameters.MatterEnabled); #endif @@ -360,6 +390,7 @@ void getThermostatParams() return; } + nvs_readStr(my_handle, "friendlyname", "Thermostat", OperatingParameters.FriendlyName, sizeof(OperatingParameters.FriendlyName)); nvs_readMode(my_handle, "currMode", &OperatingParameters.hvacOpMode, DEF_CURR_MODE); nvs_readMode(my_handle, "setMode", &OperatingParameters.hvacSetMode, DEF_SET_MODE); nvs_readFloat(my_handle, "setTemp", &OperatingParameters.tempSet, DEF_SET_TEMP); @@ -375,6 +406,13 @@ void getThermostatParams() nvs_readInt16(my_handle, "timezoneSel", &OperatingParameters.timezone_sel, DEF_TZ_SEL); OperatingParameters.timezone = (char *)gmt_timezones[OperatingParameters.timezone_sel]; nvs_readBool(my_handle, "Beep", &OperatingParameters.thermostatBeepEnable, DEF_BEEP_ENABLE); +#ifdef MQTT_ENABLED + nvs_readBool(my_handle, "MqttEn", &OperatingParameters.MqttEnabled, DEF_MQTT_ENABLE); + nvs_readStr(my_handle, "MqttBroker", DEF_MQTT_BROKER, OperatingParameters.MqttBrokerHost, sizeof(OperatingParameters.MqttBrokerHost)); + nvs_readStr(my_handle, "MqttUsername", DEF_MQTT_USER, OperatingParameters.MqttBrokerUsername, sizeof(OperatingParameters.MqttBrokerUsername)); + nvs_readStr(my_handle, "MqttPassword", DEF_MQTT_PASS, OperatingParameters.MqttBrokerPassword, sizeof(OperatingParameters.MqttBrokerPassword)); + nvs_readInt16(my_handle, "MqttBrokerPort", &OperatingParameters.MqttBrokerPort, DEF_MQTT_PORT); +#endif #ifdef MATTER_ENABLED nvs_readBool(my_handle, "MatterEn", &OperatingParameters.MatterEnabled, DEF_MATTER_ENABLE); #endif @@ -414,7 +452,7 @@ void setDefaultWifiCreds() nvs_writeString(my_handle, "pass", ""); closeNVS(my_handle); - strncpy (WifiCreds.hostname, "thermostat", sizeof(WifiCreds.hostname)); + strncpy (OperatingParameters.DeviceName, "thermostat", sizeof(OperatingParameters.DeviceName)); strncpy (WifiCreds.ssid, "", sizeof(WifiCreds.ssid)); strncpy (WifiCreds.password, "", sizeof(WifiCreds.password)); } @@ -428,7 +466,7 @@ void setWifiCreds() // printf ("*** [setWifiCreds] WifiCreds.password = %s\n", WifiCreds.password); nvs_handle_t my_handle; openNVS(&my_handle, NVS_WIFI_TAG); - nvs_writeString(my_handle, "hostname", WifiCreds.hostname); + nvs_writeString(my_handle, "hostname", OperatingParameters.DeviceName); nvs_writeString(my_handle, "ssid", WifiCreds.ssid); nvs_writeString(my_handle, "pass", WifiCreds.password); closeNVS(my_handle); @@ -444,7 +482,7 @@ void getWifiCreds() if (!openNVS(&my_handle, NVS_WIFI_TAG)) return; } - nvs_readStr(my_handle, "hostname", "thermostat", WifiCreds.hostname, sizeof(WifiCreds.hostname)); + nvs_readStr(my_handle, "hostname", "thermostat", OperatingParameters.DeviceName, sizeof(OperatingParameters.DeviceName)); nvs_readStr(my_handle, "ssid", "", WifiCreds.ssid, sizeof(WifiCreds.ssid)); nvs_readStr(my_handle, "pass", "", WifiCreds.password, sizeof(WifiCreds.password)); // printf ("*** [getWifiCreds] WifiCreds.password = %s\n", WifiCreds.password); diff --git a/app/src/indicators.cpp b/app/src/indicators.cpp index 74331f1..af80255 100644 --- a/app/src/indicators.cpp +++ b/app/src/indicators.cpp @@ -12,6 +12,7 @@ * History * 17-Aug-2023: Steve Meisner (steve@meisners.net) - Initial version * 30-Aug-2023: Steve Meisner (steve@meisners.net) - Rewrote to support ESP-IDF framework instead of Arduino + * 16-Oct-2023: Steve Meisner (steve@meisners.net) - Init relay pins for output * */ @@ -116,6 +117,24 @@ void audioBeep() // gpio_config(&io_conf); // } +void initRelays() +{ + vTaskDelay(pdMS_TO_TICKS(500)); + + gpio_reset_pin((gpio_num_t)HVAC_HEAT_PIN); + gpio_set_direction((gpio_num_t)HVAC_HEAT_PIN, GPIO_MODE_OUTPUT); + + gpio_reset_pin((gpio_num_t)HVAC_COOL_PIN); + gpio_set_direction((gpio_num_t)HVAC_COOL_PIN, GPIO_MODE_OUTPUT); + + gpio_reset_pin((gpio_num_t)HVAC_FAN_PIN); + gpio_set_direction((gpio_num_t)HVAC_FAN_PIN, GPIO_MODE_OUTPUT); + + gpio_reset_pin((gpio_num_t)HVAC_RVALV_PIN); + gpio_set_direction((gpio_num_t)HVAC_RVALV_PIN, GPIO_MODE_OUTPUT); +} + + void indicatorsInit() { gpio_reset_pin((gpio_num_t)LED_HEAT_PIN); diff --git a/app/src/main.cpp b/app/src/main.cpp index a249d18..e2c9c0d 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -13,39 +13,44 @@ * History * 17-Aug-2023: Steve Meisner (steve@meisners.net) - Initial version * 30-Aug-2023: Steve Meisner (steve@meisners.net) - Rewrote to support ESP-IDF framework instead of Arduino + * 11-Oct-2023: Steve Meisner (steve@meisners.net) - Add suport for home automation (MQTT & Matter) + * 16-Oct-2023: Steve Meisner (steve@meisners.net) - Add restriction for enabling both MQTT & Matter & removed printf's * */ +#if defined(MATTER_ENABLED) && defined(MQTT_ENABLED) + #error "Do not enable Matter/CHIP and MQTT at the same time" +#endif + #include "thermostat.hpp" #include "esp_timer.h" int32_t millis() { return esp_timer_get_time() / 1000;} +#define TAG "Main" void app_main() { - printf ("IDF version: %s\n", esp_get_idf_version()); - printf ("- Free memory: %d bytes\n", esp_get_free_heap_size()); + ESP_LOGI (TAG, "IDF version: %s", esp_get_idf_version()); + ESP_LOGD (TAG, "- Free memory: %d bytes", esp_get_free_heap_size()); // Load configuration from EEPROM - printf ("Reading EEPROM\n"); + ESP_LOGI (TAG, "Reading EEPROM"); eepromInit(); - strcpy (OperatingParameters.DeviceName, "BasementTest"); - // Initialize the TFT display - printf ("Initializing TFT\n"); + ESP_LOGI (TAG, "Initializing TFT"); tftInit(); // Create the RTOS task to drive the touchscreen - printf ("Starting TFT task\n"); + ESP_LOGI (TAG, "Starting TFT task"); tftCreateTask(); #ifdef MATTER_ENABLED // Start Matter - printf ("Starting Matter\n"); + ESP_LOGI (TAG, "Starting Matter"); OperatingParameters.MatterStarted = MatterInit(); #endif // Start wifi - printf ("Starting wifi (\"%s\", \"%s\")\n", WifiCreds.ssid, WifiCreds.password); + ESP_LOGI (TAG, "Starting wifi (\"%s\", \"%s\")", WifiCreds.ssid, WifiCreds.password); OperatingParameters.wifiConnected = // wifiStart(WifiCreds.hostname, WifiCreds.ssid, WifiCreds.password); wifiStart(OperatingParameters.DeviceName, WifiCreds.ssid, WifiCreds.password); @@ -53,27 +58,28 @@ void app_main() #ifdef MQTT_ENABLED // Start Matter - printf ("Starting MQTT\n"); + ESP_LOGI (TAG, "Starting MQTT"); MqttInit(); #endif // Initialize indicators (relays, LEDs, buzzer) - printf ("Initializing indicators\n"); + ESP_LOGI (TAG, "Initializing indicators"); indicatorsInit(); + initRelays(); // Initialize sensors (temp, humidity, motion, etc) - printf ("Initializing sensors\n"); + ESP_LOGI (TAG, "Initializing sensors"); sensorsInit(); // Create the RTOS task to drive the state machine - printf ("Starting state machine task\n"); + ESP_LOGI (TAG, "Starting state machine task"); stateCreateTask(); // Start web server - // printf ("Starting web server\n"); + ESP_LOGI (TAG, "Starting web server"); webStart(); // Play the startup sound audioStartupBeep(); - printf ("Startup done\n"); -} \ No newline at end of file + ESP_LOGI (TAG, "Startup done"); +} diff --git a/app/src/mqtt.cpp b/app/src/mqtt.cpp index 2428177..c2ada4a 100644 --- a/app/src/mqtt.cpp +++ b/app/src/mqtt.cpp @@ -1,5 +1,23 @@ #ifdef MQTT_ENABLED +// SPDX-License-Identifier: GPL-3.0-only +/* + * mqtt.cpp + * + * Implement support for MQTT and Home Assistant. This module connects to the MQTT broker + * (usually running as part of Home Assistant) and provides a discovery MQTT publish. Then + * periodically, provide status updates via MQTT publishes. + * + * Copyright (c) 2023 Steve Meisner (steve@meisners.net) + * + * Notes: + * + * History + * 11-Oct-2023: Steve Meisner (steve@meisners.net) - Initial version + * 16-Oct-2023: Steve Meisner (steve@meisners.net) - Add support for friendly name & many operational improvements + * + */ + #include // for string class #include "thermostat.hpp" #include "version.h" @@ -17,6 +35,7 @@ const char* g_deviceModel = "Truly Smart Thermostat"; // const char* g_swVersion = VERSION_STRING; // Firmware Version const char* g_manufacturer = "Steve Meisner"; // Manufacturer Name std::string g_deviceName; // = OperatingParameters.DeviceName; // Device Name +std::string g_friendlyName; std::string g_mqttStatusTopic; // = "SmartThermostat/" + g_deviceName; // MQTT Topic struct CustomWriter { @@ -73,8 +92,8 @@ static void MqttEventHandler(void* handler_args, esp_event_base_t base, int32_t break; case MQTT_EVENT_DATA: ESP_LOGI(TAG, "MQTT_EVENT_DATA"); - printf("TOPIC=%.*s\r\n", event->topic_len, event->topic); - printf("DATA=%.*s\r\n", event->data_len, event->data); + ESP_LOGI(TAG, "TOPIC=%.*s\r\n", event->topic_len, event->topic); + ESP_LOGI(TAG, "DATA=%.*s\r\n", event->data_len, event->data); if (strstr(event->topic, "mode")) { char m[event->data_len + 1]; @@ -82,12 +101,40 @@ static void MqttEventHandler(void* handler_args, esp_event_base_t base, int32_t m[event->data_len] = '\0'; // Make first letter uppercase to match our string representation m[0] = toupper(m[0]); - printf ("Looking up %s\n", m); + ESP_LOGI(TAG, "Looking up %s\n", m); updateHvacMode (strToHvacMode(m)); } if (strstr(event->topic, "temp")) { - updateHvacSetTemp (atof(event->data)); + if (strlen(event->data) > 0 && atof(event->data) != 0) + { + updateHvacSetTemp (atof(event->data)); + } + else + { + ESP_LOGE(TAG, "Received invalid string for set temp: \"%s\"\n", event->data); + } + } + if (strstr(event->topic, "fan")) + { + if (strlen(event->data) > 0) + { + if (strncmp("on", event->data, event->data_len) == 0) + { + updateHvacMode (FAN_ONLY); + } + else + { + if (OperatingParameters.hvacOpMode == FAN_ONLY) + { + updateHvacMode (OFF); + } + } + } + else + { + ESP_LOGE(TAG, "Received invalid string for set mode: \"%s\"\n", event->data); + } } break; case MQTT_EVENT_ERROR: @@ -97,7 +144,7 @@ static void MqttEventHandler(void* handler_args, esp_event_base_t base, int32_t } } -void MqttPublish(const char *topic, const char *payload) +void MqttPublish(const char *topic, const char *payload, bool retain) { int msg_id; if (!OperatingParameters.MqttConnected) @@ -106,7 +153,7 @@ void MqttPublish(const char *topic, const char *payload) return; } msg_id = esp_mqtt_client_publish( - (esp_mqtt_client_handle_t)(OperatingParameters.MqttClient), topic, payload, 0, 0, 0); + (esp_mqtt_client_handle_t)(OperatingParameters.MqttClient), topic, payload, 0, 0, (retain ? 1 : 0)); ESP_LOGV(TAG, "Sent MQTT publish -- msg_id=%d", msg_id); xEventGroupSetBits(s_mqtt_event_group, MQTT_EVENT_PUB_BIT); } @@ -126,23 +173,43 @@ void MqttUpdateStatusTopic() if (OperatingParameters.MqttEnabled && OperatingParameters.MqttConnected) { std::string mode = hvacModeToString(OperatingParameters.hvacSetMode); + std::string curr_mode = hvacModeToMqttCurrMode(OperatingParameters.hvacOpMode); StaticJsonDocument<200> payload; // payload["inputstatus"] = "ON"; - payload["Humidity"] = OperatingParameters.humidCurrent + OperatingParameters.humidityCorrection; - payload["Temperature"] = OperatingParameters.tempCurrent + OperatingParameters.tempCorrection; + std::string hum(16, '\0'); + auto written = std::snprintf(&hum[0], hum.size(), "%.2f", (OperatingParameters.humidCurrent + OperatingParameters.humidityCorrection)); + hum.resize(written); + payload["Humidity"] = hum; + // payload["Humidity"] = OperatingParameters.humidCurrent + OperatingParameters.humidityCorrection; + std::string temp(16, '\0'); + written = std::snprintf(&temp[0], temp.size(), "%.2f", (OperatingParameters.tempCurrent + OperatingParameters.tempCorrection)); + temp.resize(written); + payload["Temperature"] = temp; + // payload["Temperature"] = OperatingParameters.tempCurrent + OperatingParameters.tempCorrection; + //@@@ Should the following line be part of an "else" for the next "if" statement??? payload["Setpoint"] = OperatingParameters.tempSet; + makeLower(mode.c_str()); payload["Mode"] = mode; + makeLower(curr_mode.c_str()); + payload["CurrMode"] = curr_mode; + + if (OperatingParameters.hvacSetMode == AUTO) + { + payload["LowSetpoint"] = OperatingParameters.tempSetAutoMin; + payload["HighSetpoint"] = OperatingParameters.tempSetAutoMax; + } + std::string strPayload; serializeJson(payload, strPayload); ESP_LOGI (TAG, "%s", strPayload.c_str()); std::string topic; - topic = g_mqttStatusTopic + "/status"; + topic = g_mqttStatusTopic; // if(g_mqttPubSub.connected()) // { - MqttPublish(topic.c_str(), strPayload.c_str()); + MqttPublish(topic.c_str(), strPayload.c_str(), false); // } } } @@ -156,6 +223,15 @@ void MqttHomeAssistantDiscovery() std::string payload; std::string strPayload; + // printf ("Status of MQTT connectedion: %s\n", (g_mqttPubSub.connected() ? "Connected" : "NOT Connected")); + + if (!OperatingParameters.MqttEnabled || !OperatingParameters.MqttConnected) + // if (!OperatingParameters.MqttEnabled || !OperatingParameters.MqttStarted) + { + ESP_LOGE(TAG, "MQTT not enabled or not connected!"); + return; + } + // if(g_mqttPubSub.connected()) { ESP_LOGI(TAG, "Send Home Assistant Discovery..."); @@ -182,7 +258,7 @@ void MqttHomeAssistantDiscovery() // printf ("Mac: %s\n", mac); // payload["name"] = g_deviceName + ".temp"; - payload["name"] = g_deviceName; + payload["name"] = ""; //@@@g_friendlyName; // payload["uniq_id"] = UniqueId + "_temp"; payload["uniq_id"] = mac; // payload["power_command_topic"] = g_deviceName + "/power/set"; @@ -191,21 +267,42 @@ void MqttHomeAssistantDiscovery() modes.add("off"); modes.add("heat"); if (OperatingParameters.hvacCoolEnable) + { modes.add("cool"); - if (OperatingParameters.hvacFanEnable) - modes.add("fan"); - if ((OperatingParameters.hvacCoolEnable) || (OperatingParameters.hvacFanEnable)) modes.add("auto"); + } + if (OperatingParameters.hvacFanEnable) + modes.add("fan_only"); + payload["~"] = g_mqttStatusTopic; + payload["act_t"] = "~"; + payload["act_tpl"] = "{{ value_json.CurrMode }}"; // payload["stat_t"] = g_mqttStatusTopic + "/temperature"; - payload["curr_temp_t"] = g_mqttStatusTopic + "/status"; + payload["curr_temp_t"] = "~"; payload["curr_temp_tpl"] = "{{ value_json.Temperature|float }}"; - payload["temp_stat_t"] = g_mqttStatusTopic + "/status"; + payload["temp_stat_t"] = "~"; payload["temp_stat_tpl"] = "{{ value_json.Setpoint }}"; - payload["mode_stat_t"] = g_mqttStatusTopic + "/status"; + payload["mode_stat_t"] = "~"; payload["mode_stat_tpl"] = "{{ value_json.Mode }}"; - payload["current_humidity_topic"] = g_mqttStatusTopic + "/status"; + payload["current_humidity_topic"] = "~"; payload["current_humidity_template"] = "{{ value_json.Humidity|float }}"; + if (OperatingParameters.hvacFanEnable) + { + payload["fan_mode_stat_t"] = "~"; + payload["fan_mode_stat_tpl"] = "{{ value_json.Mode }}"; + payload["fan_mode_cmd_t"] = g_deviceName + "/set/fan"; + modes = payload.createNestedArray("fan_modes"); + modes.add("off"); + modes.add("on"); + } + if (OperatingParameters.hvacCoolEnable) + { + // Auto is enabled, so we need to specify hi & lo temps + payload["temp_lo_stat_t"] = "~"; + payload["temp_lo_stat_tpl"] = "{{ value_json.LowSetpoint }}"; + payload["temp_hi_stat_t"] = "~"; + payload["temp_hi_stat_tpl"] = "{{ value_json.HighSetpoint }}"; + } payload["mode_cmd_t"] = g_deviceName + "/set/mode"; payload["temp_cmd_t"] = g_deviceName + "/set/temp"; @@ -216,10 +313,12 @@ void MqttHomeAssistantDiscovery() payload["temp_unit"] = &OperatingParameters.tempUnits; device = payload.createNestedObject("device"); - device["name"] = g_deviceName; - device["model"] = g_deviceModel; - device["sw_version"] = g_swVersion; - device["manufacturer"] = g_manufacturer; + device["name"] = g_friendlyName; + device["mdl"] = g_deviceModel; + device["sw"] = g_swVersion; + device["mf"] = g_manufacturer; + std::string ip = wifiAddress(); + device["cu"] = "http://" + ip; //@@@ Must be updated if dhcp address changes identifiers = device.createNestedArray("identifiers"); identifiers.add(mac); @@ -229,7 +328,7 @@ void MqttHomeAssistantDiscovery() ESP_LOGI (TAG, "Payload: %s", strPayload.c_str()); // g_mqttPubSub.publish(discoveryTopic.c_str(), strPayload.c_str()); - MqttPublish(discoveryTopic.c_str(), strPayload.c_str()); + MqttPublish(discoveryTopic.c_str(), strPayload.c_str(), true); EventBits_t bits = xEventGroupWaitBits(s_mqtt_event_group, MQTT_EVENT_PUB_BIT | MQTT_ERROR_BIT, @@ -272,7 +371,7 @@ void MqttHomeAssistantDiscovery() printf ("Payload: %s\n", strPayload.c_str()); // g_mqttPubSub.publish(discoveryTopic.c_str(), strPayload.c_str()); - MqttPublish(discoveryTopic.c_str(), strPayload.c_str()); + MqttPublish(discoveryTopic.c_str(), strPayload.c_str(), true); bits = xEventGroupWaitBits(s_mqtt_event_group, MQTT_EVENT_PUB_BIT | MQTT_ERROR_BIT, @@ -327,26 +426,34 @@ void MqttSubscribeTopic(esp_mqtt_client_handle_t client, std::string topic) } -static void MqttConnect(void) +bool MqttConnect(void) { ESP_LOGI(__FUNCTION__, "Waiting for MQTT..."); esp_mqtt_client_config_t mqtt_cfg; memset(&mqtt_cfg, 0, sizeof(esp_mqtt_client_config_t)); - OperatingParameters.MqttBrokerHost = (char *)malloc(64); - strcpy (OperatingParameters.MqttBrokerHost, "mqtt://hass.meisners.net:1883"); - OperatingParameters.MqttBrokerUsername = (char *)malloc(16); - strcpy (OperatingParameters.MqttBrokerUsername, "homeassistant"); - OperatingParameters.MqttBrokerPassword = (char *)malloc(72); - strcpy (OperatingParameters.MqttBrokerPassword, "einiiZeiphah4ish0Rowae7doh0OhNg6wahngohmie4iNae1meipainaeyijai5i"); - - printf ("Broker: %s\n", OperatingParameters.MqttBrokerHost); - printf ("Username: %s\n", OperatingParameters.MqttBrokerUsername); - printf ("Password: %s\n", OperatingParameters.MqttBrokerPassword); + // Build up the fully qualified MQTT URI host string + char port[16]; + snprintf (port, 15, "%d", OperatingParameters.MqttBrokerPort); + std::string _host = OperatingParameters.MqttBrokerHost; + std::string host = "mqtt://" + _host + ":" + port; + +//@@@ + // OperatingParameters.MqttBrokerHost = (char *)malloc(64); + // strcpy (OperatingParameters.MqttBrokerHost, "mqtt://hass.meisners.net:1883"); + // OperatingParameters.MqttBrokerUsername = (char *)malloc(16); + // strcpy (OperatingParameters.MqttBrokerUsername, "homeassistant"); + // OperatingParameters.MqttBrokerPassword = (char *)malloc(72); + // strcpy (OperatingParameters.MqttBrokerPassword, "einiiZeiphah4ish0Rowae7doh0OhNg6wahngohmie4iNae1meipainaeyijai5i"); + + ESP_LOGI(TAG, "FQDN Broker: %s\n", host.c_str()); + ESP_LOGI(TAG, "Broker: %s\n", OperatingParameters.MqttBrokerHost); + ESP_LOGI(TAG, "Username: %s\n", OperatingParameters.MqttBrokerUsername); + ESP_LOGI(TAG, "Password: %s\n", OperatingParameters.MqttBrokerPassword); // mqtt_cfg.broker.address.uri = "mqtt://iot.eclipse.org"; // mqtt_cfg.broker.address.uri = "mqtt://test.mosquitto.org:1883"; // mqtt_cfg.broker.address.transport = MQTT_TRANSPORT_OVER_TCP; - mqtt_cfg.broker.address.uri = OperatingParameters.MqttBrokerHost; + mqtt_cfg.broker.address.uri = host.c_str(); // mqtt_cfg.broker.address.hostname = "mqtt://homeassistant.meisners.net:1883"; // mqtt_cfg.broker.address.port = 1883; // mqtt_cfg.credentials.username = "mqtt"; @@ -378,7 +485,10 @@ static void MqttConnect(void) xTicksToWait); if (bits & MQTT_ERROR_BIT) + { ESP_LOGE (TAG, "MQTT Connect failed"); + return false; + } if (bits & MQTT_EVENT_CONNECTED_BIT) { @@ -387,6 +497,11 @@ static void MqttConnect(void) // MqttSubscribeTopic(client, g_deviceName + "/set/temp"); MqttSubscribeTopic(client, g_deviceName + "/set/#"); } + + // Send discovery packet to let all listeners know we have arrived + MqttHomeAssistantDiscovery(); + + return true; } //@@@ Need a reconnect function @@ -396,6 +511,13 @@ static void MqttConnect(void) void MqttInit() { + esp_log_level_set("*", ESP_LOG_INFO); + esp_log_level_set("MQTT_CLIENT", ESP_LOG_VERBOSE); + esp_log_level_set("TRANSPORT_TCP", ESP_LOG_VERBOSE); + esp_log_level_set("TRANSPORT_SSL", ESP_LOG_VERBOSE); + esp_log_level_set("TRANSPORT", ESP_LOG_VERBOSE); + esp_log_level_set("OUTBOX", ESP_LOG_VERBOSE); + if (!OperatingParameters.MqttEnabled) { ESP_LOGW(TAG, "MQTT is not enabled!"); @@ -408,21 +530,10 @@ void MqttInit() return; } - esp_log_level_set("*", ESP_LOG_INFO); - esp_log_level_set("MQTT_CLIENT", ESP_LOG_VERBOSE); - esp_log_level_set("TRANSPORT_TCP", ESP_LOG_VERBOSE); - esp_log_level_set("TRANSPORT_SSL", ESP_LOG_VERBOSE); - esp_log_level_set("TRANSPORT", ESP_LOG_VERBOSE); - esp_log_level_set("OUTBOX", ESP_LOG_VERBOSE); - g_deviceName = OperatingParameters.DeviceName; + g_friendlyName = OperatingParameters.FriendlyName; g_mqttStatusTopic = g_deviceName + "/status"; - MqttConnect(); - - MqttHomeAssistantDiscovery(); - - // MqttUpdateStatusTopic(); } #endif // #ifdef MQTT_ENABLED diff --git a/app/src/state_machine.cpp b/app/src/state_machine.cpp index 325a9f7..55576f9 100644 --- a/app/src/state_machine.cpp +++ b/app/src/state_machine.cpp @@ -9,10 +9,12 @@ * Copyright (c) 2023 Steve Meisner (steve@meisners.net) * * Notes: + * Need to add support for reversing valve (when aux heat enabled) * * History * 17-Aug-2023: Steve Meisner (steve@meisners.net) - Initial version * 30-Aug-2023: Steve Meisner (steve@meisners.net) - Rewrote to support ESP-IDF framework instead of Arduino + * 11-Oct-2023: Steve Meisner (steve@meisners.net) - Add suport for home automation (MQTT & Matter) * */ @@ -57,9 +59,9 @@ void stateMachine(void *parameter) gpio_set_level((gpio_num_t)LED_HEAT_PIN, LOW); gpio_set_level((gpio_num_t)LED_FAN_PIN, LOW); } - else if (OperatingParameters.hvacSetMode == FAN) + else if (OperatingParameters.hvacSetMode == FAN_ONLY) { - OperatingParameters.hvacOpMode = FAN; + OperatingParameters.hvacOpMode = FAN_ONLY; gpio_set_level((gpio_num_t)HVAC_HEAT_PIN, LOW); gpio_set_level((gpio_num_t)HVAC_COOL_PIN, LOW); gpio_set_level((gpio_num_t)HVAC_FAN_PIN, HIGH); @@ -172,7 +174,7 @@ void stateMachine(void *parameter) } } - if ((currentTemp >= minTemp) && (currentTemp <= maxTemp) && (OperatingParameters.hvacSetMode != FAN) && (OperatingParameters.hvacSetMode != OFF)) + if ((currentTemp >= minTemp) && (currentTemp <= maxTemp) && (OperatingParameters.hvacSetMode != FAN_ONLY) && (OperatingParameters.hvacSetMode != OFF)) { OperatingParameters.hvacOpMode = IDLE; gpio_set_level((gpio_num_t)HVAC_HEAT_PIN, LOW); @@ -194,7 +196,9 @@ void stateMachine(void *parameter) #ifdef MQTT_ENABLED if ((!OperatingParameters.MqttConnected) && (OperatingParameters.MqttEnabled) && (OperatingParameters.wifiConnected)) - MqttInit(); + // MqttInit(); + //@@@ Should be a "reconnect" + MqttConnect(); #endif // Check wifi @@ -260,19 +264,12 @@ void stateCreateTask() xTaskCreate( stateMachine, "State Machine", - 4096, + 8192, NULL, tskIDLE_PRIORITY - 1, NULL); } -void testToggleRelays() -{ - vTaskDelay(pdMS_TO_TICKS(500)); - gpio_reset_pin((gpio_num_t)HVAC_HEAT_PIN); - gpio_set_direction((gpio_num_t)HVAC_HEAT_PIN, GPIO_MODE_OUTPUT); -} - void serialStart() { // diff --git a/app/src/tft.cpp b/app/src/tft.cpp index d45e938..4026b83 100644 --- a/app/src/tft.cpp +++ b/app/src/tft.cpp @@ -20,6 +20,7 @@ * History * 17-Aug-2023: Steve Meisner (steve@meisners.net) - Initial version * 30-Aug-2023: Steve Meisner (steve@meisners.net) - Rewrote to support ESP-IDF framework instead of Arduino + * 11-Oct-2023: Steve Meisner (steve@meisners.net) - Add suport for home automation (MQTT & Matter) * */ @@ -164,23 +165,40 @@ void tftUpdateDisplay() switch (OperatingParameters.hvacOpMode) { // Set color of inner circle representing the operating mode - case HEAT: lv_obj_set_style_bg_color(ui_SetTempBg, lv_color_hex(0xa00b0b), LV_PART_MAIN); break; - case COOL: lv_obj_set_style_bg_color(ui_SetTempBg, lv_color_hex(0x435deb), LV_PART_MAIN); break; - case FAN: lv_obj_set_style_bg_color(ui_SetTempBg, lv_color_hex(0x3c8945), LV_PART_MAIN); break; //@@@ - default: lv_obj_set_style_bg_color(ui_SetTempBg, lv_color_hex(0x7a92b2), LV_PART_MAIN); break; + case HEAT: lv_obj_set_style_bg_color(ui_SetTempBg, lv_color_hex(0xa00b0b), LV_PART_MAIN); break; + case COOL: lv_obj_set_style_bg_color(ui_SetTempBg, lv_color_hex(0x435deb), LV_PART_MAIN); break; + case FAN_ONLY: lv_obj_set_style_bg_color(ui_SetTempBg, lv_color_hex(0x3c8945), LV_PART_MAIN); break; //@@@ + default: lv_obj_set_style_bg_color(ui_SetTempBg, lv_color_hex(0x7a92b2), LV_PART_MAIN); break; } switch (OperatingParameters.hvacSetMode) { // Set color of outer circle representing the enabled or set mode case AUX_HEAT: - case HEAT: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0xc71b1b), LV_PART_MAIN); break; - case COOL: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0x1b7dc7), LV_PART_MAIN); break; - case FAN: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0x23562b), LV_PART_MAIN); break; //@@@ - case AUTO: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0xaeac40), LV_PART_MAIN); break; - default: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0x7d7d7d), LV_PART_MAIN); break; + case HEAT: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0xc71b1b), LV_PART_MAIN); break; + case COOL: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0x1b7dc7), LV_PART_MAIN); break; + case FAN_ONLY: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0x23562b), LV_PART_MAIN); break; //@@@ + case AUTO: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0xaeac40), LV_PART_MAIN); break; + default: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0x7d7d7d), LV_PART_MAIN); break; } } +#ifdef MQTT_ENABLED +const char *hvacModeToMqttCurrMode(HVAC_MODE mode) +{ + switch (mode) + { + case OFF: return "off"; + case IDLE: return "idle"; + case AUTO: return "auto"; + case HEAT: return "heating"; + case COOL: return "cooling"; + case FAN_ONLY: return "Fan_only"; + case AUX_HEAT: return "Aux Heat"; + default: return "Error"; + } +} +#endif + const char *hvacModeToString(HVAC_MODE mode) { switch (mode) @@ -190,7 +208,7 @@ const char *hvacModeToString(HVAC_MODE mode) case AUTO: return "Auto"; case HEAT: return "Heat"; case COOL: return "Cool"; - case FAN: return "Fan"; + case FAN_ONLY: return "Fan_only"; case AUX_HEAT: return "Aux Heat"; default: return "Error"; } @@ -217,7 +235,7 @@ HVAC_MODE convertSelectedHvacMode() // Check to see if the selected HVAC mode is now disabled (after config menu) if ((OperatingParameters.hvacSetMode == AUTO) && !OperatingParameters.hvacCoolEnable) updateHvacMode(OFF); - if ((OperatingParameters.hvacSetMode == FAN) && !OperatingParameters.hvacFanEnable) + if ((OperatingParameters.hvacSetMode == FAN_ONLY) && !OperatingParameters.hvacFanEnable) updateHvacMode(OFF); if ((OperatingParameters.hvacSetMode == COOL) && !OperatingParameters.hvacCoolEnable) updateHvacMode(OFF); @@ -251,7 +269,7 @@ void setHvacModesDropdown() { if ((n == AUTO) && !OperatingParameters.hvacCoolEnable) continue; - if ((n == FAN) && !OperatingParameters.hvacFanEnable) + if ((n == FAN_ONLY) && !OperatingParameters.hvacFanEnable) continue; if ((n == COOL) && !OperatingParameters.hvacCoolEnable) continue; @@ -426,7 +444,7 @@ void tftCreateTask() xTaskCreate ( tftPump, "Touch Screen UI", - 4096, + 8192, NULL, tskIDLE_PRIORITY+1, &xTouchUIHandle diff --git a/app/src/ui/CMakeLists.txt b/app/src/ui/CMakeLists.txt index f2a8b99..ce4fbdf 100644 --- a/app/src/ui/CMakeLists.txt +++ b/app/src/ui/CMakeLists.txt @@ -4,8 +4,9 @@ SET(SOURCES screens/ui_MainScreen.c screens/ui_LessCommonSetup.c screens/ui_WifiConfig.c screens/ui_MatterConfig.c - screens/ui_ThermostatRestart.c screens/ui_MqttConfig.c + screens/ui_DeviceName.c + screens/ui_ThermostatRestart.c ui.c components/ui_comp_hook.c ui_helpers.c) diff --git a/app/src/ui/filelist.txt b/app/src/ui/filelist.txt index 4cf773e..6f6b664 100644 --- a/app/src/ui/filelist.txt +++ b/app/src/ui/filelist.txt @@ -4,8 +4,9 @@ screens/ui_Setup.c screens/ui_LessCommonSetup.c screens/ui_WifiConfig.c screens/ui_MatterConfig.c -screens/ui_ThermostatRestart.c screens/ui_MqttConfig.c +screens/ui_DeviceName.c +screens/ui_ThermostatRestart.c ui.c components/ui_comp_hook.c ui_helpers.c diff --git a/app/src/ui/screens/ui_DeviceName.c b/app/src/ui/screens/ui_DeviceName.c new file mode 100644 index 0000000..fa3555f --- /dev/null +++ b/app/src/ui/screens/ui_DeviceName.c @@ -0,0 +1,90 @@ +// This file was generated by SquareLine Studio +// SquareLine Studio version: SquareLine Studio 1.3.2 +// LVGL version: 8.3.6 +// Project name: Thermostat + +#include "../ui.h" + +void ui_DeviceName_screen_init(void) +{ +ui_DeviceName = lv_obj_create(NULL); +lv_obj_clear_flag( ui_DeviceName, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM ); /// Flags +lv_obj_set_scrollbar_mode(ui_DeviceName, LV_SCROLLBAR_MODE_OFF); +lv_obj_set_style_bg_color(ui_DeviceName, lv_color_hex(0xB787E2), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_DeviceName, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_DeviceName, lv_color_hex(0xBE5757), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_DeviceName, LV_GRAD_DIR_HOR, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_DevNameKeyboard = lv_keyboard_create(ui_DeviceName); +lv_obj_set_width( ui_DevNameKeyboard, 320); +lv_obj_set_height( ui_DevNameKeyboard, 148); +lv_obj_set_x( ui_DevNameKeyboard, 0 ); +lv_obj_set_y( ui_DevNameKeyboard, 46 ); +lv_obj_set_align( ui_DevNameKeyboard, LV_ALIGN_LEFT_MID ); +lv_obj_set_style_bg_color(ui_DevNameKeyboard, lv_color_hex(0xBD6994), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_DevNameKeyboard, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_DeviceHostname = lv_textarea_create(ui_DeviceName); +lv_obj_set_width( ui_DeviceHostname, 205); +lv_obj_set_height( ui_DeviceHostname, LV_SIZE_CONTENT); /// 20 +lv_obj_set_x( ui_DeviceHostname, -50 ); +lv_obj_set_y( ui_DeviceHostname, -97 ); +lv_obj_set_align( ui_DeviceHostname, LV_ALIGN_CENTER ); +lv_textarea_set_placeholder_text(ui_DeviceHostname,"Device Name"); +lv_textarea_set_one_line(ui_DeviceHostname,true); +lv_obj_set_style_text_font(ui_DeviceHostname, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); + + + +ui_DevNameSaveBtn = lv_btn_create(ui_DeviceName); +lv_obj_set_width( ui_DevNameSaveBtn, 100); +lv_obj_set_height( ui_DevNameSaveBtn, 36); +lv_obj_set_x( ui_DevNameSaveBtn, -1 ); +lv_obj_set_y( ui_DevNameSaveBtn, -56 ); +lv_obj_set_align( ui_DevNameSaveBtn, LV_ALIGN_RIGHT_MID ); +lv_obj_add_flag( ui_DevNameSaveBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_DevNameSaveBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_DevNameSaveBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_DevNameSaveBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_DevNameSaveBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_DevNameSaveBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_DevNameSaveLabel = lv_label_create(ui_DeviceName); +lv_obj_set_width( ui_DevNameSaveLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_DevNameSaveLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_DevNameSaveLabel, 109 ); +lv_obj_set_y( ui_DevNameSaveLabel, -56 ); +lv_obj_set_align( ui_DevNameSaveLabel, LV_ALIGN_CENTER ); +lv_label_set_text(ui_DevNameSaveLabel,"Save"); +lv_obj_set_style_text_color(ui_DevNameSaveLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_DevNameSaveLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_DevNameCancelBtn = lv_btn_create(ui_DeviceName); +lv_obj_set_width( ui_DevNameCancelBtn, 100); +lv_obj_set_height( ui_DevNameCancelBtn, 36); +lv_obj_set_x( ui_DevNameCancelBtn, -1 ); +lv_obj_set_y( ui_DevNameCancelBtn, -96 ); +lv_obj_set_align( ui_DevNameCancelBtn, LV_ALIGN_RIGHT_MID ); +lv_obj_add_flag( ui_DevNameCancelBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_DevNameCancelBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_DevNameCancelBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_DevNameCancelBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_DevNameCancelBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_DevNameCancelBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_DevNameCancelLabel = lv_label_create(ui_DeviceName); +lv_obj_set_width( ui_DevNameCancelLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_DevNameCancelLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_DevNameCancelLabel, 109 ); +lv_obj_set_y( ui_DevNameCancelLabel, -96 ); +lv_obj_set_align( ui_DevNameCancelLabel, LV_ALIGN_CENTER ); +lv_label_set_text(ui_DevNameCancelLabel,"Cancel"); +lv_obj_set_style_text_color(ui_DevNameCancelLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_DevNameCancelLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +lv_keyboard_set_textarea(ui_DevNameKeyboard,ui_DeviceHostname); +lv_obj_add_event_cb(ui_DeviceHostname, ui_event_DeviceHostname, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_DevNameSaveBtn, ui_event_DevNameSaveBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_DevNameCancelBtn, ui_event_DevNameCancelBtn, LV_EVENT_ALL, NULL); + +} diff --git a/app/src/ui/screens/ui_LessCommonSetup.c b/app/src/ui/screens/ui_LessCommonSetup.c index 8a4ef77..d031523 100644 --- a/app/src/ui/screens/ui_LessCommonSetup.c +++ b/app/src/ui/screens/ui_LessCommonSetup.c @@ -37,6 +37,18 @@ lv_label_set_text(ui_CalibrateLabel,"Calibrate"); lv_obj_set_style_text_color(ui_CalibrateLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); lv_obj_set_style_text_opa(ui_CalibrateLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +ui_DevNameBtn = lv_btn_create(ui_LessCommonSetup); +lv_obj_set_width( ui_DevNameBtn, 100); +lv_obj_set_height( ui_DevNameBtn, 36); +lv_obj_set_x( ui_DevNameBtn, 113 ); +lv_obj_set_y( ui_DevNameBtn, 4 ); +lv_obj_add_flag( ui_DevNameBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_DevNameBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_DevNameBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_DevNameBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_DevNameBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_DevNameBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + ui_TimezoneLabel1 = lv_label_create(ui_LessCommonSetup); lv_obj_set_width( ui_TimezoneLabel1, LV_SIZE_CONTENT); /// 1 lv_obj_set_height( ui_TimezoneLabel1, LV_SIZE_CONTENT); /// 1 @@ -143,7 +155,7 @@ ui_SetupWifiBtn = lv_btn_create(ui_LessCommonSetup); lv_obj_set_width( ui_SetupWifiBtn, 100); lv_obj_set_height( ui_SetupWifiBtn, 36); lv_obj_set_x( ui_SetupWifiBtn, -2 ); -lv_obj_set_y( ui_SetupWifiBtn, -45 ); +lv_obj_set_y( ui_SetupWifiBtn, -42 ); lv_obj_set_align( ui_SetupWifiBtn, LV_ALIGN_BOTTOM_RIGHT ); lv_obj_add_flag( ui_SetupWifiBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags lv_obj_clear_flag( ui_SetupWifiBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags @@ -156,7 +168,7 @@ ui_SetupWifiLabel = lv_label_create(ui_LessCommonSetup); lv_obj_set_width( ui_SetupWifiLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_height( ui_SetupWifiLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_x( ui_SetupWifiLabel, -36 ); -lv_obj_set_y( ui_SetupWifiLabel, -56 ); +lv_obj_set_y( ui_SetupWifiLabel, -53 ); lv_obj_set_align( ui_SetupWifiLabel, LV_ALIGN_BOTTOM_RIGHT ); lv_label_set_text(ui_SetupWifiLabel,"Wifi"); lv_obj_set_style_text_color(ui_SetupWifiLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); @@ -178,17 +190,51 @@ lv_obj_set_style_bg_grad_dir(ui_SetupHomeBtn2, LV_GRAD_DIR_VER, LV_PART_MAIN| LV ui_SetupHomeLabel2 = lv_label_create(ui_LessCommonSetup); lv_obj_set_width( ui_SetupHomeLabel2, LV_SIZE_CONTENT); /// 1 lv_obj_set_height( ui_SetupHomeLabel2, LV_SIZE_CONTENT); /// 1 -lv_obj_set_x( ui_SetupHomeLabel2, -30 ); +lv_obj_set_x( ui_SetupHomeLabel2, -33 ); lv_obj_set_y( ui_SetupHomeLabel2, -14 ); lv_obj_set_align( ui_SetupHomeLabel2, LV_ALIGN_BOTTOM_RIGHT ); -lv_label_set_text(ui_SetupHomeLabel2,"Home"); +lv_label_set_text(ui_SetupHomeLabel2,"Save"); lv_obj_set_style_text_color(ui_SetupHomeLabel2, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); lv_obj_set_style_text_opa(ui_SetupHomeLabel2, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +ui_DevNameLabel = lv_label_create(ui_LessCommonSetup); +lv_obj_set_width( ui_DevNameLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_DevNameLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_DevNameLabel, 140 ); +lv_obj_set_y( ui_DevNameLabel, 13 ); +lv_label_set_text(ui_DevNameLabel,"Name"); +lv_obj_set_style_text_color(ui_DevNameLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_DevNameLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_UncommonCancelBtn = lv_btn_create(ui_LessCommonSetup); +lv_obj_set_width( ui_UncommonCancelBtn, 100); +lv_obj_set_height( ui_UncommonCancelBtn, 36); +lv_obj_set_x( ui_UncommonCancelBtn, -2 ); +lv_obj_set_y( ui_UncommonCancelBtn, -82 ); +lv_obj_set_align( ui_UncommonCancelBtn, LV_ALIGN_BOTTOM_RIGHT ); +lv_obj_add_flag( ui_UncommonCancelBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_UncommonCancelBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_UncommonCancelBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_UncommonCancelBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_UncommonCancelBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_UncommonCancelBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_UncommonCancelLabel = lv_label_create(ui_LessCommonSetup); +lv_obj_set_width( ui_UncommonCancelLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_UncommonCancelLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_UncommonCancelLabel, -28 ); +lv_obj_set_y( ui_UncommonCancelLabel, -92 ); +lv_obj_set_align( ui_UncommonCancelLabel, LV_ALIGN_BOTTOM_RIGHT ); +lv_label_set_text(ui_UncommonCancelLabel,"Cancel"); +lv_obj_set_style_text_color(ui_UncommonCancelLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_UncommonCancelLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + lv_obj_add_event_cb(ui_CalibrateBtn, ui_event_CalibrateBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_DevNameBtn, ui_event_DevNameBtn, LV_EVENT_ALL, NULL); lv_obj_add_event_cb(ui_UiSleepSlider, ui_event_UiSleepSlider, LV_EVENT_ALL, NULL); lv_obj_add_event_cb(ui_SetupWifiBtn, ui_event_SetupWifiBtn, LV_EVENT_ALL, NULL); lv_obj_add_event_cb(ui_SetupHomeBtn2, ui_event_SetupHomeBtn2, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_UncommonCancelBtn, ui_event_UncommonCancelBtn, LV_EVENT_ALL, NULL); lv_obj_add_event_cb(ui_LessCommonSetup, ui_event_LessCommonSetup, LV_EVENT_ALL, NULL); } diff --git a/app/src/ui/screens/ui_MqttConfig.c b/app/src/ui/screens/ui_MqttConfig.c index 94ebb5c..7b1eb19 100644 --- a/app/src/ui/screens/ui_MqttConfig.c +++ b/app/src/ui/screens/ui_MqttConfig.c @@ -30,8 +30,7 @@ lv_obj_set_height( ui_MqttHostname, LV_SIZE_CONTENT); /// 20 lv_obj_set_x( ui_MqttHostname, -50 ); lv_obj_set_y( ui_MqttHostname, -97 ); lv_obj_set_align( ui_MqttHostname, LV_ALIGN_CENTER ); -lv_textarea_set_text(ui_MqttHostname,"MQTT Host"); -lv_textarea_set_placeholder_text(ui_MqttHostname,"Placeholder..."); +lv_textarea_set_placeholder_text(ui_MqttHostname,"MQTT Broker"); lv_textarea_set_one_line(ui_MqttHostname,true); lv_obj_set_style_text_font(ui_MqttHostname, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); @@ -43,8 +42,7 @@ lv_obj_set_height( ui_MqttUsername, LV_SIZE_CONTENT); /// 33 lv_obj_set_x( ui_MqttUsername, -50 ); lv_obj_set_y( ui_MqttUsername, -52 ); lv_obj_set_align( ui_MqttUsername, LV_ALIGN_CENTER ); -lv_textarea_set_text(ui_MqttUsername,"Username"); -lv_textarea_set_placeholder_text(ui_MqttUsername,"Placeholder..."); +lv_textarea_set_placeholder_text(ui_MqttUsername,"MQTT Username"); lv_textarea_set_one_line(ui_MqttUsername,true); lv_obj_set_style_text_font(ui_MqttUsername, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); @@ -56,26 +54,17 @@ lv_obj_set_height( ui_MqttPassword, LV_SIZE_CONTENT); /// 33 lv_obj_set_x( ui_MqttPassword, -50 ); lv_obj_set_y( ui_MqttPassword, -7 ); lv_obj_set_align( ui_MqttPassword, LV_ALIGN_CENTER ); -lv_textarea_set_text(ui_MqttPassword,"Password"); -lv_textarea_set_placeholder_text(ui_MqttPassword,"Placeholder..."); +lv_textarea_set_placeholder_text(ui_MqttPassword,"MQTT Password"); lv_textarea_set_one_line(ui_MqttPassword,true); lv_obj_set_style_text_font(ui_MqttPassword, &lv_font_montserrat_18, LV_PART_MAIN| LV_STATE_DEFAULT); -ui_MqttPwdLabel = lv_label_create(ui_MqttConfig); -lv_obj_set_width( ui_MqttPwdLabel, LV_SIZE_CONTENT); /// 1 -lv_obj_set_height( ui_MqttPwdLabel, LV_SIZE_CONTENT); /// 1 -lv_obj_set_x( ui_MqttPwdLabel, 230 ); -lv_obj_set_y( ui_MqttPwdLabel, -99 ); -lv_obj_set_align( ui_MqttPwdLabel, LV_ALIGN_LEFT_MID ); -lv_label_set_text(ui_MqttPwdLabel,"Password:"); - ui_MqttSaveBtn = lv_btn_create(ui_MqttConfig); lv_obj_set_width( ui_MqttSaveBtn, 100); lv_obj_set_height( ui_MqttSaveBtn, 36); lv_obj_set_x( ui_MqttSaveBtn, -1 ); -lv_obj_set_y( ui_MqttSaveBtn, -20 ); +lv_obj_set_y( ui_MqttSaveBtn, -56 ); lv_obj_set_align( ui_MqttSaveBtn, LV_ALIGN_RIGHT_MID ); lv_obj_add_flag( ui_MqttSaveBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags lv_obj_clear_flag( ui_MqttSaveBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags @@ -88,7 +77,7 @@ ui_MqttSaveLabel = lv_label_create(ui_MqttConfig); lv_obj_set_width( ui_MqttSaveLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_height( ui_MqttSaveLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_x( ui_MqttSaveLabel, 109 ); -lv_obj_set_y( ui_MqttSaveLabel, -20 ); +lv_obj_set_y( ui_MqttSaveLabel, -56 ); lv_obj_set_align( ui_MqttSaveLabel, LV_ALIGN_CENTER ); lv_label_set_text(ui_MqttSaveLabel,"Save"); lv_obj_set_style_text_color(ui_MqttSaveLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); @@ -98,7 +87,7 @@ ui_MqttCancelBtn = lv_btn_create(ui_MqttConfig); lv_obj_set_width( ui_MqttCancelBtn, 100); lv_obj_set_height( ui_MqttCancelBtn, 36); lv_obj_set_x( ui_MqttCancelBtn, -1 ); -lv_obj_set_y( ui_MqttCancelBtn, -60 ); +lv_obj_set_y( ui_MqttCancelBtn, -96 ); lv_obj_set_align( ui_MqttCancelBtn, LV_ALIGN_RIGHT_MID ); lv_obj_add_flag( ui_MqttCancelBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags lv_obj_clear_flag( ui_MqttCancelBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags @@ -111,7 +100,7 @@ ui_MqttCancelLabel = lv_label_create(ui_MqttConfig); lv_obj_set_width( ui_MqttCancelLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_height( ui_MqttCancelLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_x( ui_MqttCancelLabel, 109 ); -lv_obj_set_y( ui_MqttCancelLabel, -60 ); +lv_obj_set_y( ui_MqttCancelLabel, -96 ); lv_obj_set_align( ui_MqttCancelLabel, LV_ALIGN_CENTER ); lv_label_set_text(ui_MqttCancelLabel,"Cancel"); lv_obj_set_style_text_color(ui_MqttCancelLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); diff --git a/app/src/ui/screens/ui_Setup.c b/app/src/ui/screens/ui_Setup.c index ccd3170..66911c7 100644 --- a/app/src/ui/screens/ui_Setup.c +++ b/app/src/ui/screens/ui_Setup.c @@ -27,7 +27,7 @@ lv_label_set_text(ui_TempUnitsLabel,"Temp Units: "); ui_FahrenheitLabel = lv_label_create(ui_Setup); lv_obj_set_width( ui_FahrenheitLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_height( ui_FahrenheitLabel, LV_SIZE_CONTENT); /// 1 -lv_obj_set_x( ui_FahrenheitLabel, 133 ); +lv_obj_set_x( ui_FahrenheitLabel, 117 ); lv_obj_set_y( ui_FahrenheitLabel, -15 ); lv_obj_set_align( ui_FahrenheitLabel, LV_ALIGN_LEFT_MID ); lv_label_set_text(ui_FahrenheitLabel,"F"); @@ -35,7 +35,7 @@ lv_label_set_text(ui_FahrenheitLabel,"F"); ui_TempUnitsSwitch = lv_switch_create(ui_Setup); lv_obj_set_width( ui_TempUnitsSwitch, 50); lv_obj_set_height( ui_TempUnitsSwitch, 22); -lv_obj_set_x( ui_TempUnitsSwitch, 13 ); +lv_obj_set_x( ui_TempUnitsSwitch, -3 ); lv_obj_set_y( ui_TempUnitsSwitch, -15 ); lv_obj_set_align( ui_TempUnitsSwitch, LV_ALIGN_CENTER ); lv_obj_add_state( ui_TempUnitsSwitch, LV_STATE_CHECKED ); /// States @@ -46,7 +46,7 @@ lv_obj_set_style_bg_opa(ui_TempUnitsSwitch, 255, LV_PART_MAIN| LV_STATE_DEFAULT) ui_CelciusLabel = lv_label_create(ui_Setup); lv_obj_set_width( ui_CelciusLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_height( ui_CelciusLabel, LV_SIZE_CONTENT); /// 1 -lv_obj_set_x( ui_CelciusLabel, 203 ); +lv_obj_set_x( ui_CelciusLabel, 187 ); lv_obj_set_y( ui_CelciusLabel, -15 ); lv_obj_set_align( ui_CelciusLabel, LV_ALIGN_LEFT_MID ); lv_label_set_text(ui_CelciusLabel,"C"); @@ -68,7 +68,7 @@ lv_obj_set_align( ui_TempCorrectionLabel, LV_ALIGN_LEFT_MID ); lv_label_set_text(ui_TempCorrectionLabel,"-3.8°"); ui_TempCorrectionSlider = lv_slider_create(ui_Setup); -lv_slider_set_range(ui_TempCorrectionSlider, -65,10); +lv_slider_set_range(ui_TempCorrectionSlider, -100,30); if (lv_slider_get_mode(ui_TempCorrectionSlider)==LV_SLIDER_MODE_RANGE ) lv_slider_set_left_value( ui_TempCorrectionSlider, -65, LV_ANIM_OFF); lv_obj_set_width( ui_TempCorrectionSlider, 127); lv_obj_set_height( ui_TempCorrectionSlider, 10); @@ -143,7 +143,7 @@ ui_SetupMqttBtn = lv_btn_create(ui_Setup); lv_obj_set_width( ui_SetupMqttBtn, 100); lv_obj_set_height( ui_SetupMqttBtn, 36); lv_obj_set_x( ui_SetupMqttBtn, -2 ); -lv_obj_set_y( ui_SetupMqttBtn, -87 ); +lv_obj_set_y( ui_SetupMqttBtn, -83 ); lv_obj_set_align( ui_SetupMqttBtn, LV_ALIGN_BOTTOM_RIGHT ); lv_obj_add_flag( ui_SetupMqttBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags lv_obj_clear_flag( ui_SetupMqttBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags @@ -156,7 +156,7 @@ ui_SetupMqttLabel = lv_label_create(ui_Setup); lv_obj_set_width( ui_SetupMqttLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_height( ui_SetupMqttLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_x( ui_SetupMqttLabel, -30 ); -lv_obj_set_y( ui_SetupMqttLabel, -98 ); +lv_obj_set_y( ui_SetupMqttLabel, -94 ); lv_obj_set_align( ui_SetupMqttLabel, LV_ALIGN_BOTTOM_RIGHT ); lv_label_set_text(ui_SetupMqttLabel,"MQTT"); lv_obj_set_style_text_color(ui_SetupMqttLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); @@ -166,7 +166,7 @@ ui_SetupUncommonBtn = lv_btn_create(ui_Setup); lv_obj_set_width( ui_SetupUncommonBtn, 100); lv_obj_set_height( ui_SetupUncommonBtn, 36); lv_obj_set_x( ui_SetupUncommonBtn, -2 ); -lv_obj_set_y( ui_SetupUncommonBtn, -45 ); +lv_obj_set_y( ui_SetupUncommonBtn, -42 ); lv_obj_set_align( ui_SetupUncommonBtn, LV_ALIGN_BOTTOM_RIGHT ); lv_obj_add_flag( ui_SetupUncommonBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags lv_obj_clear_flag( ui_SetupUncommonBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags @@ -178,10 +178,10 @@ lv_obj_set_style_bg_grad_dir(ui_SetupUncommonBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| ui_SetupUncommonLabel = lv_label_create(ui_Setup); lv_obj_set_width( ui_SetupUncommonLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_height( ui_SetupUncommonLabel, LV_SIZE_CONTENT); /// 1 -lv_obj_set_x( ui_SetupUncommonLabel, -21 ); -lv_obj_set_y( ui_SetupUncommonLabel, -56 ); +lv_obj_set_x( ui_SetupUncommonLabel, -27 ); +lv_obj_set_y( ui_SetupUncommonLabel, -53 ); lv_obj_set_align( ui_SetupUncommonLabel, LV_ALIGN_BOTTOM_RIGHT ); -lv_label_set_text(ui_SetupUncommonLabel,"Unusual"); +lv_label_set_text(ui_SetupUncommonLabel,"More..."); lv_obj_set_style_text_color(ui_SetupUncommonLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); lv_obj_set_style_text_opa(ui_SetupUncommonLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); @@ -201,10 +201,10 @@ lv_obj_set_style_bg_grad_dir(ui_SetupHomeBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_ ui_SetupHomeLabel = lv_label_create(ui_Setup); lv_obj_set_width( ui_SetupHomeLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_height( ui_SetupHomeLabel, LV_SIZE_CONTENT); /// 1 -lv_obj_set_x( ui_SetupHomeLabel, -30 ); +lv_obj_set_x( ui_SetupHomeLabel, -33 ); lv_obj_set_y( ui_SetupHomeLabel, -14 ); lv_obj_set_align( ui_SetupHomeLabel, LV_ALIGN_BOTTOM_RIGHT ); -lv_label_set_text(ui_SetupHomeLabel,"Home"); +lv_label_set_text(ui_SetupHomeLabel,"Save"); lv_obj_set_style_text_color(ui_SetupHomeLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); lv_obj_set_style_text_opa(ui_SetupHomeLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); @@ -215,12 +215,7 @@ lv_obj_set_x( ui_HomeAutomationLabel, 7 ); lv_obj_set_y( ui_HomeAutomationLabel, 95 ); lv_obj_set_align( ui_HomeAutomationLabel, LV_ALIGN_LEFT_MID ); lv_label_set_long_mode(ui_HomeAutomationLabel,LV_LABEL_LONG_SCROLL); -#ifdef MATTER_ENABLED lv_label_set_text(ui_HomeAutomationLabel,"Matter Enable:"); -#endif -#ifdef MQTT_ENABLED -lv_label_set_text(ui_HomeAutomationLabel,"MQTT Enable:"); -#endif ui_HomeAutomationCheckbox = lv_checkbox_create(ui_Setup); lv_checkbox_set_text(ui_HomeAutomationCheckbox,""); @@ -231,11 +226,35 @@ lv_obj_set_y( ui_HomeAutomationCheckbox, 95 ); lv_obj_set_align( ui_HomeAutomationCheckbox, LV_ALIGN_CENTER ); lv_obj_add_flag( ui_HomeAutomationCheckbox, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +ui_SetupCancelBtn = lv_btn_create(ui_Setup); +lv_obj_set_width( ui_SetupCancelBtn, 100); +lv_obj_set_height( ui_SetupCancelBtn, 36); +lv_obj_set_x( ui_SetupCancelBtn, -2 ); +lv_obj_set_y( ui_SetupCancelBtn, -124 ); +lv_obj_set_align( ui_SetupCancelBtn, LV_ALIGN_BOTTOM_RIGHT ); +lv_obj_add_flag( ui_SetupCancelBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags +lv_obj_clear_flag( ui_SetupCancelBtn, LV_OBJ_FLAG_SCROLLABLE ); /// Flags +lv_obj_set_style_bg_color(ui_SetupCancelBtn, lv_color_hex(0x2095F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_opa(ui_SetupCancelBtn, 255, LV_PART_MAIN| LV_STATE_DEFAULT); +lv_obj_set_style_bg_grad_color(ui_SetupCancelBtn, lv_color_hex(0x2620F6), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_bg_grad_dir(ui_SetupCancelBtn, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT); + +ui_SetupCancelLabel = lv_label_create(ui_Setup); +lv_obj_set_width( ui_SetupCancelLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_height( ui_SetupCancelLabel, LV_SIZE_CONTENT); /// 1 +lv_obj_set_x( ui_SetupCancelLabel, -30 ); +lv_obj_set_y( ui_SetupCancelLabel, -134 ); +lv_obj_set_align( ui_SetupCancelLabel, LV_ALIGN_BOTTOM_RIGHT ); +lv_label_set_text(ui_SetupCancelLabel,"Cancel"); +lv_obj_set_style_text_color(ui_SetupCancelLabel, lv_color_hex(0xFFE300), LV_PART_MAIN | LV_STATE_DEFAULT ); +lv_obj_set_style_text_opa(ui_SetupCancelLabel, 255, LV_PART_MAIN| LV_STATE_DEFAULT); + lv_obj_add_event_cb(ui_TempCorrectionSlider, ui_event_TempCorrectionSlider, LV_EVENT_ALL, NULL); lv_obj_add_event_cb(ui_TempSwingSlider, ui_event_TempSwingSlider, LV_EVENT_ALL, NULL); lv_obj_add_event_cb(ui_SetupMqttBtn, ui_event_SetupMqttBtn, LV_EVENT_ALL, NULL); lv_obj_add_event_cb(ui_SetupUncommonBtn, ui_event_SetupUncommonBtn, LV_EVENT_ALL, NULL); lv_obj_add_event_cb(ui_SetupHomeBtn, ui_event_SetupHomeBtn, LV_EVENT_ALL, NULL); +lv_obj_add_event_cb(ui_SetupCancelBtn, ui_event_SetupCancelBtn, LV_EVENT_ALL, NULL); lv_obj_add_event_cb(ui_Setup, ui_event_Setup, LV_EVENT_ALL, NULL); } diff --git a/app/src/ui/screens/ui_WifiConfig.c b/app/src/ui/screens/ui_WifiConfig.c index 2d1268d..38f04ba 100644 --- a/app/src/ui/screens/ui_WifiConfig.c +++ b/app/src/ui/screens/ui_WifiConfig.c @@ -30,7 +30,7 @@ lv_obj_set_height( ui_PSK, LV_SIZE_CONTENT); /// 33 lv_obj_set_x( ui_PSK, -55 ); lv_obj_set_y( ui_PSK, -21 ); lv_obj_set_align( ui_PSK, LV_ALIGN_CENTER ); -lv_textarea_set_placeholder_text(ui_PSK,"Placeholder..."); +lv_textarea_set_placeholder_text(ui_PSK,"Password"); lv_textarea_set_one_line(ui_PSK,true); lv_obj_set_style_text_font(ui_PSK, &lv_font_montserrat_20, LV_PART_MAIN| LV_STATE_DEFAULT); diff --git a/app/src/ui/ui.c b/app/src/ui/ui.c index 2028d24..2167a59 100644 --- a/app/src/ui/ui.c +++ b/app/src/ui/ui.c @@ -96,6 +96,9 @@ lv_obj_t *ui_SetupHomeBtn; lv_obj_t *ui_SetupHomeLabel; lv_obj_t *ui_HomeAutomationLabel; lv_obj_t *ui_HomeAutomationCheckbox; +void ui_event_SetupCancelBtn( lv_event_t * e); +lv_obj_t *ui_SetupCancelBtn; +lv_obj_t *ui_SetupCancelLabel; // SCREEN: ui_LessCommonSetup @@ -105,6 +108,8 @@ lv_obj_t *ui_LessCommonSetup; void ui_event_CalibrateBtn( lv_event_t * e); lv_obj_t *ui_CalibrateBtn; lv_obj_t *ui_CalibrateLabel; +void ui_event_DevNameBtn( lv_event_t * e); +lv_obj_t *ui_DevNameBtn; lv_obj_t *ui_TimezoneLabel1; lv_obj_t *ui_TimezoneDropdown; lv_obj_t *ui_UiSleepTextLabel; @@ -123,6 +128,10 @@ lv_obj_t *ui_SetupWifiLabel; void ui_event_SetupHomeBtn2( lv_event_t * e); lv_obj_t *ui_SetupHomeBtn2; lv_obj_t *ui_SetupHomeLabel2; +lv_obj_t *ui_DevNameLabel; +void ui_event_UncommonCancelBtn( lv_event_t * e); +lv_obj_t *ui_UncommonCancelBtn; +lv_obj_t *ui_UncommonCancelLabel; // SCREEN: ui_WifiConfig @@ -157,14 +166,6 @@ lv_obj_t *ui_QRImage; lv_obj_t *ui_ManualPairingCode; -// SCREEN: ui_ThermostatRestart -void ui_ThermostatRestart_screen_init(void); -void ui_event_ThermostatRestart( lv_event_t * e); -lv_obj_t *ui_ThermostatRestart; -lv_obj_t *ui_Notification; -lv_obj_t *ui_RestartCountdown; - - // SCREEN: ui_MqttConfig void ui_MqttConfig_screen_init(void); lv_obj_t *ui_MqttConfig; @@ -175,13 +176,34 @@ void ui_event_MqttUsername( lv_event_t * e); lv_obj_t *ui_MqttUsername; void ui_event_MqttPassword( lv_event_t * e); lv_obj_t *ui_MqttPassword; -lv_obj_t *ui_MqttPwdLabel; void ui_event_MqttSaveBtn( lv_event_t * e); lv_obj_t *ui_MqttSaveBtn; lv_obj_t *ui_MqttSaveLabel; void ui_event_MqttCancelBtn( lv_event_t * e); lv_obj_t *ui_MqttCancelBtn; lv_obj_t *ui_MqttCancelLabel; + + +// SCREEN: ui_DeviceName +void ui_DeviceName_screen_init(void); +lv_obj_t *ui_DeviceName; +lv_obj_t *ui_DevNameKeyboard; +void ui_event_DeviceHostname( lv_event_t * e); +lv_obj_t *ui_DeviceHostname; +void ui_event_DevNameSaveBtn( lv_event_t * e); +lv_obj_t *ui_DevNameSaveBtn; +lv_obj_t *ui_DevNameSaveLabel; +void ui_event_DevNameCancelBtn( lv_event_t * e); +lv_obj_t *ui_DevNameCancelBtn; +lv_obj_t *ui_DevNameCancelLabel; + + +// SCREEN: ui_ThermostatRestart +void ui_ThermostatRestart_screen_init(void); +void ui_event_ThermostatRestart( lv_event_t * e); +lv_obj_t *ui_ThermostatRestart; +lv_obj_t *ui_Notification; +lv_obj_t *ui_RestartCountdown; lv_obj_t *ui____initial_actions0; ///////////////////// TEST LVGL SETTINGS //////////////////// @@ -339,6 +361,13 @@ if ( event_code == LV_EVENT_CLICKED) { SaveConfigSettings( e ); } } +void ui_event_SetupCancelBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + _ui_screen_change( &ui_MainScreen, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0, &ui_MainScreen_screen_init); + tftBeep( e ); +} +} void ui_event_LessCommonSetup( lv_event_t * e) { lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); if ( event_code == LV_EVENT_SCREEN_LOADED) { @@ -351,6 +380,13 @@ if ( event_code == LV_EVENT_CLICKED) { tftCalibrate( e ); } } +void ui_event_DevNameBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + _ui_screen_change( &ui_DeviceName, LV_SCR_LOAD_ANIM_FADE_ON, 500, 0, &ui_DeviceName_screen_init); + loadDeviceName( e ); +} +} void ui_event_UiSleepSlider( lv_event_t * e) { lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); if ( event_code == LV_EVENT_VALUE_CHANGED) { @@ -373,6 +409,13 @@ if ( event_code == LV_EVENT_CLICKED) { SaveUncommonConfigSettings( e ); } } +void ui_event_UncommonCancelBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + _ui_screen_change( &ui_Setup, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0, &ui_Setup_screen_init); + tftBeep( e ); +} +} void ui_event_SsidDropdown( lv_event_t * e) { lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); if ( event_code == LV_EVENT_VALUE_CHANGED) { @@ -396,7 +439,7 @@ if ( event_code == LV_EVENT_CLICKED) { void ui_event_CancelBtn( lv_event_t * e) { lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); if ( event_code == LV_EVENT_CLICKED) { - _ui_screen_change( &ui_Setup, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_Setup_screen_init); + _ui_screen_change( &ui_LessCommonSetup, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_LessCommonSetup_screen_init); tftBeep( e ); stopWifiScan( e ); } @@ -420,12 +463,6 @@ if ( event_code == LV_EVENT_CLICKED) { _ui_screen_change( &ui_MainScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_MainScreen_screen_init); } } -void ui_event_ThermostatRestart( lv_event_t * e) { - lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); -if ( event_code == LV_EVENT_SCREEN_LOADED) { - tftCountdown( e ); -} -} void ui_event_MqttHostname( lv_event_t * e) { lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); if ( event_code == LV_EVENT_CLICKED) { @@ -459,6 +496,33 @@ if ( event_code == LV_EVENT_CLICKED) { tftBeep( e ); } } +void ui_event_DeviceHostname( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + _ui_keyboard_set_target(ui_DevNameKeyboard, ui_DeviceHostname); +} +} +void ui_event_DevNameSaveBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + saveDeviceName( e ); + _ui_screen_change( &ui_MainScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 2, &ui_MainScreen_screen_init); + tftAwaken( e ); +} +} +void ui_event_DevNameCancelBtn( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_CLICKED) { + _ui_screen_change( &ui_LessCommonSetup, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_LessCommonSetup_screen_init); + tftBeep( e ); +} +} +void ui_event_ThermostatRestart( lv_event_t * e) { + lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e); +if ( event_code == LV_EVENT_SCREEN_LOADED) { + tftCountdown( e ); +} +} ///////////////////// SCREENS //////////////////// @@ -473,8 +537,9 @@ ui_Setup_screen_init(); ui_LessCommonSetup_screen_init(); ui_WifiConfig_screen_init(); ui_MatterConfig_screen_init(); -ui_ThermostatRestart_screen_init(); ui_MqttConfig_screen_init(); +ui_DeviceName_screen_init(); +ui_ThermostatRestart_screen_init(); ui____initial_actions0 = lv_obj_create(NULL); lv_disp_load_scr( ui_MainScreen); } diff --git a/app/src/ui/ui.h b/app/src/ui/ui.h index 6da245b..ed6a7b5 100644 --- a/app/src/ui/ui.h +++ b/app/src/ui/ui.h @@ -97,6 +97,9 @@ extern lv_obj_t *ui_SetupHomeBtn; extern lv_obj_t *ui_SetupHomeLabel; extern lv_obj_t *ui_HomeAutomationLabel; extern lv_obj_t *ui_HomeAutomationCheckbox; +void ui_event_SetupCancelBtn( lv_event_t * e); +extern lv_obj_t *ui_SetupCancelBtn; +extern lv_obj_t *ui_SetupCancelLabel; // SCREEN: ui_LessCommonSetup void ui_LessCommonSetup_screen_init(void); void ui_event_LessCommonSetup( lv_event_t * e); @@ -104,6 +107,8 @@ extern lv_obj_t *ui_LessCommonSetup; void ui_event_CalibrateBtn( lv_event_t * e); extern lv_obj_t *ui_CalibrateBtn; extern lv_obj_t *ui_CalibrateLabel; +void ui_event_DevNameBtn( lv_event_t * e); +extern lv_obj_t *ui_DevNameBtn; extern lv_obj_t *ui_TimezoneLabel1; extern lv_obj_t *ui_TimezoneDropdown; extern lv_obj_t *ui_UiSleepTextLabel; @@ -122,6 +127,10 @@ extern lv_obj_t *ui_SetupWifiLabel; void ui_event_SetupHomeBtn2( lv_event_t * e); extern lv_obj_t *ui_SetupHomeBtn2; extern lv_obj_t *ui_SetupHomeLabel2; +extern lv_obj_t *ui_DevNameLabel; +void ui_event_UncommonCancelBtn( lv_event_t * e); +extern lv_obj_t *ui_UncommonCancelBtn; +extern lv_obj_t *ui_UncommonCancelLabel; // SCREEN: ui_WifiConfig void ui_WifiConfig_screen_init(void); extern lv_obj_t *ui_WifiConfig; @@ -150,12 +159,6 @@ extern lv_obj_t *ui_QrHomeBtn; extern lv_obj_t *ui_SetupHomeLabel1; extern lv_obj_t *ui_QRImage; extern lv_obj_t *ui_ManualPairingCode; -// SCREEN: ui_ThermostatRestart -void ui_ThermostatRestart_screen_init(void); -void ui_event_ThermostatRestart( lv_event_t * e); -extern lv_obj_t *ui_ThermostatRestart; -extern lv_obj_t *ui_Notification; -extern lv_obj_t *ui_RestartCountdown; // SCREEN: ui_MqttConfig void ui_MqttConfig_screen_init(void); extern lv_obj_t *ui_MqttConfig; @@ -166,13 +169,30 @@ void ui_event_MqttUsername( lv_event_t * e); extern lv_obj_t *ui_MqttUsername; void ui_event_MqttPassword( lv_event_t * e); extern lv_obj_t *ui_MqttPassword; -extern lv_obj_t *ui_MqttPwdLabel; void ui_event_MqttSaveBtn( lv_event_t * e); extern lv_obj_t *ui_MqttSaveBtn; extern lv_obj_t *ui_MqttSaveLabel; void ui_event_MqttCancelBtn( lv_event_t * e); extern lv_obj_t *ui_MqttCancelBtn; extern lv_obj_t *ui_MqttCancelLabel; +// SCREEN: ui_DeviceName +void ui_DeviceName_screen_init(void); +extern lv_obj_t *ui_DeviceName; +extern lv_obj_t *ui_DevNameKeyboard; +void ui_event_DeviceHostname( lv_event_t * e); +extern lv_obj_t *ui_DeviceHostname; +void ui_event_DevNameSaveBtn( lv_event_t * e); +extern lv_obj_t *ui_DevNameSaveBtn; +extern lv_obj_t *ui_DevNameSaveLabel; +void ui_event_DevNameCancelBtn( lv_event_t * e); +extern lv_obj_t *ui_DevNameCancelBtn; +extern lv_obj_t *ui_DevNameCancelLabel; +// SCREEN: ui_ThermostatRestart +void ui_ThermostatRestart_screen_init(void); +void ui_event_ThermostatRestart( lv_event_t * e); +extern lv_obj_t *ui_ThermostatRestart; +extern lv_obj_t *ui_Notification; +extern lv_obj_t *ui_RestartCountdown; extern lv_obj_t *ui____initial_actions0; diff --git a/app/src/ui/ui_events.cpp b/app/src/ui/ui_events.cpp index 702167f..0140538 100644 --- a/app/src/ui/ui_events.cpp +++ b/app/src/ui/ui_events.cpp @@ -6,6 +6,7 @@ #include "thermostat.hpp" #include "ui.h" #include "version.h" +#include // #include // For nvs_flash_init() #define screenWidth 320 @@ -71,11 +72,12 @@ void tftHvacModeChange(lv_event_t * e) switch (OperatingParameters.hvacSetMode) { // Set color of outer ring to represent set mode - case HEAT: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0xc71b1b), LV_PART_MAIN); break; - case COOL: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0x1b7dc7), LV_PART_MAIN); break; - case FAN: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0x23562b), LV_PART_MAIN); break; //@@@ - case AUTO: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0xaeac40), LV_PART_MAIN); break; - default: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0x7d7d7d), LV_PART_MAIN); break; + case AUX_HEAT: + case HEAT: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0xc71b1b), LV_PART_MAIN); break; + case COOL: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0x1b7dc7), LV_PART_MAIN); break; + case FAN_ONLY: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0x23562b), LV_PART_MAIN); break; //@@@ + case AUTO: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0xaeac40), LV_PART_MAIN); break; + default: lv_obj_set_style_bg_color(ui_SetTempBg1, lv_color_hex(0x7d7d7d), LV_PART_MAIN); break; } tftWakeDisplay(true); @@ -166,7 +168,7 @@ void LoadInfoStrings(lv_event_t * e) lv_label_set_text_fmt(ui_WifiSsidLabel, "%s SSID:# %s", LABEL_COLOR, WifiCreds.ssid); lv_label_set_recolor(ui_HostnameLabel, true); - lv_label_set_text_fmt(ui_HostnameLabel, "%s Hostname:# %s", LABEL_COLOR, WifiCreds.hostname); + lv_label_set_text_fmt(ui_HostnameLabel, "%s Hostname:# %s", LABEL_COLOR, OperatingParameters.DeviceName); lv_label_set_recolor(ui_IPLabel, true); lv_label_set_text_fmt(ui_IPLabel, "%s IP:# %s", LABEL_COLOR, wifiAddress()); @@ -313,7 +315,16 @@ void SaveConfigSettings(lv_event_t * e) _ui_screen_change(&ui_ThermostatRestart, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_ThermostatRestart_screen_init); } } + else + { + if (OperatingParameters.MqttEnabled && OperatingParameters.MqttConnected) + { + // Update config by sending a new discovery packet + MqttHomeAssistantDiscovery(); + } + } #endif + updateThermostatParams(); } void LoadConfigSettings(lv_event_t * e) @@ -335,6 +346,7 @@ void LoadConfigSettings(lv_event_t * e) else lv_obj_clear_state(ui_HvacFanCheckbox, LV_STATE_CHECKED); #ifdef MATTER_ENABLED + lv_label_set_text(ui_HomeAutomationLabel,"Matter Enable:"); if (OperatingParameters.MatterEnabled) lv_obj_add_state(ui_HomeAutomationCheckbox, LV_STATE_CHECKED); else @@ -344,18 +356,25 @@ void LoadConfigSettings(lv_event_t * e) lv_obj_add_flag(ui_SetupMqttLabel, LV_OBJ_FLAG_HIDDEN); #endif #ifdef MQTT_ENABLED + lv_label_set_text(ui_HomeAutomationLabel,"MQTT Enable:"); + //@@@ For now, if we compile with MQTT support, enable the config button if (OperatingParameters.MqttEnabled) - { lv_obj_add_state(ui_HomeAutomationCheckbox, LV_STATE_CHECKED); - lv_obj_clear_flag(ui_SetupMqttBtn, LV_OBJ_FLAG_HIDDEN); - lv_obj_clear_flag(ui_SetupMqttLabel, LV_OBJ_FLAG_HIDDEN); - } - else - { - lv_obj_clear_state(ui_HomeAutomationCheckbox, LV_STATE_CHECKED); - lv_obj_add_flag(ui_SetupMqttBtn, LV_OBJ_FLAG_HIDDEN); - lv_obj_add_flag(ui_SetupMqttLabel, LV_OBJ_FLAG_HIDDEN); - } + lv_obj_clear_flag(ui_SetupMqttBtn, LV_OBJ_FLAG_HIDDEN); + lv_obj_clear_flag(ui_SetupMqttLabel, LV_OBJ_FLAG_HIDDEN); + + // if (OperatingParameters.MqttEnabled) + // { + // lv_obj_add_state(ui_HomeAutomationCheckbox, LV_STATE_CHECKED); + // lv_obj_clear_flag(ui_SetupMqttBtn, LV_OBJ_FLAG_HIDDEN); + // lv_obj_clear_flag(ui_SetupMqttLabel, LV_OBJ_FLAG_HIDDEN); + // } + // else + // { + // lv_obj_clear_state(ui_HomeAutomationCheckbox, LV_STATE_CHECKED); + // lv_obj_add_flag(ui_SetupMqttBtn, LV_OBJ_FLAG_HIDDEN); + // lv_obj_add_flag(ui_SetupMqttLabel, LV_OBJ_FLAG_HIDDEN); + // } #endif } @@ -392,6 +411,8 @@ void SaveUncommonConfigSettings(lv_event_t * e) setHvacModesDropdown(); updateTimezone(); + updateThermostatParams(); + } void tftCalibrate(lv_event_t * e) @@ -504,8 +525,59 @@ void saveMqttSettings(lv_event_t * e) strcpy (OperatingParameters.MqttBrokerUsername, lv_textarea_get_text(ui_MqttUsername)); strcpy (OperatingParameters.MqttBrokerPassword, lv_textarea_get_text(ui_MqttPassword)); + updateThermostatParams(); + printf ("On save:\n"); printf (" MQTT Broker: %s\n", OperatingParameters.MqttBrokerHost); printf (" MQTT Username: %s\n", OperatingParameters.MqttBrokerUsername); printf (" MQTT Password: %s\n", OperatingParameters.MqttBrokerPassword); } + +void loadDeviceName(lv_event_t * e) +{ + lv_textarea_set_text(ui_DeviceHostname, OperatingParameters.FriendlyName); + + printf ("On load:\n"); + printf (" Friendly Name: %s\n", OperatingParameters.FriendlyName); + printf (" Device Hostname: %s\n", OperatingParameters.DeviceName); +} + +void saveDeviceName(lv_event_t * e) +{ + char *oldName = strdup(OperatingParameters.DeviceName); + + strcpy (OperatingParameters.FriendlyName, lv_textarea_get_text(ui_DeviceHostname)); + + char *p = (char *)OperatingParameters.FriendlyName; + char *t = (char *)OperatingParameters.DeviceName; + // Make DeviceName the same as FriendlyName just with all lower + // case letters and no spaces. + while (*p) + { + if (*p != ' ') + { + *t = tolower(*p); + t++; + } + p++; + } + + printf ("On save:\n"); + printf (" Friendly Name: %s\n", OperatingParameters.FriendlyName); + printf (" Device Hostname: %s\n", OperatingParameters.DeviceName); + + /* Rewrite the wifi credentials after resetting NVS storage */ + printf ("Rewriting wifi credentials\n"); + setWifiCreds(); // Save device name + printf ("Saving thermostat config\n"); + updateThermostatParams(); // Save Friendly name + + if (strcmp(oldName, OperatingParameters.DeviceName)) + { + printf ("Hostname/Devicename changed -- Restarting wifi to update network name\n"); + // Initiate a disconnect so the new wifi info will be used when auto-reconnect happens + WifiDisconnect(); + // Immediately start a new wifi connection + lastWifiReconnect = 0; + } +} diff --git a/app/src/ui/ui_events.h b/app/src/ui/ui_events.h index f5ba504..30cae3b 100644 --- a/app/src/ui/ui_events.h +++ b/app/src/ui/ui_events.h @@ -25,6 +25,7 @@ void loadMqttSettings(lv_event_t * e); void LoadUncommonSettings(lv_event_t * e); void SaveConfigSettings(lv_event_t * e); void tftCalibrate(lv_event_t * e); +void loadDeviceName(lv_event_t * e); void tftUpdateUiSleepValue(lv_event_t * e); void tftClearPsk(lv_event_t * e); void SaveUncommonConfigSettings(lv_event_t * e); @@ -32,8 +33,9 @@ void StartWifiScan(lv_event_t * e); void tftSetNewWifi(lv_event_t * e); void stopWifiScan(lv_event_t * e); void ShowQrOnScreen(lv_event_t * e); -void tftCountdown(lv_event_t * e); void saveMqttSettings(lv_event_t * e); +void saveDeviceName(lv_event_t * e); +void tftCountdown(lv_event_t * e); #ifdef __cplusplus } /*extern "C"*/ diff --git a/app/src/web.cpp b/app/src/web.cpp index c4e986c..505a3f1 100644 --- a/app/src/web.cpp +++ b/app/src/web.cpp @@ -104,7 +104,7 @@ esp_err_t hvacModeCool(httpd_req_t *req) esp_err_t hvacModeFan(httpd_req_t *req) { - updateHvacMode(FAN); + updateHvacMode(FAN_ONLY); return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); } @@ -339,6 +339,7 @@ void webStart() } httpd_config_t config = HTTPD_DEFAULT_CONFIG(); + config.max_uri_handlers = 11; httpd_handle_t server = NULL; if (httpd_start(&server, &config) == ESP_OK) diff --git a/app/src/wifi.cpp b/app/src/wifi.cpp index 3ef4f1c..61fc1e6 100644 --- a/app/src/wifi.cpp +++ b/app/src/wifi.cpp @@ -271,6 +271,10 @@ static void event_handler(void* arg, esp_event_base_t event_base, OperatingParameters.wifiConnected = true; WifiStatus.ip = event->ip_info.ip; wifiConnecting = false; + #ifdef MQTT_ENABLED + //@@@ Is this necessary when the IP address changes (lease expires)? + // MqttHomeAssistantDiscovery(); + #endif } } @@ -650,7 +654,7 @@ void networkReconnectTask(void *pvParameters) lastWifiMillis = millis(); - if (wifiReconnect(WifiCreds.hostname, WifiCreds.ssid, WifiCreds.password) == true) + if (wifiReconnect(OperatingParameters.DeviceName, WifiCreds.ssid, WifiCreds.password) == true) { OperatingParameters.wifiConnected = true; } From 7f5a9c0f7848d0e193f147e1bf9c70f9c633161f Mon Sep 17 00:00:00 2001 From: Steve Meisner Date: Tue, 24 Oct 2023 07:52:38 -0400 Subject: [PATCH 05/10] Resynch w/ web pr. Improve MQTT connect --- app/include/Arduino.h | 2 +- app/include/thermostat.hpp | 4 + app/include/web_ui.h | 322 +++++++++++++++++++++--------- app/src/mqtt.cpp | 94 ++++++--- app/src/state_machine.cpp | 23 ++- app/src/ui/ui_events.cpp | 9 + app/src/web.cpp | 391 +++++++++++++++++-------------------- app/src/wifi.cpp | 10 +- 8 files changed, 509 insertions(+), 346 deletions(-) diff --git a/app/include/Arduino.h b/app/include/Arduino.h index 4cd42ee..731e491 100644 --- a/app/include/Arduino.h +++ b/app/include/Arduino.h @@ -1,6 +1,6 @@ /*--------------------------------------------------------------- Simple header file to incorporate Arduino functions - mostly for the LD2410 sensor. + mostly for the LD2410 sensor library. ---------------------------------------------------------------*/ #include "thermostat.hpp" diff --git a/app/include/thermostat.hpp b/app/include/thermostat.hpp index 875842d..2ff1e9a 100644 --- a/app/include/thermostat.hpp +++ b/app/include/thermostat.hpp @@ -110,10 +110,14 @@ typedef struct } WIFI_STATUS; + extern OPERATING_PARAMETERS OperatingParameters; extern WIFI_CREDS WifiCreds; extern int32_t ui_WifiStatusLabel_timestamp; +#ifdef MQTT_ENABLED +#define MQTT_RECONNECT_DELAY 75000 +#endif #define MOTION_TIMEOUT 10000 #define WIFI_CONNECT_INTERVAL 30000 #define UPDATE_TIME_INTERVAL 60000 diff --git a/app/include/web_ui.h b/app/include/web_ui.h index 2713fd4..41cd344 100644 --- a/app/include/web_ui.h +++ b/app/include/web_ui.h @@ -1,96 +1,226 @@ -const char *webUI = "\ -\ -\ -Truly Smart Thermostat\ -\ -

Smart Thermostat Control Panel

\ -
\ -
\ -
Thermostat Controls
\ -
\ -
%d°%c
\ -

\ -\ -
\ -
\ -
Set to %s [Current action: %s]
\ -\ -\ -\ -\ -\ -
\ -
Current Readings
%0.1f°%c\ -
%0.1f%% humidity
Light Level: %d
Motion: %s
\ -
Thermostat Settings\ -



Units: %c
Swing: %0.1f
Temp. Correction: %0.1f\ -
\ -
System Settings
\ -
WiFi Strength: %d%%
IP: %s

Firmware Version %s
%s
\ -\ -

\ -
\ -



\ -"; - -const char *web_fw_upload = "\ -\ -\ - \ - \ - ESP32 OTA Update\ - \ - \ - \ -

ESP32 OTA Firmware Update

\ -
\ - \ - \ -
\ -
\ - \ -
\ -
\ - \ -"; +const char webUI[] = R"=====( + + +Truly Smart Thermostat + + +

Smart Thermostat Control Panel

+
+
+
Thermostat Controls
+
+
+
+
+ +
+
+
+

+ +
+
+ Current Readings +
+
+
+
+
+
Thermostat Settings +


+
+ + +
+ + + +
+
HVAC system settings +


+ + +
+ + +
+ + +
+ + +
+
System Info

+
+
+
+
+
+ +

+
+



+ + + + + +)====="; + +const char *web_fw_upload = R"=====( + + + + + ESP32 OTA Update + + + +

ESP32 OTA Firmware Update

+
+ + +
+
+ +
+
+ +)====="; \ No newline at end of file diff --git a/app/src/mqtt.cpp b/app/src/mqtt.cpp index c2ada4a..2a7fe47 100644 --- a/app/src/mqtt.cpp +++ b/app/src/mqtt.cpp @@ -59,7 +59,7 @@ struct CustomWriter { #define MQTT_EVENT_PUB_BIT BIT2 #define MQTT_ERROR_BIT BIT3 static EventGroupHandle_t s_mqtt_event_group = NULL; -const TickType_t xTicksToWait = 10000 / portTICK_PERIOD_MS; +const TickType_t xTicksToWait = 11000 / portTICK_PERIOD_MS; static void MqttEventHandler(void* handler_args, esp_event_base_t base, int32_t event_id, void* event_data) { @@ -90,10 +90,15 @@ static void MqttEventHandler(void* handler_args, esp_event_base_t base, int32_t ESP_LOGI(TAG, "MQTT_EVENT_PUBLISHED, msg_id=%d", event->msg_id); // xEventGroupSetBits(s_mqtt_event_group, MQTT_EVENT_PUB_BIT); break; + case MQTT_EVENT_ERROR: + ESP_LOGI(TAG, "MQTT_EVENT_ERROR"); + OperatingParameters.MqttConnected = false; + xEventGroupSetBits(s_mqtt_event_group, MQTT_ERROR_BIT); + break; case MQTT_EVENT_DATA: ESP_LOGI(TAG, "MQTT_EVENT_DATA"); - ESP_LOGI(TAG, "TOPIC=%.*s\r\n", event->topic_len, event->topic); - ESP_LOGI(TAG, "DATA=%.*s\r\n", event->data_len, event->data); + ESP_LOGI(TAG, "TOPIC=%.*s", event->topic_len, event->topic); + ESP_LOGI(TAG, "DATA=%.*s", event->data_len, event->data); if (strstr(event->topic, "mode")) { char m[event->data_len + 1]; @@ -101,7 +106,7 @@ static void MqttEventHandler(void* handler_args, esp_event_base_t base, int32_t m[event->data_len] = '\0'; // Make first letter uppercase to match our string representation m[0] = toupper(m[0]); - ESP_LOGI(TAG, "Looking up %s\n", m); + ESP_LOGI(TAG, "Looking up %s", m); updateHvacMode (strToHvacMode(m)); } if (strstr(event->topic, "temp")) @@ -112,7 +117,7 @@ static void MqttEventHandler(void* handler_args, esp_event_base_t base, int32_t } else { - ESP_LOGE(TAG, "Received invalid string for set temp: \"%s\"\n", event->data); + ESP_LOGE(TAG, "Received invalid string for set temp: \"%s\"", event->data); } } if (strstr(event->topic, "fan")) @@ -133,14 +138,10 @@ static void MqttEventHandler(void* handler_args, esp_event_base_t base, int32_t } else { - ESP_LOGE(TAG, "Received invalid string for set mode: \"%s\"\n", event->data); + ESP_LOGE(TAG, "Received invalid string for set mode: \"%s\"", event->data); } } break; - case MQTT_EVENT_ERROR: - ESP_LOGI(TAG, "MQTT_EVENT_ERROR"); - xEventGroupSetBits(s_mqtt_event_group, MQTT_ERROR_BIT); - break; } } @@ -327,6 +328,8 @@ void MqttHomeAssistantDiscovery() serializeJson(payload, strPayload); ESP_LOGI (TAG, "Payload: %s", strPayload.c_str()); + xEventGroupClearBits (s_mqtt_event_group, MQTT_EVENT_PUB_BIT | MQTT_ERROR_BIT); + // g_mqttPubSub.publish(discoveryTopic.c_str(), strPayload.c_str()); MqttPublish(discoveryTopic.c_str(), strPayload.c_str(), true); @@ -370,6 +373,8 @@ void MqttHomeAssistantDiscovery() serializeJson(payload, strPayload); printf ("Payload: %s\n", strPayload.c_str()); + xEventGroupClearBits (s_mqtt_event_group, MQTT_EVENT_PUB_BIT | MQTT_ERROR_BIT); + // g_mqttPubSub.publish(discoveryTopic.c_str(), strPayload.c_str()); MqttPublish(discoveryTopic.c_str(), strPayload.c_str(), true); @@ -425,10 +430,9 @@ void MqttSubscribeTopic(esp_mqtt_client_handle_t client, std::string topic) ESP_LOGI (TAG, "Send subscribe successful, Topic=%s, msg_id=%d", topic.c_str(), msg_id); } - bool MqttConnect(void) { - ESP_LOGI(__FUNCTION__, "Waiting for MQTT..."); + ESP_LOGI(__FUNCTION__, "Connecting to MQTT broker"); esp_mqtt_client_config_t mqtt_cfg; memset(&mqtt_cfg, 0, sizeof(esp_mqtt_client_config_t)); @@ -446,10 +450,10 @@ bool MqttConnect(void) // OperatingParameters.MqttBrokerPassword = (char *)malloc(72); // strcpy (OperatingParameters.MqttBrokerPassword, "einiiZeiphah4ish0Rowae7doh0OhNg6wahngohmie4iNae1meipainaeyijai5i"); - ESP_LOGI(TAG, "FQDN Broker: %s\n", host.c_str()); - ESP_LOGI(TAG, "Broker: %s\n", OperatingParameters.MqttBrokerHost); - ESP_LOGI(TAG, "Username: %s\n", OperatingParameters.MqttBrokerUsername); - ESP_LOGI(TAG, "Password: %s\n", OperatingParameters.MqttBrokerPassword); + ESP_LOGI(TAG, "FQDN Broker: %s", host.c_str()); + ESP_LOGI(TAG, "Broker: %s", OperatingParameters.MqttBrokerHost); + ESP_LOGI(TAG, "Username: %s", OperatingParameters.MqttBrokerUsername); + ESP_LOGI(TAG, "Password: %s", OperatingParameters.MqttBrokerPassword); // mqtt_cfg.broker.address.uri = "mqtt://iot.eclipse.org"; // mqtt_cfg.broker.address.uri = "mqtt://test.mosquitto.org:1883"; // mqtt_cfg.broker.address.transport = MQTT_TRANSPORT_OVER_TCP; @@ -469,37 +473,63 @@ bool MqttConnect(void) // // .user_context = (void *)your_context // }; - /* Initialize event group */ - s_mqtt_event_group = xEventGroupCreate(); - esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg); + if (client == NULL) + { + ESP_LOGE(TAG, "Failed to init client!"); + return false; + } OperatingParameters.MqttClient = client; - esp_mqtt_client_register_event (client, MQTT_EVENT_ANY, MqttEventHandler, client); - esp_mqtt_client_start(client); + xEventGroupClearBits (s_mqtt_event_group, MQTT_EVENT_CONNECTED_BIT | MQTT_ERROR_BIT | MQTT_EVENT_DISCONNECTED_BIT); + + esp_err_t err; + err = esp_mqtt_client_register_event (client, MQTT_EVENT_ANY, MqttEventHandler, client); + if (err != ESP_OK) + { + ESP_LOGE(TAG, "Failed to register client: 0x%x", err); + if (err == ESP_ERR_NO_MEM) ESP_LOGE(TAG, "ESP_ERR_NO_MEM"); + if (err == ESP_ERR_INVALID_ARG) ESP_LOGE(TAG, "ESP_ERR_INVALID_ARG"); + esp_mqtt_client_destroy(client); + return false; + } + + err = esp_mqtt_client_start(client); + if (err != ESP_OK) + { + ESP_LOGE(TAG, "Failed to start client: 0x%x", err); + if (err == ESP_FAIL) ESP_LOGE(TAG, "ESP_FAIL"); + if (err == ESP_ERR_INVALID_ARG) ESP_LOGE(TAG, "ESP_ERR_INVALID_ARG"); + esp_mqtt_client_unregister_event(client, MQTT_EVENT_ANY, MqttEventHandler); + esp_mqtt_client_destroy(client); + return false; + } EventBits_t bits = xEventGroupWaitBits(s_mqtt_event_group, - MQTT_EVENT_CONNECTED_BIT | MQTT_ERROR_BIT, + MQTT_EVENT_CONNECTED_BIT | MQTT_ERROR_BIT | MQTT_EVENT_DISCONNECTED_BIT, pdFALSE, pdFALSE, xTicksToWait); - if (bits & MQTT_ERROR_BIT) + // bits == 0 means timeout + if ((bits == 0) || (bits & MQTT_ERROR_BIT) || (bits & MQTT_EVENT_DISCONNECTED_BIT)) { ESP_LOGE (TAG, "MQTT Connect failed"); + // esp_mqtt_client_stop(client); // Commented out since connect never worked + ESP_LOGI(TAG, "Tearing down MQTT data structures"); + esp_mqtt_client_unregister_event(client, MQTT_EVENT_ANY, MqttEventHandler); + esp_mqtt_client_destroy(client); return false; } if (bits & MQTT_EVENT_CONNECTED_BIT) { - // MqttSubscribeTopic(client, g_mqttStatusTopic); - // MqttSubscribeTopic(client, g_deviceName + "/set/mode"); - // MqttSubscribeTopic(client, g_deviceName + "/set/temp"); + ESP_LOGI(TAG, "Subscribing to topic %s/set/#", g_deviceName); MqttSubscribeTopic(client, g_deviceName + "/set/#"); - } - // Send discovery packet to let all listeners know we have arrived - MqttHomeAssistantDiscovery(); + // Send discovery packet to let all listeners know we have arrived + MqttHomeAssistantDiscovery(); + } return true; } @@ -523,6 +553,10 @@ void MqttInit() ESP_LOGW(TAG, "MQTT is not enabled!"); return; } + + /* Initialize event group */ + s_mqtt_event_group = xEventGroupCreate(); + ESP_LOGI(TAG, "MQTT Startup..."); if (!wifiConnected()) { @@ -533,7 +567,7 @@ void MqttInit() g_deviceName = OperatingParameters.DeviceName; g_friendlyName = OperatingParameters.FriendlyName; g_mqttStatusTopic = g_deviceName + "/status"; - + OperatingParameters.MqttConnected = false; } #endif // #ifdef MQTT_ENABLED diff --git a/app/src/state_machine.cpp b/app/src/state_machine.cpp index 55576f9..3adbb64 100644 --- a/app/src/state_machine.cpp +++ b/app/src/state_machine.cpp @@ -26,6 +26,9 @@ OPERATING_PARAMETERS OperatingParameters; extern int32_t lastTimeUpdate; int32_t lastWifiReconnect = 0; +#ifdef MQTT_ENABLED +int32_t lastMqttReconnect = 0; +#endif void stateMachine(void *parameter) { @@ -33,6 +36,11 @@ void stateMachine(void *parameter) float minTemp, maxTemp; float autoMinTemp, autoMaxTemp; +#ifdef MQTT_ENABLED + // This will cause the first pass to make a connect attempt + lastMqttReconnect = MQTT_RECONNECT_DELAY * -1; +#endif + for (;;) // infinite loop { OperatingParameters.lightDetected = readLightSensor(); @@ -195,10 +203,15 @@ void stateMachine(void *parameter) OperatingParameters.wifiConnected = wifiConnected(); #ifdef MQTT_ENABLED - if ((!OperatingParameters.MqttConnected) && (OperatingParameters.MqttEnabled) && (OperatingParameters.wifiConnected)) - // MqttInit(); - //@@@ Should be a "reconnect" - MqttConnect(); + if ((OperatingParameters.wifiConnected) && (OperatingParameters.MqttEnabled) && (!OperatingParameters.MqttConnected)) + { + if (millis() > (lastMqttReconnect + MQTT_RECONNECT_DELAY)) + { + lastMqttReconnect = millis(); + //@@@ Should be a "reconnect" + MqttConnect(); + } + } #endif // Check wifi @@ -208,7 +221,7 @@ void stateMachine(void *parameter) if ((!OperatingParameters.wifiConnected) && (strlen(WifiCreds.ssid))) #endif { - if (millis() > lastWifiReconnect + 60000) + if (millis() > lastWifiReconnect + WIFI_CONNECT_INTERVAL) { lastWifiReconnect = millis(); startReconnectTask(); diff --git a/app/src/ui/ui_events.cpp b/app/src/ui/ui_events.cpp index 0140538..17f1e9e 100644 --- a/app/src/ui/ui_events.cpp +++ b/app/src/ui/ui_events.cpp @@ -345,6 +345,14 @@ void LoadConfigSettings(lv_event_t * e) lv_obj_add_state(ui_HvacFanCheckbox, LV_STATE_CHECKED); else lv_obj_clear_state(ui_HvacFanCheckbox, LV_STATE_CHECKED); + +#if !defined(MATTER_ENABLED) && !defined(MQTT_ENABLED) + lv_obj_add_flag(ui_HomeAutomationLabel, LV_OBJ_FLAG_HIDDEN); + lv_obj_add_flag(ui_HomeAutomationCheckbox, LV_OBJ_FLAG_HIDDEN); + lv_obj_add_flag(ui_SetupMqttBtn, LV_OBJ_FLAG_HIDDEN); + lv_obj_add_flag(ui_SetupMqttLabel, LV_OBJ_FLAG_HIDDEN); +#endif + #ifdef MATTER_ENABLED lv_label_set_text(ui_HomeAutomationLabel,"Matter Enable:"); if (OperatingParameters.MatterEnabled) @@ -355,6 +363,7 @@ void LoadConfigSettings(lv_event_t * e) lv_obj_add_flag(ui_SetupMqttBtn, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(ui_SetupMqttLabel, LV_OBJ_FLAG_HIDDEN); #endif + #ifdef MQTT_ENABLED lv_label_set_text(ui_HomeAutomationLabel,"MQTT Enable:"); //@@@ For now, if we compile with MQTT support, enable the config button diff --git a/app/src/web.cpp b/app/src/web.cpp index 505a3f1..a24bec2 100644 --- a/app/src/web.cpp +++ b/app/src/web.cpp @@ -3,7 +3,7 @@ * web.cpp * * This module implements the web UI page. It also provide the - * initialization of mDNS so the web page can be connected to without + * initialization of mDNS so the web page can be connected to without * knowing the IP address. * * Copyright (c) 2023 Steve Meisner (steve@meisners.net) @@ -12,21 +12,44 @@ * 17-Aug-2023: Steve Meisner (steve@meisners.net) - Initial version * 18-Aug-2023: Michael Burke (michaelburke2000@gmail.com) - WebUI refresh + reorganization * 30-Aug-2023: Steve Meisner (steve@meisners.net) - Rewrote to support ESP-IDF framework instead of Arduino + * 06-Oct-2023: Michael Burke (michaelburke2000@gmail.com) - Reimplement XML live updating, add more settings to webui + * + * + * + * Portions of this module and ../include/web_ui.h, and ONLY these two modules, are inspired by an example project by Kris Kasprzak. + * https://www.youtube.com/watch?v=pL3dhGtmcMY + * https://github.com/KrisKasprzak/ESP32_WebPage/tree/main + * Kris's project is distributed under an MIT License. + * The MIT License (MIT) + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "thermostat.hpp" #include +#include +#include "thermostat.hpp" +#include "ui/ui.h" #include "version.h" #include "web_ui.h" -#include static const char *TAG = "WEB"; -const char* serverIndex = "
"; -const char* serverRedirect = ""; static char html[2200]; +static char xml[800]; -esp_err_t tempUp(httpd_req_t *req) +void doTempUp(void) { if (OperatingParameters.tempUnits == 'C') { @@ -36,10 +59,9 @@ esp_err_t tempUp(httpd_req_t *req) OperatingParameters.tempSet += 1.0; updateHvacSetTemp(roundValue(OperatingParameters.tempSet, 0)); } - return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); } -esp_err_t tempDown(httpd_req_t *req) +void doTempDown(void) { if (OperatingParameters.tempUnits == 'C') { @@ -49,168 +71,162 @@ esp_err_t tempDown(httpd_req_t *req) OperatingParameters.tempSet -= 1.0; updateHvacSetTemp(roundValue(OperatingParameters.tempSet, 0)); } - return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); } -esp_err_t handleRoot(httpd_req_t *req) -{ - snprintf(html, sizeof(html), webUI, - (int)OperatingParameters.tempSet, OperatingParameters.tempUnits, - hvacModeToString(OperatingParameters.hvacSetMode), - hvacModeToString(OperatingParameters.hvacOpMode), - OperatingParameters.tempCurrent + OperatingParameters.tempCorrection, - OperatingParameters.tempUnits, - OperatingParameters.humidCurrent + OperatingParameters.humidityCorrection, - OperatingParameters.lightDetected, - (OperatingParameters.motionDetected == true) ? "True" : "False", - OperatingParameters.tempUnits, OperatingParameters.tempSwing, - OperatingParameters.tempCorrection, - wifiSignal(), wifiAddress(), VERSION_STRING, VERSION_BUILD_DATE_TIME, - VERSION_COPYRIGHT - ); - - return httpd_resp_send(req, html, strlen(html)); +float enforceRange(float value, float min, float max) { + if (value < min) + return min; + if (value > max) + return max; + return value; } -esp_err_t clearFirmware(httpd_req_t *req) +#define BUTTON_CONTENT_SIZE 30 +void buttonDispatch(char content[BUTTON_CONTENT_SIZE]) { - clearNVS(); - return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); + if (!strncmp(content, "tempUp", BUTTON_CONTENT_SIZE)) + doTempUp(); + else if (!strncmp(content, "tempDown", BUTTON_CONTENT_SIZE)) + doTempDown(); + else if (!strncmp(content, "hvacModeOff", BUTTON_CONTENT_SIZE)) + updateHvacMode(OFF); + else if (!strncmp(content, "hvacModeAuto", BUTTON_CONTENT_SIZE)) + updateHvacMode(AUTO); + else if (!strncmp(content, "hvacModeHeat", BUTTON_CONTENT_SIZE)) + updateHvacMode(HEAT); + else if (!strncmp(content, "hvacModeCool", BUTTON_CONTENT_SIZE)) + updateHvacMode(COOL); + else if (!strncmp(content, "hvacModeFan", BUTTON_CONTENT_SIZE)) + updateHvacMode(FAN_ONLY); + else if (!strncmp(content, "clear", BUTTON_CONTENT_SIZE)) + clearNVS(); + else if (!strncmp(content, "hvacCoolEnable", BUTTON_CONTENT_SIZE)) + OperatingParameters.hvacCoolEnable = !OperatingParameters.hvacCoolEnable; + else if (!strncmp(content, "hvacFanEnable", BUTTON_CONTENT_SIZE)) + OperatingParameters.hvacFanEnable = !OperatingParameters.hvacFanEnable; + else if (!strncmp(content, "swingUp", BUTTON_CONTENT_SIZE)) + OperatingParameters.tempSwing = enforceRange(OperatingParameters.tempSwing + 0.1, 0.0, 6.0); + else if (!strncmp(content, "swingDown", BUTTON_CONTENT_SIZE)) + OperatingParameters.tempSwing = enforceRange(OperatingParameters.tempSwing - 0.1, 0.0, 6.0); + else if (!strncmp(content, "correctionUp", BUTTON_CONTENT_SIZE)) + OperatingParameters.tempCorrection = enforceRange(OperatingParameters.tempCorrection + 0.1, -10.0, 1.0); + else if (!strncmp(content, "correctionDown", BUTTON_CONTENT_SIZE)) + OperatingParameters.tempCorrection = enforceRange(OperatingParameters.tempCorrection - 0.1, -10.0, 1.0); + else if (!strncmp(content, "twoStageEnable", BUTTON_CONTENT_SIZE)) + OperatingParameters.hvac2StageHeatEnable = !OperatingParameters.hvac2StageHeatEnable; + else if (!strncmp(content, "reverseEnable", BUTTON_CONTENT_SIZE)) + OperatingParameters.hvacReverseValveEnable = !OperatingParameters.hvacReverseValveEnable; + else if (!strncmp(content, "unitToggle", BUTTON_CONTENT_SIZE)) { + if (OperatingParameters.tempUnits == 'F') { + OperatingParameters.tempSet = (OperatingParameters.tempSet - 32.0) / (9.0/5.0); + OperatingParameters.tempCurrent = (OperatingParameters.tempCurrent - 32.0) / (9.0/5.0); + OperatingParameters.tempCorrection = OperatingParameters.tempCorrection * 5.0 / 9.0; + OperatingParameters.tempSwing = OperatingParameters.tempSwing * 5.0 / 9.0; + resetTempSmooth(); + lv_arc_set_range(ui_TempArc, 7*10, 33*10); + lv_obj_clear_flag(ui_SetTempFrac, LV_OBJ_FLAG_HIDDEN); + OperatingParameters.tempUnits = 'C'; + } + else { + OperatingParameters.tempSet = (OperatingParameters.tempSet * 9.0/5.0) + 32.0; + OperatingParameters.tempCurrent = (OperatingParameters.tempCurrent * 9.0/5.0) + 32.0; + OperatingParameters.tempCorrection = OperatingParameters.tempCorrection * 1.8; + OperatingParameters.tempSwing = OperatingParameters.tempSwing * 1.8; + resetTempSmooth(); + lv_arc_set_range(ui_TempArc, 45*10, 92*10); + lv_obj_add_flag(ui_SetTempFrac, LV_OBJ_FLAG_HIDDEN); + OperatingParameters.tempUnits = 'F'; + } + } + else + ESP_LOGI(TAG, "Could not dispatch request \"%s\"", content); } -esp_err_t hvacModeOff(httpd_req_t *req) -{ - updateHvacMode(OFF); - return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); -} +#define min(x, y) ((x < y) ? x : y) -esp_err_t hvacModeAuto(httpd_req_t *req) +esp_err_t handleButton(httpd_req_t *req) { - updateHvacMode(AUTO); - return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); + char content[BUTTON_CONTENT_SIZE]; + size_t recv_size = min(req->content_len, sizeof(content)); + httpd_resp_set_type(req, "text/xml"); + int ret = httpd_req_recv(req, content, recv_size); + content[recv_size] = '\0'; + buttonDispatch(content); + return httpd_resp_send(req, 0, 0); } -esp_err_t hvacModeHeat(httpd_req_t *req) -{ - updateHvacMode(HEAT); - return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); -} +#define CAT_IF_SPACE(xmlBuffer, other, space, request) \ + if (space < 0) { \ + ESP_LOGI(TAG, "XML buffer ran out of space. Aborting..."); \ + return httpd_resp_send_500(request); \ + } \ + strcat(xmlBuffer, other); -esp_err_t hvacModeCool(httpd_req_t *req) +esp_err_t handleXML(httpd_req_t *req) { - updateHvacMode(COOL); - return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); + char buf[128]; + ssize_t xmlSpace = sizeof(xml) - 1; + httpd_resp_set_type(req, "text/xml"); + xmlSpace -= snprintf(xml, xmlSpace, "\n"); + if (xmlSpace < 0) + return httpd_resp_send_500(req); + xmlSpace -= snprintf(buf, sizeof(buf), "%.1f\n", OperatingParameters.tempCurrent + OperatingParameters.tempCorrection); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + if (OperatingParameters.tempUnits == 'F') + xmlSpace -= snprintf(buf, sizeof(buf), "%.0f\n", OperatingParameters.tempSet); + else + xmlSpace -= snprintf(buf, sizeof(buf), "%.1f\n", OperatingParameters.tempSet); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%s\n", hvacModeToString(OperatingParameters.hvacOpMode)); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%s\n", hvacModeToString(OperatingParameters.hvacSetMode)); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%.1f\n", OperatingParameters.humidCurrent + OperatingParameters.humidityCorrection); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%d\n", OperatingParameters.lightDetected); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%s\n", OperatingParameters.motionDetected ? "True" : "False"); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%c\n", OperatingParameters.tempUnits); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%.1f\n", OperatingParameters.tempSwing); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%.1f\n", OperatingParameters.tempCorrection); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%d\n", wifiSignal()); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "
%s
\n", wifiAddress()); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%s\n", VERSION_STRING); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%s\n", VERSION_BUILD_DATE_TIME); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%s\n", VERSION_COPYRIGHT); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%d\n", OperatingParameters.hvacCoolEnable); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%d\n", OperatingParameters.hvacFanEnable); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%d\n", OperatingParameters.hvac2StageHeatEnable); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + xmlSpace -= snprintf(buf, sizeof(buf), "%d\n", OperatingParameters.hvacReverseValveEnable); + CAT_IF_SPACE(xml, buf, xmlSpace, req); + CAT_IF_SPACE(xml, "
", xmlSpace, req); + ESP_LOGD(TAG, "Remaining XML space: %ld", xmlSpace); + return httpd_resp_send(req, xml, strlen(xml)); } -esp_err_t hvacModeFan(httpd_req_t *req) +esp_err_t handleRoot(httpd_req_t *req) { - updateHvacMode(FAN_ONLY); - return httpd_resp_send(req, serverRedirect, strlen(serverRedirect)); + return httpd_resp_send(req, webUI, sizeof(webUI)); } -// server.on("/upload", HTTP_GET, []() { -// server.sendHeader("Connection", "close"); -// server.send(200, "text/html", serverIndex); -// }); - -// void webInit(void * parameter) -// { -// if (!wifiConnected()) -// Serial.printf ("*** WARNING: Starting web server while wifi down!! *****\n"); - -// MDNS.begin(WifiCreds.hostname); - -// server.on("/", handleRoot); -// server.on("/tempUp", tempUp); -// server.on("/tempDown", tempDown); - -// server.on("/clearFirmware", HTTP_GET, []() { -// clearNVS(); -// server.send(200, "text/html", serverRedirect); -// }); - -// server.on("/hvacModeOff", HTTP_GET, []() { -// OperatingParameters.hvacSetMode = OFF; -// eepromUpdateHvacSetMode(); -// server.send(200, "text/html", serverRedirect); -// }); - -// server.on("/hvacModeAuto", HTTP_GET, []() { -// OperatingParameters.hvacSetMode = AUTO; -// eepromUpdateHvacSetMode(); -// server.send(200, "text/html", serverRedirect); -// }); - -// server.on("/hvacModeHeat", HTTP_GET, []() { -// OperatingParameters.hvacSetMode = HEAT; -// eepromUpdateHvacSetMode(); -// server.send(200, "text/html", serverRedirect); -// }); - -// server.on("/hvacModeCool", HTTP_GET, []() { -// OperatingParameters.hvacSetMode = COOL; -// eepromUpdateHvacSetMode(); -// server.send(200, "text/html", serverRedirect); -// }); - -// server.on("/hvacModeFan", HTTP_GET, []() { -// OperatingParameters.hvacSetMode = FAN; -// eepromUpdateHvacSetMode(); -// server.send(200, "text/html", serverRedirect); -// }); - -// server.on("/upload", HTTP_GET, []() { -// server.sendHeader("Connection", "close"); -// server.send(200, "text/html", serverIndex); -// }); - -// server.on("/update", HTTP_POST, []() { -// server.sendHeader("Connection", "close"); -// server.send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK"); -// vTaskDelay(500 / portTICK_PERIOD_MS); -// ESP.restart(); -// }, []() { -// HTTPUpload& upload = server.upload(); -// if (upload.status == UPLOAD_FILE_START) { -// Serial.setDebugOutput(true); -// Serial.printf("Update: %s\n", upload.filename.c_str()); -// if (!Update.begin()) { //start with max available size -// Update.printError(Serial); -// } -// } else if (upload.status == UPLOAD_FILE_WRITE) { -// if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) { -// Update.printError(Serial); -// } -// } else if (upload.status == UPLOAD_FILE_END) { -// if (Update.end(true)) { //true to set the size to the current progress -// Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize); -// } else { -// Update.printError(Serial); -// } -// Serial.setDebugOutput(false); -// } else { -// Serial.printf("Update Failed Unexpectedly (likely broken connection): status=%d\n", upload.status); -// } -// }); -// server.begin(); -// MDNS.addService("http", "tcp", 80); - -// Serial.printf("Ready! Open http://%s.local in your browser\n", WifiCreds.hostname); - -// Serial.printf ("Starting web server task\n"); -// for (;;) { server.handleClient(); delay(10); } - - -// } - esp_err_t fwUpload(httpd_req_t *req) { //@@@ clearNVS(); return httpd_resp_send(req, web_fw_upload, strlen(web_fw_upload)); } -#define min(x, y) ((x < y) ? x : y) - /* * Handle OTA file upload * @@ -266,70 +282,31 @@ esp_err_t fwUpdate(httpd_req_t *req) return ESP_OK; } - - httpd_uri_t uri_get = { .uri = "/", .method = HTTP_GET, .handler = handleRoot, .user_ctx = NULL}; - -httpd_uri_t uri_tempUp = { - .uri = "/tempUp", - .method = HTTP_GET, - .handler = tempUp, - .user_ctx = NULL}; - -httpd_uri_t uri_tempDown = { - .uri = "/tempDown", - .method = HTTP_GET, - .handler = tempDown, +httpd_uri_t uri_xml = { + .uri = "/xml", + .method = HTTP_PUT, + .handler = handleXML, .user_ctx = NULL}; - -httpd_uri_t uri_clearFirmware = { - .uri = "/clearFirmware", - .method = HTTP_GET, - .handler = clearFirmware, +httpd_uri_t uri_button = { + .uri = "/button", + .method = HTTP_PUT, + .handler = handleButton, .user_ctx = NULL}; - -httpd_uri_t uri_hvacModeOff = { - .uri = "/hvacModeOff", +httpd_uri_t uri_upload = { + .uri = "/upload", .method = HTTP_GET, - .handler = hvacModeOff, + .handler = fwUpload, .user_ctx = NULL}; -httpd_uri_t uri_hvacModeAuto = { - .uri = "/hvacModeAuto", - .method = HTTP_GET, - .handler = hvacModeAuto, +httpd_uri_t uri_update = { + .uri = "/update", + .method = HTTP_POST, + .handler = fwUpdate, .user_ctx = NULL}; -httpd_uri_t uri_hvacModeHeat = { - .uri = "/hvacModeHeat", - .method = HTTP_GET, - .handler = hvacModeHeat, - .user_ctx = NULL}; -httpd_uri_t uri_hvacModeCool = { - .uri = "/hvacModeCool", - .method = HTTP_GET, - .handler = hvacModeCool, - .user_ctx = NULL}; -httpd_uri_t uri_hvacModeFan = { - .uri = "/hvacModeFan", - .method = HTTP_GET, - .handler = hvacModeFan, - .user_ctx = NULL}; - -httpd_uri_t uri_firmwareLoad = { - .uri = "/upload", - .method = HTTP_GET, - .handler = fwUpload, - .user_ctx = NULL -}; -httpd_uri_t uri_firmwareUpdate = { - .uri = "/update", - .method = HTTP_POST, - .handler = fwUpdate, - .user_ctx = NULL -}; void webStart() { @@ -339,22 +316,14 @@ void webStart() } httpd_config_t config = HTTPD_DEFAULT_CONFIG(); - config.max_uri_handlers = 11; httpd_handle_t server = NULL; if (httpd_start(&server, &config) == ESP_OK) { httpd_register_uri_handler(server, &uri_get); - httpd_register_uri_handler(server, &uri_firmwareLoad); - httpd_register_uri_handler(server, &uri_firmwareUpdate); - httpd_register_uri_handler(server, &uri_tempUp); - httpd_register_uri_handler(server, &uri_tempDown); - httpd_register_uri_handler(server, &uri_clearFirmware); - httpd_register_uri_handler(server, &uri_hvacModeOff); - httpd_register_uri_handler(server, &uri_hvacModeAuto); - httpd_register_uri_handler(server, &uri_hvacModeHeat); - httpd_register_uri_handler(server, &uri_hvacModeCool); - httpd_register_uri_handler(server, &uri_hvacModeFan); + httpd_register_uri_handler(server, &uri_xml); + httpd_register_uri_handler(server, &uri_button); + httpd_register_uri_handler(server, &uri_upload); } if (server == NULL) diff --git a/app/src/wifi.cpp b/app/src/wifi.cpp index 61fc1e6..bc99a9a 100644 --- a/app/src/wifi.cpp +++ b/app/src/wifi.cpp @@ -586,18 +586,21 @@ void WifiDeinit() } } +static int32_t lastWifiMillis = 0; +TaskHandle_t ntReconnectTaskHandler = NULL; + void WifiDisconnect() { ESP_LOGI(TAG, "WifiDisconnect()"); ESP_LOGD(TAG, "- Calling esp_wifi_disconnect()"); esp_wifi_disconnect(); + // Reset lastWifiMillis to 0 so a reconnect is enabled right away + // [see networkReconnectTask()] + lastWifiMillis = 0; OperatingParameters.wifiConnected = false; } -int32_t lastWifiMillis = 0; -TaskHandle_t ntReconnectTaskHandler = NULL; - bool wifiReconnect(const char *hostname, const char *ssid, const char *pass) { ESP_LOGI(TAG, "wifiReconnect()"); @@ -652,6 +655,7 @@ void networkReconnectTask(void *pvParameters) return; // Will never get here, but wanted to give the compiler an exit path } + // Update timestamp for last wifi connect attempt lastWifiMillis = millis(); if (wifiReconnect(OperatingParameters.DeviceName, WifiCreds.ssid, WifiCreds.password) == true) From 40acd242165590af6c00961a918af428607a8a74 Mon Sep 17 00:00:00 2001 From: Steve Meisner Date: Thu, 26 Oct 2023 17:50:58 -0400 Subject: [PATCH 06/10] Remove final printf and unused code. --- app/include/thermostat.hpp | 1 - app/src/sensors.cpp | 29 +++++++++++++---------------- app/src/state_machine.cpp | 25 ------------------------- app/src/tft.cpp | 19 +++++++++++-------- app/src/wifi.cpp | 10 +++++----- 5 files changed, 29 insertions(+), 55 deletions(-) diff --git a/app/include/thermostat.hpp b/app/include/thermostat.hpp index 2ff1e9a..5c04152 100644 --- a/app/include/thermostat.hpp +++ b/app/include/thermostat.hpp @@ -158,7 +158,6 @@ void MqttHomeAssistantDiscovery(); // State Machine void stateCreateTask(); -void serialStart(); extern int32_t lastWifiReconnect; // EEPROM diff --git a/app/src/sensors.cpp b/app/src/sensors.cpp index 89d6304..01d354f 100644 --- a/app/src/sensors.cpp +++ b/app/src/sensors.cpp @@ -164,33 +164,30 @@ bool ld2410_init() if (radar.begin(RadarPort)) { - printf("LD2410: Sensor started\n"); + ESP_LOGI(TAG, "LD2410: Sensor started"); rc = true; if (radar.requestFirmwareVersion()) { - printf ("LD2410: Firmware: v%u.%02u.%u%u%u%u\n", + ESP_LOGI(TAG, "LD2410: Firmware: v%u.%02u.%08x", radar.firmware_major_version, radar.firmware_minor_version, - (uint8_t)(radar.firmware_bugfix_version & 0xff000000) >> 24, - (uint8_t)(radar.firmware_bugfix_version & 0x00ff0000) >> 16, - (uint8_t)(radar.firmware_bugfix_version & 0x0000ff00) >> 8, - (uint8_t)radar.firmware_bugfix_version & 0x000000ff + radar.firmware_bugfix_version ); } else { - printf ("LD2410: Failed to read firmware version\n"); + ESP_LOGE(TAG, "LD2410: Failed to read firmware version\n"); } if (radar.requestCurrentConfiguration()) { - printf("LD2410: Maximum gate ID: %d\n", radar.max_gate); - printf("LD2410: Maximum gate for moving targets: %d\n", radar.max_moving_gate); - printf("LD2410: Maximum gate for stationary targets: %d\n", radar.max_stationary_gate); - printf("LD2410: Idle time for targets: %d\n", radar.sensor_idle_time); - printf("LD2410: Gate sensitivity\n"); + ESP_LOGI(TAG, "LD2410: Maximum gate ID: %d", radar.max_gate); + ESP_LOGI(TAG, "LD2410: Maximum gate for moving targets: %d", radar.max_moving_gate); + ESP_LOGI(TAG, "LD2410: Maximum gate for stationary targets: %d", radar.max_stationary_gate); + ESP_LOGI(TAG, "LD2410: Idle time for targets: %d", radar.sensor_idle_time); + ESP_LOGI(TAG, "LD2410: Gate sensitivity"); for (uint8_t gate = 0; gate <= radar.max_gate; gate++) { - printf(" Gate %d moving targets: %d stationary targets: %d\n", + ESP_LOGI(TAG, " Gate %d moving targets: %d stationary targets: %d", gate, radar.motion_sensitivity[gate], radar.stationary_sensitivity[gate]); } } @@ -208,15 +205,15 @@ bool ld2410_init() // limited to 0 (0.75m). Use this to also change the inactivity timer. // //bool setMaxValues(uint16_t moving, uint16_t stationary, uint16_t inactivityTimer); - if (radar.setMaxValues(1, 0, (MOTION_TIMEOUT / 2000))) printf ("LD2410: Max gate values set\n"); else printf ("LD2410: FAILED to set max gate values\n"); + if (radar.setMaxValues(1, 0, (MOTION_TIMEOUT / 2000))) ESP_LOGI(TAG, "LD2410: Max gate values set"); else ESP_LOGE(TAG, "LD2410: FAILED to set max gate values"); // // Now request a restart to enable all the setting specified above // - if (radar.requestRestart()) printf ("LD2410: Restart requested\n"); else printf ("LD2410: FAILED requesting restart\n"); + if (radar.requestRestart()) ESP_LOGW(TAG, "LD2410: Restart requested"); else ESP_LOGE(TAG, "LD2410: FAILED requesting restart"); } else { - printf ("LD2410: Sensor not connected\n"); + ESP_LOGE(TAG, "LD2410: Sensor not connected"); rc = false; } return rc; diff --git a/app/src/state_machine.cpp b/app/src/state_machine.cpp index 3adbb64..4521127 100644 --- a/app/src/state_machine.cpp +++ b/app/src/state_machine.cpp @@ -282,28 +282,3 @@ void stateCreateTask() tskIDLE_PRIORITY - 1, NULL); } - -void serialStart() -{ - // - // Serial port mapping: - // - // Serial relates to the onboard UART port - // Serial1 is mapped (I believe) to the SWD port - // Serial2 is the USB port directly connected to the ESP32 - // NB: Serial2 is remapped to provide serial comms with the LD2410 - // - // Do not use Serial2 as this will disable firmware uploading - // and debugging via the USB port. It will also cause the USB - // interface to not show up as a USB device to the host. - // - - // int32_t tmo = millis() + 60000; - //Serial.begin(115200); - // Serial.setDebugOutput(true); - printf("UART Serial port (via UART-USB adapter -> usually /dev/ttyUSB0)\n"); - - // Serial1.begin(115200); - // Serial1.setDebugOutput(true); - // Serial1.printf("SERIAL1\n"); -} \ No newline at end of file diff --git a/app/src/tft.cpp b/app/src/tft.cpp index 4026b83..bb2e1be 100644 --- a/app/src/tft.cpp +++ b/app/src/tft.cpp @@ -42,18 +42,20 @@ int32_t lastMotionDetected = 0; volatile bool tftMotionTrigger = false; +#define TAG "TFT" + #ifdef __cplusplus extern "C" { #endif void tftDisableTouchTimer() { - printf ("Disabling touch timer\n"); + ESP_LOGI(TAG, "Disabling touch/motion timer"); tftTouchTimerEnabled = false; } void tftEnableTouchTimer() { - printf ("Enabling touch timer\n"); + ESP_LOGI(TAG, "Enabling touch/motion timer"); tftTouchTimerEnabled = true; } @@ -100,7 +102,7 @@ void tftWakeDisplayMotion() // float ratio = (float)(OperatingParameters.lightDetected) / 3150.0; // Measured in mV (max = 3.15 V) int brightness = (int)(ratio * (float)(FULL_BRIGHTNESS)); tftShowDisplayItems(); - printf ("Setting display to partial brightness: %d (%d%%)\n", + ESP_LOGI(TAG, "Setting display to partial brightness: %d (%d%%)", brightness, (int)(ratio*100.0)); tft.setBrightness(brightness); tftEnableTouchTimer(); @@ -112,6 +114,7 @@ void tftDimDisplay() { if (tftTouchTimerEnabled) { + ESP_LOGD(TAG, "Dimming display"); tft.setBrightness(OFF_BRIGHTNESS); tftHideDisplayItems(); tftDisableTouchTimer(); @@ -324,8 +327,8 @@ Cal data: // Use calData to set up touch dimensions tft.setTouchCalibrate(calData); // Dump data to debug logger - printf ("Touch Screen calibration data:\n"); - for (int n=0; n < 8; n++) printf("%d : %d\n", n, calData[n]); + ESP_LOGI (TAG, "Touch Screen calibration data:"); + for (int n=0; n < 8; n++) ESP_LOGI (TAG, "%d : %d", n, calData[n]); } void tftInit() @@ -360,7 +363,7 @@ void tftInit() setHvacModesDropdown(); - printf("Current temp set to %.1f°\n", OperatingParameters.tempSet); + ESP_LOGI (TAG, "Current temp set to %.1f°", OperatingParameters.tempSet); lv_arc_set_value(ui_TempArc, OperatingParameters.tempSet*10); lv_label_set_text_fmt(ui_SetTemp, "%d°", (int)OperatingParameters.tempSet); @@ -414,7 +417,7 @@ void tftPump(void * parameter) // if (/*(lastMotionDetected == 0) &&*/ (!tftTouchTimerEnabled) && isCurrentScreenMain()) { - printf("Motion wake triggered\n"); + ESP_LOGI (TAG, "Motion wake triggered"); lastMotionDetected = millis(); OperatingParameters.motionDetected = true; tftWakeDisplayMotion(); @@ -429,7 +432,7 @@ void tftPump(void * parameter) { if (millis() - lastMotionDetected > MOTION_TIMEOUT) { - printf ("Motion detection timeout\n"); + ESP_LOGI (TAG, "Motion detection timeout"); OperatingParameters.motionDetected = false; } } diff --git a/app/src/wifi.cpp b/app/src/wifi.cpp index bc99a9a..2ceab95 100644 --- a/app/src/wifi.cpp +++ b/app/src/wifi.cpp @@ -380,15 +380,15 @@ void wifiSwitchMatterMode() { // Setting MatterStarted keeps networkReconnect task from running OperatingParameters.MatterStarted = true; - Serial.printf ("Enabling Matter\n"); + ESP_LOGI(TAG, "Enabling Matter"); // Since we are shutting down wifi to enable Matter, // do not allow callbacks to take any action. wifiDeregisterEventCallbacks(); - Serial.printf ("Shutting down wifi connection\n"); + ESP_LOGI(TAG, "Shutting down wifi connection"); WifiDisconnect(); - Serial.printf ("Unloading wifi driver\n"); + ESP_LOGI(TAG, "Unloading wifi driver"); WifiDeinit(); - Serial.printf ("Starting Matter API\n"); + ESP_LOGI(TAG, "Starting Matter API"); OperatingParameters.MatterStarted = MatterInit(); // Serial.printf ("Connecting to wifi\n"); // OperatingParameters.wifiConnected = @@ -396,7 +396,7 @@ void wifiSwitchMatterMode() } else { - Serial.printf ("Disabling Matter\n"); + ESP_LOGI(TAG, "Disabling Matter"); updateThermostatParams(); // ESP restart will happen as part of UI code (see ui_events.cpp) } From 49a35f2a82f2296e50e2a1dd2296c28cd3f79b9f Mon Sep 17 00:00:00 2001 From: Steve Meisner Date: Fri, 27 Oct 2023 21:19:48 -0400 Subject: [PATCH 07/10] Updated diag message --- app/src/mqtt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/mqtt.cpp b/app/src/mqtt.cpp index 2a7fe47..ae9bb6a 100644 --- a/app/src/mqtt.cpp +++ b/app/src/mqtt.cpp @@ -516,7 +516,7 @@ bool MqttConnect(void) { ESP_LOGE (TAG, "MQTT Connect failed"); // esp_mqtt_client_stop(client); // Commented out since connect never worked - ESP_LOGI(TAG, "Tearing down MQTT data structures"); + ESP_LOGW(TAG, "Removing MQTT data structures"); esp_mqtt_client_unregister_event(client, MQTT_EVENT_ANY, MqttEventHandler); esp_mqtt_client_destroy(client); return false; From cfe5fb059c0996be0b998927a48230693ecbe3ef Mon Sep 17 00:00:00 2001 From: Steve Meisner Date: Fri, 27 Oct 2023 21:42:34 -0400 Subject: [PATCH 08/10] Fix typo --- app/src/mqtt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/mqtt.cpp b/app/src/mqtt.cpp index ae9bb6a..f7a39b6 100644 --- a/app/src/mqtt.cpp +++ b/app/src/mqtt.cpp @@ -450,7 +450,7 @@ bool MqttConnect(void) // OperatingParameters.MqttBrokerPassword = (char *)malloc(72); // strcpy (OperatingParameters.MqttBrokerPassword, "einiiZeiphah4ish0Rowae7doh0OhNg6wahngohmie4iNae1meipainaeyijai5i"); - ESP_LOGI(TAG, "FQDN Broker: %s", host.c_str()); + ESP_LOGI(TAG, "Broker FQDN: %s", host.c_str()); ESP_LOGI(TAG, "Broker: %s", OperatingParameters.MqttBrokerHost); ESP_LOGI(TAG, "Username: %s", OperatingParameters.MqttBrokerUsername); ESP_LOGI(TAG, "Password: %s", OperatingParameters.MqttBrokerPassword); From 0d3961d5955cb1f173074f91b84c51af1e145d89 Mon Sep 17 00:00:00 2001 From: Steve Meisner Date: Fri, 27 Oct 2023 21:44:09 -0400 Subject: [PATCH 09/10] ...more typos fixed --- app/src/mqtt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/mqtt.cpp b/app/src/mqtt.cpp index f7a39b6..64c3592 100644 --- a/app/src/mqtt.cpp +++ b/app/src/mqtt.cpp @@ -425,9 +425,9 @@ void MqttSubscribeTopic(esp_mqtt_client_handle_t client, std::string topic) int msg_id; msg_id = esp_mqtt_client_subscribe(client, topic.c_str(), 1); if (msg_id < 0) - ESP_LOGE (TAG, "Send subscribe FAILED, Topic=%s, msg_id=%d", topic.c_str(), msg_id); + ESP_LOGE (TAG, "Subscribe topic FAILED, Topic=%s, msg_id=%d", topic.c_str(), msg_id); else - ESP_LOGI (TAG, "Send subscribe successful, Topic=%s, msg_id=%d", topic.c_str(), msg_id); + ESP_LOGI (TAG, "Subscribe topic successful, Topic=%s, msg_id=%d", topic.c_str(), msg_id); } bool MqttConnect(void) From 3747eef42d7fc271400611ffae55a51dd1bfefaa Mon Sep 17 00:00:00 2001 From: Steve Meisner Date: Sat, 28 Oct 2023 09:25:34 -0400 Subject: [PATCH 10/10] Change time vars to 64-bit (wrapped @ 24.85 days); consistent temp setting; stop resetting relays @ start --- app/include/thermostat.hpp | 11 ++++---- app/src/indicators.cpp | 16 +++++++---- app/src/main.cpp | 12 +++++--- app/src/sensors.cpp | 57 +++++++++++++++++++------------------- app/src/state_machine.cpp | 6 ++-- app/src/tft.cpp | 6 ++-- app/src/ui/ui_events.cpp | 8 +++--- app/src/wifi.cpp | 2 +- 8 files changed, 64 insertions(+), 54 deletions(-) diff --git a/app/include/thermostat.hpp b/app/include/thermostat.hpp index 5c04152..ab8c1cc 100644 --- a/app/include/thermostat.hpp +++ b/app/include/thermostat.hpp @@ -113,7 +113,7 @@ typedef struct extern OPERATING_PARAMETERS OperatingParameters; extern WIFI_CREDS WifiCreds; -extern int32_t ui_WifiStatusLabel_timestamp; +extern int64_t ui_WifiStatusLabel_timestamp; #ifdef MQTT_ENABLED #define MQTT_RECONNECT_DELAY 75000 @@ -140,7 +140,7 @@ extern void app_main(); } /*extern "C"*/ #endif -int32_t millis(); // Defined in main.cpp +int64_t millis(); // Defined in main.cpp void showConfigurationData(); void scanI2cBus(); @@ -158,7 +158,7 @@ void MqttHomeAssistantDiscovery(); // State Machine void stateCreateTask(); -extern int32_t lastWifiReconnect; +extern int64_t lastWifiReconnect; // EEPROM void eepromInit(); @@ -218,12 +218,13 @@ void updateHvacSetTemp(float setTemp); // float roundValue(float value, int places = 0); float roundValue(float value, int places); float getRoundedFrac(float value); +void initTimeSntp(); // int degCfrac(float tempF); // int tempOut(float tempF); // float tempIn(float tempC); // float degFtoC(float degF); void resetTempSmooth(); -bool sensorsInit(); +void sensorsInit(); void initRelays(); int getTemp(); int getHumidity(); @@ -237,7 +238,7 @@ void audioBeep(); // SNTP Time Sync void updateTimezone(); -bool getLocalTime(struct tm *, uint32_t); +bool getLocalTime(struct tm *, uint64_t); void updateTimeSntp(); // ui_events.cpp diff --git a/app/src/indicators.cpp b/app/src/indicators.cpp index af80255..528d35e 100644 --- a/app/src/indicators.cpp +++ b/app/src/indicators.cpp @@ -77,7 +77,7 @@ void audioStartupBeep() } // Use lastBeep to rate limit the beeping -unsigned long lastBeep = 0; +uint64_t lastBeep = 0; void audioBeep() { @@ -119,19 +119,23 @@ void audioBeep() void initRelays() { - vTaskDelay(pdMS_TO_TICKS(500)); + vTaskDelay(pdMS_TO_TICKS(250)); - gpio_reset_pin((gpio_num_t)HVAC_HEAT_PIN); gpio_set_direction((gpio_num_t)HVAC_HEAT_PIN, GPIO_MODE_OUTPUT); + gpio_set_level((gpio_num_t)HVAC_HEAT_PIN, LOW); + // gpio_reset_pin((gpio_num_t)HVAC_HEAT_PIN); - gpio_reset_pin((gpio_num_t)HVAC_COOL_PIN); gpio_set_direction((gpio_num_t)HVAC_COOL_PIN, GPIO_MODE_OUTPUT); + gpio_set_level((gpio_num_t)HVAC_COOL_PIN, LOW); + // gpio_reset_pin((gpio_num_t)HVAC_COOL_PIN); - gpio_reset_pin((gpio_num_t)HVAC_FAN_PIN); gpio_set_direction((gpio_num_t)HVAC_FAN_PIN, GPIO_MODE_OUTPUT); + gpio_set_level((gpio_num_t)HVAC_FAN_PIN, LOW); + // gpio_reset_pin((gpio_num_t)HVAC_FAN_PIN); - gpio_reset_pin((gpio_num_t)HVAC_RVALV_PIN); gpio_set_direction((gpio_num_t)HVAC_RVALV_PIN, GPIO_MODE_OUTPUT); + gpio_set_level((gpio_num_t)HVAC_RVALV_PIN, LOW); + // gpio_reset_pin((gpio_num_t)HVAC_RVALV_PIN); } diff --git a/app/src/main.cpp b/app/src/main.cpp index e2c9c0d..a08fbd5 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -24,9 +24,10 @@ #include "thermostat.hpp" #include "esp_timer.h" -int32_t millis() { return esp_timer_get_time() / 1000;} #define TAG "Main" +int64_t millis() { return esp_timer_get_time() / 1000;} + void app_main() { ESP_LOGI (TAG, "IDF version: %s", esp_get_idf_version()); @@ -43,6 +44,10 @@ void app_main() ESP_LOGI (TAG, "Starting TFT task"); tftCreateTask(); + // Initialize sensors (temp, humidity, motion, etc) + ESP_LOGI (TAG, "Initializing sensors"); + sensorsInit(); + #ifdef MATTER_ENABLED // Start Matter ESP_LOGI (TAG, "Starting Matter"); @@ -62,14 +67,13 @@ void app_main() MqttInit(); #endif + // Start SNTP connection to get local time + initTimeSntp(); // Initialize indicators (relays, LEDs, buzzer) ESP_LOGI (TAG, "Initializing indicators"); indicatorsInit(); initRelays(); - // Initialize sensors (temp, humidity, motion, etc) - ESP_LOGI (TAG, "Initializing sensors"); - sensorsInit(); // Create the RTOS task to drive the state machine ESP_LOGI (TAG, "Starting state machine task"); diff --git a/app/src/sensors.cpp b/app/src/sensors.cpp index 01d354f..04006ee 100644 --- a/app/src/sensors.cpp +++ b/app/src/sensors.cpp @@ -37,11 +37,11 @@ const char *gmt_timezones[] = {"GMT-12", "GMT-11", "GMT-10", "GMT-9", "GMT-8", "GMT-7", "GMT-6", "GMT-5", "GMT-4", "GMT-3", "GMT-2", "GMT-1" "GMT", "GMT+1", "GMT+2", "GMT+3", "GMT+4", "GMT+5", "GMT+6", "GMT+7", "GMT+8", "GMT+9", "GMT+10", "GMT+11"}; -int32_t lastTimeUpdate = 0; +int64_t lastTimeUpdate = 0; Stream RadarPort; ld2410 radar; -uint32_t last_ld2410_Reading = 0; +uint64_t last_ld2410_Reading = 0; Smoothed sensorTemp; Smoothed sensorHumidity; @@ -65,6 +65,7 @@ void updateHvacSetTemp(float setTemp) { OperatingParameters.tempSet = setTemp; eepromUpdateHvacSetTemp(); + ESP_LOGI(TAG, "Set temp: %.1f", setTemp); #ifdef MQTT_ENABLED MqttUpdateStatusTopic(); #endif @@ -126,7 +127,6 @@ float roundValue(float value, int places) r = (float)((int)(value + 0.5)); if (places == 1) r = (float)((int)(value + 0.25) + (getRoundedFrac(value + 0.25) / 10.0)); - ESP_LOGI(TAG, "%.1f", r); return r; } @@ -299,6 +299,27 @@ void updateAht(void *parameter) } } +bool startAht() +{ + if (initAht()) + { + xTaskCreate( + updateAht, // Function that should be called + "Update AHT", // Name of the task (for debugging) + 4096, // Stack size (bytes) + NULL, // Parameter to pass + tskIDLE_PRIORITY + 1, // Task priority + NULL // Task handle + ); + + return true; + } + else + { + return false; + } +} + // Read sensor temp and return rounded up and correction applied int getTemp() { @@ -336,10 +357,10 @@ void updateTimezone() tzset(); } -bool getLocalTime(struct tm * info, uint32_t ms) +bool getLocalTime(struct tm * info, uint64_t ms) { - uint32_t start = millis(); - uint32_t tmo = ms; + uint64_t start = millis(); + uint64_t tmo = ms; time_t now; if (!wifiConnected()) @@ -395,34 +416,14 @@ void initTimeSntp() /*--------------------------------------------------------------- Init code for sensors entry point ---------------------------------------------------------------*/ -bool sensorsInit() +void sensorsInit() { sensorTemp.begin(SMOOTHED_EXPONENTIAL, 10); sensorHumidity.begin(SMOOTHED_EXPONENTIAL, 10); sensorTemp.clear(); sensorHumidity.clear(); - initTimeSntp(); - + startAht(); ld2410_init(); - initLightSensor(); - - if (initAht()) - { - xTaskCreate( - updateAht, // Function that should be called - "Update AHT", // Name of the task (for debugging) - 4096, // Stack size (bytes) - NULL, // Parameter to pass - tskIDLE_PRIORITY + 1, // Task priority - NULL // Task handle - ); - - return true; - } - else - { - return false; - } } diff --git a/app/src/state_machine.cpp b/app/src/state_machine.cpp index 4521127..68e98ab 100644 --- a/app/src/state_machine.cpp +++ b/app/src/state_machine.cpp @@ -24,10 +24,10 @@ #define LOW 0 OPERATING_PARAMETERS OperatingParameters; -extern int32_t lastTimeUpdate; -int32_t lastWifiReconnect = 0; +extern int64_t lastTimeUpdate; +int64_t lastWifiReconnect = 0; #ifdef MQTT_ENABLED -int32_t lastMqttReconnect = 0; +int64_t lastMqttReconnect = 0; #endif void stateMachine(void *parameter) diff --git a/app/src/tft.cpp b/app/src/tft.cpp index bb2e1be..c4be1bf 100644 --- a/app/src/tft.cpp +++ b/app/src/tft.cpp @@ -32,13 +32,13 @@ static char thermostatModes[48] = {0}; TaskHandle_t xTouchUIHandle; -int32_t lastTouchDetected = 0; +int64_t lastTouchDetected = 0; bool tftTouchTimerEnabled = true; -int32_t ui_WifiStatusLabel_timestamp = 0; +int64_t ui_WifiStatusLabel_timestamp = 0; uint16_t calData_2_8[8] = { 3839, 336, 3819, 3549, 893, 390, 718, 3387 }; uint16_t calData_3_2[8] = { 3778, 359, 3786, 3803, 266, 347, 258, 3769 }; uint16_t calData[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; -int32_t lastMotionDetected = 0; +int64_t lastMotionDetected = 0; volatile bool tftMotionTrigger = false; diff --git a/app/src/ui/ui_events.cpp b/app/src/ui/ui_events.cpp index 17f1e9e..c1c9122 100644 --- a/app/src/ui/ui_events.cpp +++ b/app/src/ui/ui_events.cpp @@ -29,10 +29,10 @@ void tftDecreaseSetTemp(lv_event_t * e) if (OperatingParameters.tempUnits == 'C') { OperatingParameters.tempSet -= 0.5; - OperatingParameters.tempSet = roundValue(OperatingParameters.tempSet, 1); + updateHvacSetTemp(roundValue(OperatingParameters.tempSet, 1)); } else { OperatingParameters.tempSet -= 1.0; - OperatingParameters.tempSet = roundValue(OperatingParameters.tempSet, 0); + updateHvacSetTemp(roundValue(OperatingParameters.tempSet, 0)); } lv_arc_set_value(ui_TempArc, OperatingParameters.tempSet*10); lv_label_set_text_fmt(ui_SetTemp, "%d°", int(OperatingParameters.tempSet)); @@ -47,10 +47,10 @@ void tftIncreaseSetTemp(lv_event_t * e) if (OperatingParameters.tempUnits == 'C') { OperatingParameters.tempSet += 0.5; - OperatingParameters.tempSet = roundValue(OperatingParameters.tempSet, 1); + updateHvacSetTemp(roundValue(OperatingParameters.tempSet, 1)); } else { OperatingParameters.tempSet += 1.0; - OperatingParameters.tempSet = roundValue(OperatingParameters.tempSet, 0); + updateHvacSetTemp(roundValue(OperatingParameters.tempSet, 0)); } lv_arc_set_value(ui_TempArc, OperatingParameters.tempSet*10); lv_label_set_text_fmt(ui_SetTemp, "%d°", int(OperatingParameters.tempSet)); diff --git a/app/src/wifi.cpp b/app/src/wifi.cpp index 2ceab95..1b69fbc 100644 --- a/app/src/wifi.cpp +++ b/app/src/wifi.cpp @@ -586,7 +586,7 @@ void WifiDeinit() } } -static int32_t lastWifiMillis = 0; +static int64_t lastWifiMillis = 0; TaskHandle_t ntReconnectTaskHandler = NULL; void WifiDisconnect()