You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.3 KiB
80 lines
2.3 KiB
/*
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Change Logs:
|
|
* Date Author Notes
|
|
* 2025-11-25 Administrator the first version
|
|
*/
|
|
#include <rtthread.h>
|
|
#include <rtdevice.h>
|
|
#include <applications/data/Variable.h>
|
|
#include <board.h>
|
|
#include <stdio.h>
|
|
#include <time.h>
|
|
#include <string.h>
|
|
#include <guider/custom/custom.h>
|
|
#include <guider/generated/events_init.h>
|
|
#include <guider/generated/gui_guider.h>
|
|
#include <guider/generated/widgets_init.h>
|
|
#include "lvgl.h"
|
|
|
|
#define DBG_TAG "gui"
|
|
#define DBG_LVL DBG_LOG
|
|
#include <rtdbg.h>
|
|
|
|
#define LCD_BL_PIN GET_PIN(D,12)
|
|
#define LCD_RST_PIN GET_PIN(D,11)
|
|
|
|
|
|
void setup_user_screen(lv_ui *ui)
|
|
{
|
|
lv_obj_clear_flag(lv_tabview_get_content(ui->screen_tabview), LV_OBJ_FLAG_SCROLLABLE);//禁止左右滑动
|
|
lv_textarea_set_text(ui->screen_machine_id, machine_ID);//设备id
|
|
lv_textarea_set_text(ui->screen_machine_name, machine_name);//设备名
|
|
|
|
}
|
|
|
|
time_t nows;
|
|
char time_str[9]; //"0000:00\0"
|
|
char temp_str[6]; //"120.5"
|
|
char wter_str[6]; //"120.5"
|
|
void setup_s_screen(lv_ui *ui)
|
|
{
|
|
//系统时间
|
|
time(&nows);
|
|
struct tm *t = localtime(&nows);
|
|
snprintf(sys_time, sizeof(sys_time), "%02d:%02d:%02d", t->tm_hour, t->tm_min, t->tm_sec);
|
|
lv_label_set_text(ui->screen_SYS_TIME, (const char *)sys_time);//系统时间
|
|
//运行时间
|
|
#pragma GCC diagnostic push
|
|
#pragma GCC diagnostic ignored "-Wformat-truncation"
|
|
snprintf(time_str, sizeof(time_str), "%04d:%02d", sys_run_time / 60, sys_run_time % 60);
|
|
#pragma GCC diagnostic pop
|
|
lv_label_set_text(ui->screen_RUN_TIME, (const char *)time_str);//显示运行时间
|
|
//工单
|
|
lv_label_set_text(ui->screen_order, (const char *)Work);
|
|
//水位
|
|
snprintf(wter_str, sizeof(wter_str), "%04.0f", MTL);
|
|
lv_label_set_text(ui->screen_water, (const char *)wter_str);
|
|
//温度
|
|
snprintf(temp_str, sizeof(temp_str), "%05.1f", MTT);
|
|
lv_label_set_text(ui->screen_temp, (const char *)temp_str);
|
|
}
|
|
|
|
static void time_update_timer_cb(lv_timer_t * timer)
|
|
{
|
|
setup_s_screen(&guider_ui);
|
|
}
|
|
|
|
void lv_user_gui_init(void)
|
|
{
|
|
setup_ui(&guider_ui);
|
|
events_init(&guider_ui);
|
|
custom_init(&guider_ui);
|
|
setup_user_screen(&guider_ui);
|
|
|
|
// 创建一个每 500ms 触发一次的定时器
|
|
lv_timer_create(time_update_timer_cb, 500, NULL);
|
|
}
|
|
|