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.
114 lines
3.4 KiB
114 lines
3.4 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 <applications/data/SC828_DATA_table.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"
|
|
#include <ui_data_labels.h>
|
|
#include "SC828_DATA_table.h"
|
|
|
|
#define DBG_TAG "gui"
|
|
#define DBG_LVL DBG_LOG
|
|
#include <rtdbg.h>
|
|
|
|
|
|
void setup_user_screen(lv_ui *ui)
|
|
{
|
|
lv_obj_set_scroll_dir(lv_tabview_get_content(ui->screen_tabview_tab_1), LV_DIR_VER);
|
|
lv_obj_add_flag(lv_tabview_get_content(ui->screen_tabview_tab_1), LV_OBJ_FLAG_SCROLL_ELASTIC);//只允许垂直滚动禁止回弹动画
|
|
|
|
|
|
lv_textarea_set_text(ui->screen_machine_id_rt, machine_ID);//设备id
|
|
lv_textarea_set_text(ui->screen_machine_name_rt, 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/10.0f);
|
|
lv_label_set_text(ui->screen_water, (const char *)wter_str);
|
|
//温度
|
|
snprintf(temp_str, sizeof(temp_str), "%05.1f", MTT/10.0f);
|
|
lv_label_set_text(ui->screen_temp, (const char *)temp_str);
|
|
|
|
if(SCLINK_OK)//中央连接状态显示
|
|
{
|
|
lv_obj_clear_flag(ui->screen_inf_link, LV_OBJ_FLAG_HIDDEN);
|
|
SCLINK_OK =0;
|
|
}else{
|
|
lv_obj_add_flag(ui->screen_inf_link, LV_OBJ_FLAG_HIDDEN);
|
|
}
|
|
if(PLCLINK_OK)//plc连接状态显示
|
|
{
|
|
lv_obj_clear_flag(ui->screen_inf_plc, LV_OBJ_FLAG_HIDDEN);
|
|
}else{
|
|
lv_obj_add_flag(ui->screen_inf_plc, LV_OBJ_FLAG_HIDDEN);
|
|
}
|
|
if(USB_OK)//USB接入
|
|
{
|
|
lv_obj_clear_flag(ui->screen_inf_usb, LV_OBJ_FLAG_HIDDEN);
|
|
}else{
|
|
lv_obj_add_flag(ui->screen_inf_usb, LV_OBJ_FLAG_HIDDEN);
|
|
}
|
|
if(LOCK_OK)//锁状态
|
|
{
|
|
lv_obj_clear_flag(ui->screen_inf_lock, LV_OBJ_FLAG_HIDDEN);
|
|
}else{
|
|
lv_obj_add_flag(ui->screen_inf_lock, LV_OBJ_FLAG_HIDDEN);
|
|
}
|
|
|
|
update_led_i();
|
|
update_led_o();
|
|
|
|
update_io_labels();
|
|
}
|
|
|
|
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);
|
|
ui_init_io(&guider_ui);
|
|
// 创建一个每 500ms 触发一次的定时器
|
|
lv_timer_create(time_update_timer_cb, 900, NULL);
|
|
}
|
|
|