modbus数据打包解包代码
This commit is contained in:
1 parent
135ce35517
commit
64ca79d1a3
15 files changed
+1344
-1089
No files matched your search
@@ -15,6 +15,7 @@
|
||||
*********************/
|
||||
#include <stdio.h>
|
||||
#include "lvgl.h"
|
||||
#include "custom.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "lvgl.h"
|
||||
#include "gui_guider.h"
|
||||
|
||||
#if LV_USE_GUIDER_SIMULATOR && LV_USE_FREEMASTER
|
||||
#include "freemaster_client.h"
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
#include "lvgl.h"
|
||||
#include <stdio.h>
|
||||
#include "gui_guider.h"
|
||||
#include "widgets_init.h"
|
||||
|
||||
#if LV_USE_GUIDER_SIMULATOR && LV_USE_FREEMASTER
|
||||
#include "gg_external_data.h"
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
#include "lvgl.h"
|
||||
#include <stdio.h>
|
||||
#include "widgets_init.h"
|
||||
#include "gui_guider.h"
|
||||
|
||||
void setup_scr_screen(lv_ui *ui)
|
||||
{
|
||||
@@ -138,7 +140,7 @@ void setup_scr_screen(lv_ui *ui)
|
||||
lv_label_set_text(ui->screen_temp, "120.5");
|
||||
lv_label_set_long_mode(ui->screen_temp, LV_LABEL_LONG_CLIP);
|
||||
lv_obj_set_pos(ui->screen_temp, 50, 10);
|
||||
lv_obj_set_size(ui->screen_temp, 70, 25);
|
||||
lv_obj_set_size(ui->screen_temp, 75, 25);
|
||||
|
||||
//Write style for screen_temp, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
|
||||
lv_obj_set_style_border_width(ui->screen_temp, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
@@ -190,7 +192,7 @@ void setup_scr_screen(lv_ui *ui)
|
||||
lv_obj_set_style_border_width(ui->screen_order, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_radius(ui->screen_order, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_color(ui->screen_order, lv_color_hex(0x000000), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_font(ui->screen_order, &lv_font_simsun_32, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_font(ui->screen_order, &lv_font_simsun_30, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_opa(ui->screen_order, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_letter_space(ui->screen_order, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_line_space(ui->screen_order, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
@@ -5805,7 +5807,7 @@ void setup_scr_screen(lv_ui *ui)
|
||||
lv_textarea_set_accepted_chars(ui->screen_pname_set, "");
|
||||
lv_textarea_set_max_length(ui->screen_pname_set, 32);
|
||||
#if LV_USE_KEYBOARD != 0 || LV_USE_ZH_KEYBOARD != 0
|
||||
// lv_obj_add_event_cb(ui->screen_pname_set, ta_event_cb, LV_EVENT_ALL, ui->g_kb_top_layer);
|
||||
lv_obj_add_event_cb(ui->screen_pname_set, ta_event_cb, LV_EVENT_ALL, ui->g_kb_top_layer);
|
||||
#endif
|
||||
lv_obj_set_pos(ui->screen_pname_set, 305, -1);
|
||||
lv_obj_set_size(ui->screen_pname_set, 679, 50);
|
||||
@@ -5965,7 +5967,7 @@ void setup_scr_screen(lv_ui *ui)
|
||||
lv_textarea_set_accepted_chars(ui->screen_machine_name, "");
|
||||
lv_textarea_set_max_length(ui->screen_machine_name, 32);
|
||||
#if LV_USE_KEYBOARD != 0 || LV_USE_ZH_KEYBOARD != 0
|
||||
//lv_obj_add_event_cb(ui->screen_machine_name, ta_event_cb, LV_EVENT_ALL, ui->g_kb_top_layer);
|
||||
lv_obj_add_event_cb(ui->screen_machine_name, ta_event_cb, LV_EVENT_ALL, ui->g_kb_top_layer);
|
||||
#endif
|
||||
lv_obj_set_pos(ui->screen_machine_name, 150, 70);
|
||||
lv_obj_set_size(ui->screen_machine_name, 200, 50);
|
||||
@@ -6051,7 +6053,7 @@ void setup_scr_screen(lv_ui *ui)
|
||||
lv_textarea_set_accepted_chars(ui->screen_machine_id, "");
|
||||
lv_textarea_set_max_length(ui->screen_machine_id, 32);
|
||||
#if LV_USE_KEYBOARD != 0 || LV_USE_ZH_KEYBOARD != 0
|
||||
//lv_obj_add_event_cb(ui->screen_machine_id, ta_event_cb, LV_EVENT_ALL, ui->g_kb_top_layer);
|
||||
lv_obj_add_event_cb(ui->screen_machine_id, ta_event_cb, LV_EVENT_ALL, ui->g_kb_top_layer);
|
||||
#endif
|
||||
lv_obj_set_pos(ui->screen_machine_id, 150, 10);
|
||||
lv_obj_set_size(ui->screen_machine_id, 200, 50);
|
||||
|
||||
@@ -9,12 +9,16 @@
|
||||
*/
|
||||
#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"
|
||||
//#include "lv_demo_widgets.h"
|
||||
|
||||
|
||||
#define DBG_TAG "gui"
|
||||
@@ -24,11 +28,54 @@
|
||||
#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)
|
||||
{
|
||||
//gui_guider_setup();
|
||||
//lv_demo_widgets();
|
||||
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);
|
||||
}
|
||||
Reference in new issue
Block a user