mirror of
https://git.beihong.wang/wangbeihong/iot-bedroom-environment-controller.git
synced 2026-04-23 18:53:03 +08:00
Add Zone.Identifier files for wifi-connect and partitions
- Created new Zone.Identifier file in components/wifi-connect with ZoneId=3. - Created new Zone.Identifier file in partitions.csv with ZoneId=3.
This commit is contained in:
@@ -20,10 +20,8 @@ void ui_display_init(void);
|
||||
* @param temperature 温度值(°C),-1.0表示无效
|
||||
* @param humidity 湿度值(%),-1.0表示无效
|
||||
* @param lux 光照强度(lx),-1.0表示无效
|
||||
* @param ppm 空气中有害气体浓度(ppm)
|
||||
* @param quality_level 空气质量等级描述
|
||||
*/
|
||||
void ui_update_sensor_data(float temperature, float humidity, float lux, float ppm, const char* quality_level);
|
||||
void ui_update_sensor_data(float temperature, float humidity, float lux);
|
||||
|
||||
/* Time page APIs */
|
||||
void ui_show_time_page(void);
|
||||
|
||||
@@ -10,7 +10,6 @@ static const char *TAG = "ui_display";
|
||||
static lv_obj_t *temp_label = NULL;
|
||||
static lv_obj_t *humid_label = NULL;
|
||||
static lv_obj_t *lux_label = NULL;
|
||||
static lv_obj_t *air_quality_label = NULL; // 新增空气质量标签
|
||||
|
||||
/* Time page objects */
|
||||
static lv_obj_t *time_container = NULL;
|
||||
@@ -28,54 +27,42 @@ void ui_display_init(void)
|
||||
{
|
||||
// 获取当前活动屏幕对象
|
||||
lv_obj_t *scr = lv_scr_act();
|
||||
|
||||
|
||||
/* 任务锁定 */
|
||||
lvgl_port_lock(0);
|
||||
|
||||
|
||||
/* 设置屏幕背景为白色 */
|
||||
lv_obj_set_style_bg_color(scr, lv_color_white(), 0);
|
||||
lv_obj_set_style_bg_opa(scr, LV_OPA_COVER, 0);
|
||||
|
||||
|
||||
/* 创建标题标签 */
|
||||
lv_obj_t *title_label = lv_label_create(scr);
|
||||
lv_label_set_text(title_label, "IoT Home Monitor");
|
||||
lv_obj_set_style_text_color(title_label, lv_palette_main(LV_PALETTE_BLUE), 0);
|
||||
lv_label_set_text(title_label, "IOT Home");
|
||||
lv_obj_set_style_text_color(title_label, lv_color_black(), 0);
|
||||
lv_obj_set_style_text_font(title_label, &lv_font_unscii_8, 0);
|
||||
lv_obj_align(title_label, LV_ALIGN_TOP_MID, 0, 2); // 调整标题位置
|
||||
|
||||
/* 创建温度标签 */
|
||||
lv_obj_align(title_label, LV_ALIGN_TOP_MID, 0, 6);
|
||||
|
||||
/* 创建传感器数据显示标签 */
|
||||
temp_label = lv_label_create(scr);
|
||||
lv_label_set_text(temp_label, "Temp: --.- C");
|
||||
lv_obj_set_style_text_color(temp_label, lv_color_black(), 0);
|
||||
lv_obj_set_style_text_font(temp_label, &lv_font_unscii_8, 0);
|
||||
lv_obj_align(temp_label, LV_ALIGN_TOP_LEFT, 3, 20); // 调整位置
|
||||
|
||||
/* 创建湿度标签 */
|
||||
lv_obj_align(temp_label, LV_ALIGN_TOP_LEFT, 3, 30);
|
||||
|
||||
humid_label = lv_label_create(scr);
|
||||
lv_label_set_text(humid_label, "Humidity: --.- %");
|
||||
lv_obj_set_style_text_color(humid_label, lv_color_black(), 0);
|
||||
lv_obj_set_style_text_font(humid_label, &lv_font_unscii_8, 0);
|
||||
lv_obj_align(humid_label, LV_ALIGN_TOP_LEFT, 3, 35); // 调整位置
|
||||
|
||||
lv_obj_align(humid_label, LV_ALIGN_TOP_LEFT, 3, 45);
|
||||
|
||||
/* 创建光照标签 */
|
||||
lux_label = lv_label_create(scr);
|
||||
lv_label_set_text(lux_label, "Light: --.- lux");
|
||||
lv_obj_set_style_text_color(lux_label, lv_color_black(), 0);
|
||||
lv_obj_set_style_text_font(lux_label, &lv_font_unscii_8, 0);
|
||||
lv_obj_align(lux_label, LV_ALIGN_TOP_LEFT, 3, 50); // 调整位置
|
||||
|
||||
/* 创建空气质量标签 */
|
||||
air_quality_label = lv_label_create(scr);
|
||||
lv_label_set_text(air_quality_label, "IAQ : --.- Index");
|
||||
lv_obj_set_style_text_color(air_quality_label, lv_color_black(), 0);
|
||||
lv_obj_set_style_text_font(air_quality_label, &lv_font_unscii_8, 0);
|
||||
lv_obj_align(air_quality_label, LV_ALIGN_TOP_LEFT, 3, 65); // 调整位置
|
||||
|
||||
/* 任务解锁 */
|
||||
lvgl_port_unlock();
|
||||
lv_obj_align(lux_label, LV_ALIGN_TOP_LEFT, 3, 60);
|
||||
|
||||
// 创建时间页面(初始隐藏)
|
||||
lvgl_port_lock(0);
|
||||
/* 创建时间页面(初始隐藏) */
|
||||
time_container = lv_obj_create(lv_scr_act());
|
||||
lv_obj_set_size(time_container, lv_pct(100), lv_pct(100));
|
||||
lv_obj_set_style_bg_color(time_container, lv_color_white(), 0);
|
||||
@@ -94,12 +81,12 @@ void ui_display_init(void)
|
||||
lv_obj_align(time_label, LV_ALIGN_CENTER, 0, 12);
|
||||
|
||||
// 默认显示时间页面,隐藏传感器页面
|
||||
lv_obj_clear_flag(time_container, LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(time_container, LV_OBJ_FLAG_HIDDEN);
|
||||
if (temp_label) lv_obj_add_flag(temp_label, LV_OBJ_FLAG_HIDDEN);
|
||||
if (humid_label) lv_obj_add_flag(humid_label, LV_OBJ_FLAG_HIDDEN);
|
||||
if (lux_label) lv_obj_add_flag(lux_label, LV_OBJ_FLAG_HIDDEN);
|
||||
if (air_quality_label) lv_obj_add_flag(air_quality_label, LV_OBJ_FLAG_HIDDEN);
|
||||
time_page_visible = true;
|
||||
|
||||
lvgl_port_unlock();
|
||||
}
|
||||
|
||||
@@ -111,17 +98,15 @@ void ui_display_init(void)
|
||||
* @param temperature 温度值(°C),-1.0表示无效
|
||||
* @param humidity 湿度值(%),-1.0表示无效
|
||||
* @param lux 光照强度(lx),-1.0表示无效
|
||||
* @param ppm 空气中有害气体浓度(ppm)
|
||||
* @param quality_level 空气质量等级描述
|
||||
*/
|
||||
void ui_update_sensor_data(float temperature, float humidity, float lux, float ppm, const char* quality_level)
|
||||
void ui_update_sensor_data(float temperature, float humidity, float lux)
|
||||
{
|
||||
if (temp_label != NULL && humid_label != NULL && lux_label != NULL && air_quality_label != NULL)
|
||||
if (temp_label != NULL && humid_label != NULL && lux_label != NULL)
|
||||
{
|
||||
/* 任务锁定 */
|
||||
lvgl_port_lock(0);
|
||||
|
||||
// 更新温度标签 - 缩短文本以节省空间
|
||||
|
||||
// 更新温度标签
|
||||
if (temperature >= -0.5) // -1.0表示无效
|
||||
{
|
||||
char temp_str[32];
|
||||
@@ -132,8 +117,8 @@ void ui_update_sensor_data(float temperature, float humidity, float lux, float p
|
||||
{
|
||||
lv_label_set_text(temp_label, "Temp: Invalid");
|
||||
}
|
||||
|
||||
// 更新湿度标签 - 缩短文本以节省空间
|
||||
|
||||
// 更新湿度标签
|
||||
if (humidity >= -0.5) // -1.0表示无效
|
||||
{
|
||||
char humid_str[32];
|
||||
@@ -145,8 +130,8 @@ void ui_update_sensor_data(float temperature, float humidity, float lux, float p
|
||||
lv_label_set_text(humid_label, "Humidity: Invalid");
|
||||
}
|
||||
|
||||
// 更新光照标签 - 缩短文本以节省空间
|
||||
if (lux >= -0.5) // -1.0表示无效
|
||||
// 更新光照标签
|
||||
if (lux >= -0.5)
|
||||
{
|
||||
char lux_str[32];
|
||||
snprintf(lux_str, sizeof(lux_str), "Light: %.2f lx", lux);
|
||||
@@ -156,34 +141,7 @@ void ui_update_sensor_data(float temperature, float humidity, float lux, float p
|
||||
{
|
||||
lv_label_set_text(lux_label, "Light: Invalid");
|
||||
}
|
||||
|
||||
// 更新空气质量标签 - 缩短文本以节省空间
|
||||
if (ppm >= 0) // 空气质量值有效
|
||||
{
|
||||
char ppm_str[32];
|
||||
snprintf(ppm_str, sizeof(ppm_str), "IAQ : %.2f Index", ppm);
|
||||
|
||||
// 根据空气质量等级更改颜色
|
||||
lv_color_t color = lv_color_black(); // 默认黑色
|
||||
if (ppm <= 20.0f) {
|
||||
color = lv_color_make(0, 128, 0); // 绿色 - 空气质量优秀
|
||||
} else if (ppm <= 100.0f) {
|
||||
color = lv_color_make(0, 0, 0); // 黑色 - 空气质量良好
|
||||
} else if (ppm <= 300.0f) {
|
||||
color = lv_color_make(255, 165, 0); // 橙色 - 轻度污染
|
||||
} else {
|
||||
color = lv_color_make(255, 0, 0); // 红色 - 中重度污染
|
||||
}
|
||||
|
||||
lv_label_set_text(air_quality_label, ppm_str);
|
||||
lv_obj_set_style_text_color(air_quality_label, color, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_label_set_text(air_quality_label, "IAQ : Invalid");
|
||||
lv_obj_set_style_text_color(air_quality_label, lv_color_black(), 0);
|
||||
}
|
||||
|
||||
|
||||
/* 任务解锁 */
|
||||
lvgl_port_unlock();
|
||||
}
|
||||
@@ -200,7 +158,6 @@ void ui_show_time_page(void)
|
||||
if (temp_label) lv_obj_add_flag(temp_label, LV_OBJ_FLAG_HIDDEN);
|
||||
if (humid_label) lv_obj_add_flag(humid_label, LV_OBJ_FLAG_HIDDEN);
|
||||
if (lux_label) lv_obj_add_flag(lux_label, LV_OBJ_FLAG_HIDDEN);
|
||||
if (air_quality_label) lv_obj_add_flag(air_quality_label, LV_OBJ_FLAG_HIDDEN);
|
||||
time_page_visible = true;
|
||||
lvgl_port_unlock();
|
||||
}
|
||||
@@ -216,7 +173,6 @@ void ui_show_sensor_page(void)
|
||||
if (temp_label) lv_obj_clear_flag(temp_label, LV_OBJ_FLAG_HIDDEN);
|
||||
if (humid_label) lv_obj_clear_flag(humid_label, LV_OBJ_FLAG_HIDDEN);
|
||||
if (lux_label) lv_obj_clear_flag(lux_label, LV_OBJ_FLAG_HIDDEN);
|
||||
if (air_quality_label) lv_obj_clear_flag(air_quality_label, LV_OBJ_FLAG_HIDDEN);
|
||||
time_page_visible = false;
|
||||
lvgl_port_unlock();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user