cmcu为stm32h743IIt6
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.

102 lines
2.9 KiB

8 months ago
/*
* 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
*/
8 months ago
#include <rtthread.h>
#include <rtdevice.h>
#include <applications/data/Variable.h>
#include <applications/data/SC828_DATA_table.h>
8 months ago
#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>
8 months ago
#include "lvgl.h"
#include <ui_data_labels.h>
#include "SC828_DATA_table.h"
7 months ago
8 months ago
#define DBG_TAG "gui"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
void setup_user_screen(lv_ui *ui)
{
lv_obj_clear_flag(lv_tabview_get_content(ui->screen_tabview), LV_OBJ_FLAG_SCROLLABLE);//禁止左右滑动
lv_obj_clear_flag(lv_tabview_get_content(ui->screen_w_io), LV_OBJ_FLAG_SCROLLABLE);//禁止左右滑动
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连接状态显示
{
}else{
}
6 months ago
update_led_i();
update_led_o();
update_io_labels();
}
static void time_update_timer_cb(lv_timer_t * timer)
{
setup_s_screen(&guider_ui);
}
8 months ago
void lv_user_gui_init(void)
{
7 months ago
setup_ui(&guider_ui);
events_init(&guider_ui);
custom_init(&guider_ui);
setup_user_screen(&guider_ui);
ui_init_io(&guider_ui);
// 创建一个每 500ms 触发一次的定时器
6 months ago
lv_timer_create(time_update_timer_cb, 900, NULL);
8 months ago
}