Browse Source

添加表格显示

master
忱 沈 5 months ago
parent
commit
e8d8bedc05
  1. 8
      .config
  2. 3090
      .cproject
  3. 8
      applications/data/SC828_DATA_table.c
  4. 22
      applications/lvgl/guider/generated/events_init.c
  5. 2
      applications/lvgl/guider/generated/gui_guider.h
  6. 90
      applications/lvgl/guider/generated/setup_scr_screen.c
  7. 25
      applications/lvgl/lv__user_gui.c
  8. 176
      applications/lvgl/ui_data_csv.c
  9. 15
      applications/lvgl/ui_data_csv.h
  10. 49
      applications/lvgl/ui_data_labels.c
  11. 15
      applications/lvgl/ui_data_labels.h
  12. 2
      applications/main.c
  13. 1
      rtconfig.h
  14. 20
      scons_target.bat

8
.config

@ -744,6 +744,13 @@ CONFIG_PKG_USING_LITTLEFS_V2112=y
CONFIG_LFS_READ_SIZE=256
CONFIG_LFS_PROG_SIZE=256
CONFIG_LFS_BLOCK_SIZE=4096
# CONFIG_LFS_YES_TRACE is not set
CONFIG_LFS_NO_DEBUG=y
# CONFIG_LFS_NO_WARN is not set
# CONFIG_LFS_NO_ERROR is not set
# CONFIG_LFS_NO_ASSERT is not set
# CONFIG_LFS_NO_INTRINSICS is not set
# CONFIG_LFS_NO_MALLOC is not set
CONFIG_LFS_CACHE_SIZE=256
CONFIG_LFS_BLOCK_CYCLES=500
# CONFIG_DFS_LFS_READONLY is not set
@ -1061,6 +1068,7 @@ CONFIG_PKG_FT5426_VER="latest"
# CONFIG_PKG_USING_CST812T is not set
# end of touch drivers
# CONFIG_PKG_USING_LCD_SPI_DRIVER is not set
# CONFIG_PKG_USING_REALTEK_AMEBA is not set
# CONFIG_PKG_USING_BUTTON is not set
# CONFIG_PKG_USING_PCF8574 is not set

3090
.cproject

File diff suppressed because it is too large

8
applications/data/SC828_DATA_table.c

@ -227,10 +227,10 @@ void DATA_Table_Init(){
{
step_table[i].RUN = 0;
rt_snprintf(step_table[i].Dyelot ,1,"");
step_table[i].ReDye = 0;
rt_snprintf(step_table[i].StepID ,1,"");
rt_snprintf(step_table[i].StepName ,1,"");
rt_snprintf(step_table[i].ParameterName ,1,"");
step_table[i].ReDye = 0;
rt_snprintf(step_table[i].StepID ,1,"");
rt_snprintf(step_table[i].StepName ,1,"");
rt_snprintf(step_table[i].ParameterName ,1,"");
step_table[i].Parameter1 = 0;
step_table[i].Parameter2 = 0;
step_table[i].Parameter3 = 0;

22
applications/lvgl/guider/generated/events_init.c

@ -15,12 +15,6 @@
#include "freemaster_client.h"
#endif
#include <lvgl/ui_data_labels.h>
#include "DB_SQLite.h"
int Work_Program_DATA=0;
char select_data_ui[4096]= {0};
#include "INI/config.h"
#include "data/Variable.h"
@ -108,21 +102,7 @@ static void screen_w_w_event_handler (lv_event_t *e)
switch (code) {
case LV_EVENT_CLICKED:
{
if(Work_Program_DATA)
{
char sqlSELECT[512] = {0}; // 初始化为 0
char time_str[32];
if (get_time_str(time_str, sizeof(time_str)) != RT_NULL)
{
// 安全格式化
rt_snprintf(sqlSELECT, sizeof(sqlSELECT),"%S,%S",select_WorkOrder_DATA,time_str);
db_send_select(DB_CMD_SELECT, "SELECT * FROM WorkOrder WHERE State=101 LIMIT 16;", 500,select_data_ui);
}
}
else
{
db_send_select(DB_CMD_SELECT, select_Program_DATA, 500,select_data_ui);
}
Work_Program_ui();
break;
}
default:

2
applications/lvgl/guider/generated/gui_guider.h

@ -34,6 +34,8 @@ typedef struct
lv_obj_t *screen_order;
lv_obj_t *screen_SYS_TIME;
lv_obj_t *screen_RUN_TIME;
lv_obj_t *screen_inf_err;
lv_obj_t *screen_inf_err_label;
lv_obj_t *screen_tabview;
lv_obj_t *screen_tabview_tab_1;
lv_obj_t *screen_tabview_tab_2;

90
applications/lvgl/guider/generated/setup_scr_screen.c

@ -80,7 +80,7 @@ void setup_scr_screen(lv_ui *ui)
lv_img_set_src(ui->screen_inf_img, &_ico_order_alpha_40x40);
lv_img_set_pivot(ui->screen_inf_img, 40,40);
lv_img_set_angle(ui->screen_inf_img, 0);
lv_obj_set_pos(ui->screen_inf_img, 350, 5);
lv_obj_set_pos(ui->screen_inf_img, 280, 5);
lv_obj_set_size(ui->screen_inf_img, 40, 40);
//Write style for screen_inf_img, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
@ -192,7 +192,7 @@ void setup_scr_screen(lv_ui *ui)
lv_label_set_text(ui->screen_water, "9999");
lv_label_set_long_mode(ui->screen_water, LV_LABEL_LONG_CLIP);
lv_obj_set_pos(ui->screen_water, 180, 10);
lv_obj_set_size(ui->screen_water, 90, 25);
lv_obj_set_size(ui->screen_water, 80, 25);
//Write style for screen_water, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_border_width(ui->screen_water, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
@ -214,8 +214,8 @@ void setup_scr_screen(lv_ui *ui)
ui->screen_order = lv_label_create(ui->screen_TITLE);
lv_label_set_text(ui->screen_order, "SC---------");
lv_label_set_long_mode(ui->screen_order, LV_LABEL_LONG_SCROLL_CIRCULAR);
lv_obj_set_pos(ui->screen_order, 400, 10);
lv_obj_set_size(ui->screen_order, 200, 30);
lv_obj_set_pos(ui->screen_order, 330, 10);
lv_obj_set_size(ui->screen_order, 300, 30);
//Write style for screen_order, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_border_width(ui->screen_order, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
@ -279,6 +279,27 @@ void setup_scr_screen(lv_ui *ui)
lv_obj_set_style_pad_left(ui->screen_RUN_TIME, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->screen_RUN_TIME, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes screen_inf_err
ui->screen_inf_err = lv_btn_create(ui->screen_TITLE);
ui->screen_inf_err_label = lv_label_create(ui->screen_inf_err);
lv_label_set_text(ui->screen_inf_err_label, "" LV_SYMBOL_WARNING " ");
lv_label_set_long_mode(ui->screen_inf_err_label, LV_LABEL_LONG_WRAP);
lv_obj_align(ui->screen_inf_err_label, LV_ALIGN_RIGHT_MID, 0, 0);
lv_obj_set_style_pad_all(ui->screen_inf_err, 0, LV_STATE_DEFAULT);
lv_obj_set_width(ui->screen_inf_err_label, LV_PCT(100));
lv_obj_set_pos(ui->screen_inf_err, 970, 0);
lv_obj_set_size(ui->screen_inf_err, 50, 50);
//Write style for screen_inf_err, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->screen_inf_err, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_width(ui->screen_inf_err, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->screen_inf_err, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(ui->screen_inf_err, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_color(ui->screen_inf_err, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui->screen_inf_err, &lv_font_simsun_24, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui->screen_inf_err, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_align(ui->screen_inf_err, LV_TEXT_ALIGN_RIGHT, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write codes screen_tabview
ui->screen_tabview = lv_tabview_create(ui->screen, LV_DIR_BOTTOM, 50);
lv_obj_set_pos(ui->screen_tabview, 0, 50);
@ -411,7 +432,7 @@ void setup_scr_screen(lv_ui *ui)
//Write codes screen_w_text
ui->screen_w_text = lv_label_create(ui->screen_tabview_tab_1);
lv_label_set_text(ui->screen_w_text, "Label");
lv_label_set_text(ui->screen_w_text, "信息");
lv_label_set_long_mode(ui->screen_w_text, LV_LABEL_LONG_WRAP);
lv_obj_set_pos(ui->screen_w_text, 305, 265);
lv_obj_set_size(ui->screen_w_text, 550, 230);
@ -454,16 +475,9 @@ void setup_scr_screen(lv_ui *ui)
//Write codes screen_w_list
ui->screen_w_list = lv_table_create(ui->screen_step_list);
lv_table_set_col_cnt(ui->screen_w_list,2);
lv_table_set_row_cnt(ui->screen_w_list,4);
lv_table_set_col_cnt(ui->screen_w_list,1);
lv_table_set_row_cnt(ui->screen_w_list,1);
lv_table_set_cell_value(ui->screen_w_list,0,0,"Name");
lv_table_set_cell_value(ui->screen_w_list,1,0,"Apple");
lv_table_set_cell_value(ui->screen_w_list,2,0,"Banana");
lv_table_set_cell_value(ui->screen_w_list,3,0,"Citron");
lv_table_set_cell_value(ui->screen_w_list,0,1,"Price");
lv_table_set_cell_value(ui->screen_w_list,1,1,"$1");
lv_table_set_cell_value(ui->screen_w_list,2,1,"$2");
lv_table_set_cell_value(ui->screen_w_list,3,1,"$3");
lv_obj_set_pos(ui->screen_w_list, 0, 0);
lv_obj_set_scrollbar_mode(ui->screen_w_list, LV_SCROLLBAR_MODE_OFF);
@ -514,16 +528,9 @@ void setup_scr_screen(lv_ui *ui)
//Write codes screen_list_inf
ui->screen_list_inf = lv_table_create(ui->screen_inf_list);
lv_table_set_col_cnt(ui->screen_list_inf,2);
lv_table_set_row_cnt(ui->screen_list_inf,4);
lv_table_set_col_cnt(ui->screen_list_inf,1);
lv_table_set_row_cnt(ui->screen_list_inf,1);
lv_table_set_cell_value(ui->screen_list_inf,0,0,"Name");
lv_table_set_cell_value(ui->screen_list_inf,1,0,"Apple");
lv_table_set_cell_value(ui->screen_list_inf,2,0,"Banana");
lv_table_set_cell_value(ui->screen_list_inf,3,0,"Citron");
lv_table_set_cell_value(ui->screen_list_inf,0,1,"Price");
lv_table_set_cell_value(ui->screen_list_inf,1,1,"$1");
lv_table_set_cell_value(ui->screen_list_inf,2,1,"$2");
lv_table_set_cell_value(ui->screen_list_inf,3,1,"$3");
lv_obj_set_pos(ui->screen_list_inf, 0, 0);
lv_obj_set_scrollbar_mode(ui->screen_list_inf, LV_SCROLLBAR_MODE_OFF);
@ -851,7 +858,7 @@ void setup_scr_screen(lv_ui *ui)
lv_label_set_text(screen_tabview_tab_3_label, "");
//Write codes screen_w_io
ui->screen_w_io = lv_tabview_create(ui->screen_tabview_tab_3, LV_DIR_RIGHT, 50);
ui->screen_w_io = lv_tabview_create(ui->screen_tabview_tab_3, LV_DIR_RIGHT, 90);
lv_obj_set_pos(ui->screen_w_io, 0, 0);
lv_obj_set_size(ui->screen_w_io, 1024, 500);
lv_obj_set_scrollbar_mode(ui->screen_w_io, LV_SCROLLBAR_MODE_OFF);
@ -859,7 +866,7 @@ void setup_scr_screen(lv_ui *ui)
//Write style for screen_w_io, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_bg_opa(ui->screen_w_io, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_color(ui->screen_w_io, lv_color_hex(0x4d4d4d), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui->screen_w_io, &lv_font_simsun_12, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui->screen_w_io, &lv_font_simsun_16, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui->screen_w_io, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_letter_space(ui->screen_w_io, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_text_line_space(ui->screen_w_io, 16, LV_PART_MAIN|LV_STATE_DEFAULT);
@ -913,7 +920,7 @@ void setup_scr_screen(lv_ui *ui)
//Write codes screen_DI_t1
ui->screen_DI_t1 = lv_obj_create(ui->screen_w_io_tab_1);
lv_obj_set_pos(ui->screen_DI_t1, 0, 0);
lv_obj_set_size(ui->screen_DI_t1, 850, 500);
lv_obj_set_size(ui->screen_DI_t1, 830, 500);
lv_obj_set_scrollbar_mode(ui->screen_DI_t1, LV_SCROLLBAR_MODE_OFF);
//Write style for screen_DI_t1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
@ -2372,7 +2379,7 @@ void setup_scr_screen(lv_ui *ui)
//Write codes screen_DI_t2
ui->screen_DI_t2 = lv_obj_create(ui->screen_w_io_tab_1);
lv_obj_set_pos(ui->screen_DI_t2, 0, 0);
lv_obj_set_size(ui->screen_DI_t2, 850, 500);
lv_obj_set_size(ui->screen_DI_t2, 830, 500);
lv_obj_set_scrollbar_mode(ui->screen_DI_t2, LV_SCROLLBAR_MODE_OFF);
lv_obj_add_flag(ui->screen_DI_t2, LV_OBJ_FLAG_HIDDEN);
@ -2877,7 +2884,7 @@ void setup_scr_screen(lv_ui *ui)
lv_obj_align(ui->screen_btn_DIU_label, LV_ALIGN_RIGHT_MID, 0, 0);
lv_obj_set_style_pad_all(ui->screen_btn_DIU, 0, LV_STATE_DEFAULT);
lv_obj_set_width(ui->screen_btn_DIU_label, LV_PCT(100));
lv_obj_set_pos(ui->screen_btn_DIU, 860, 10);
lv_obj_set_pos(ui->screen_btn_DIU, 850, 10);
lv_obj_set_size(ui->screen_btn_DIU, 50, 100);
lv_obj_add_flag(ui->screen_btn_DIU, LV_OBJ_FLAG_HIDDEN);
@ -2901,7 +2908,7 @@ void setup_scr_screen(lv_ui *ui)
lv_obj_align(ui->screen_btn_DID_label, LV_ALIGN_RIGHT_MID, 0, 0);
lv_obj_set_style_pad_all(ui->screen_btn_DID, 0, LV_STATE_DEFAULT);
lv_obj_set_width(ui->screen_btn_DID_label, LV_PCT(100));
lv_obj_set_pos(ui->screen_btn_DID, 860, 360);
lv_obj_set_pos(ui->screen_btn_DID, 850, 360);
lv_obj_set_size(ui->screen_btn_DID, 50, 100);
//Write style for screen_btn_DID, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
@ -2924,7 +2931,7 @@ void setup_scr_screen(lv_ui *ui)
//Write codes screen_DO_t2
ui->screen_DO_t2 = lv_obj_create(ui->screen_w_io_tab_2);
lv_obj_set_pos(ui->screen_DO_t2, 0, 0);
lv_obj_set_size(ui->screen_DO_t2, 850, 500);
lv_obj_set_size(ui->screen_DO_t2, 830, 500);
lv_obj_set_scrollbar_mode(ui->screen_DO_t2, LV_SCROLLBAR_MODE_OFF);
lv_obj_add_flag(ui->screen_DO_t2, LV_OBJ_FLAG_HIDDEN);
@ -3424,7 +3431,7 @@ void setup_scr_screen(lv_ui *ui)
//Write codes screen_DO_t1
ui->screen_DO_t1 = lv_obj_create(ui->screen_w_io_tab_2);
lv_obj_set_pos(ui->screen_DO_t1, 0, 0);
lv_obj_set_size(ui->screen_DO_t1, 850, 500);
lv_obj_set_size(ui->screen_DO_t1, 830, 500);
lv_obj_set_scrollbar_mode(ui->screen_DO_t1, LV_SCROLLBAR_MODE_OFF);
//Write style for screen_DO_t1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
@ -4888,7 +4895,7 @@ void setup_scr_screen(lv_ui *ui)
lv_obj_align(ui->screen_btn_DOU_label, LV_ALIGN_RIGHT_MID, 0, 0);
lv_obj_set_style_pad_all(ui->screen_btn_DOU, 0, LV_STATE_DEFAULT);
lv_obj_set_width(ui->screen_btn_DOU_label, LV_PCT(100));
lv_obj_set_pos(ui->screen_btn_DOU, 860, 10);
lv_obj_set_pos(ui->screen_btn_DOU, 850, 10);
lv_obj_set_size(ui->screen_btn_DOU, 50, 100);
lv_obj_add_flag(ui->screen_btn_DOU, LV_OBJ_FLAG_HIDDEN);
@ -4912,7 +4919,7 @@ void setup_scr_screen(lv_ui *ui)
lv_obj_align(ui->screen_btn_DOD_label, LV_ALIGN_RIGHT_MID, 0, 0);
lv_obj_set_style_pad_all(ui->screen_btn_DOD, 0, LV_STATE_DEFAULT);
lv_obj_set_width(ui->screen_btn_DOD_label, LV_PCT(100));
lv_obj_set_pos(ui->screen_btn_DOD, 860, 360);
lv_obj_set_pos(ui->screen_btn_DOD, 850, 360);
lv_obj_set_size(ui->screen_btn_DOD, 50, 100);
//Write style for screen_btn_DOD, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
@ -4935,7 +4942,7 @@ void setup_scr_screen(lv_ui *ui)
//Write codes screen_AIO_t2
ui->screen_AIO_t2 = lv_obj_create(ui->screen_w_io_tab_3);
lv_obj_set_pos(ui->screen_AIO_t2, 0, 0);
lv_obj_set_size(ui->screen_AIO_t2, 850, 500);
lv_obj_set_size(ui->screen_AIO_t2, 830, 500);
lv_obj_set_scrollbar_mode(ui->screen_AIO_t2, LV_SCROLLBAR_MODE_OFF);
lv_obj_add_flag(ui->screen_AIO_t2, LV_OBJ_FLAG_HIDDEN);
@ -5231,7 +5238,7 @@ void setup_scr_screen(lv_ui *ui)
ui->screen_label_30 = lv_label_create(ui->screen_AIO_t2);
lv_label_set_text(ui->screen_label_30, "加料比例1");
lv_label_set_long_mode(ui->screen_label_30, LV_LABEL_LONG_SCROLL_CIRCULAR);
lv_obj_set_pos(ui->screen_label_30, 50, 90);
lv_obj_set_pos(ui->screen_label_30, 50, 91);
lv_obj_set_size(ui->screen_label_30, 155, 30);
//Write style for screen_label_30, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
@ -5755,11 +5762,14 @@ void setup_scr_screen(lv_ui *ui)
//Write codes screen_AIO_t1
ui->screen_AIO_t1 = lv_obj_create(ui->screen_w_io_tab_3);
lv_obj_set_pos(ui->screen_AIO_t1, 0, 0);
lv_obj_set_size(ui->screen_AIO_t1, 850, 500);
lv_obj_set_size(ui->screen_AIO_t1, 830, 500);
lv_obj_set_scrollbar_mode(ui->screen_AIO_t1, LV_SCROLLBAR_MODE_OFF);
//Write style for screen_AIO_t1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
lv_obj_set_style_border_width(ui->screen_AIO_t1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_width(ui->screen_AIO_t1, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(ui->screen_AIO_t1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_color(ui->screen_AIO_t1, lv_color_hex(0x2195f6), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_side(ui->screen_AIO_t1, LV_BORDER_SIDE_FULL, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(ui->screen_AIO_t1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui->screen_AIO_t1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(ui->screen_AIO_t1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
@ -6322,7 +6332,7 @@ void setup_scr_screen(lv_ui *ui)
ui->screen_label_3 = lv_label_create(ui->screen_AIO_t1);
lv_label_set_text(ui->screen_label_3, "温度2");
lv_label_set_long_mode(ui->screen_label_3, LV_LABEL_LONG_SCROLL_CIRCULAR);
lv_obj_set_pos(ui->screen_label_3, 449, 10);
lv_obj_set_pos(ui->screen_label_3, 450, 10);
lv_obj_set_size(ui->screen_label_3, 155, 30);
//Write style for screen_label_3, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
@ -6976,7 +6986,7 @@ void setup_scr_screen(lv_ui *ui)
lv_obj_align(ui->screen_btn_AIOU_label, LV_ALIGN_RIGHT_MID, 0, 0);
lv_obj_set_style_pad_all(ui->screen_btn_AIOU, 0, LV_STATE_DEFAULT);
lv_obj_set_width(ui->screen_btn_AIOU_label, LV_PCT(100));
lv_obj_set_pos(ui->screen_btn_AIOU, 860, 10);
lv_obj_set_pos(ui->screen_btn_AIOU, 850, 10);
lv_obj_set_size(ui->screen_btn_AIOU, 50, 100);
lv_obj_add_flag(ui->screen_btn_AIOU, LV_OBJ_FLAG_HIDDEN);
@ -7000,7 +7010,7 @@ void setup_scr_screen(lv_ui *ui)
lv_obj_align(ui->screen_btn_AIOD_label, LV_ALIGN_RIGHT_MID, 0, 0);
lv_obj_set_style_pad_all(ui->screen_btn_AIOD, 0, LV_STATE_DEFAULT);
lv_obj_set_width(ui->screen_btn_AIOD_label, LV_PCT(100));
lv_obj_set_pos(ui->screen_btn_AIOD, 860, 360);
lv_obj_set_pos(ui->screen_btn_AIOD, 850, 360);
lv_obj_set_size(ui->screen_btn_AIOD, 50, 100);
//Write style for screen_btn_AIOD, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.

25
applications/lvgl/lv__user_gui.c

@ -30,27 +30,15 @@
void setup_user_screen(lv_ui *ui)
{
//lv_obj_set_scroll_snap_y(lv_tabview_get_content(ui->screen_w_io), LV_SCROLL_SNAP_NONE);
//lv_obj_remove_flag(lv_tabview_get_content(ui->screen_w_io), LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_WITH_ARROW);
//lv_obj_add_flag(lv_tabview_get_content(ui->screen_w_io), LV_OBJ_FLAG_SCROLLABLE);
//lv_obj_set_scroll_snap_x(lv_tabview_get_content(ui->screen_w_io), LV_SCROLL_SNAP_NONE);
//lv_obj_set_scroll_snap_y(lv_tabview_get_content(ui->screen_w_io), LV_SCROLL_SNAP_NONE);
lv_obj_clear_flag(lv_tabview_get_content(ui->screen_w_io), LV_EVENT_SCROLL_END );//禁止左右滑动
//lv_obj_set_scroll_dir(ui->screen_tabview_tab_1, LV_DIR_VER);
//lv_obj_add_flag(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)
{
//系统时间
@ -64,8 +52,6 @@ void setup_s_screen(lv_ui *ui)
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);
@ -82,16 +68,19 @@ void setup_s_screen(lv_ui *ui)
}
if(PLCLINK_OK)//plc连接状态显示
{
//工单
lv_label_set_text(ui->screen_order, (const char *)Work);//显示当前信息
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);
lv_label_set_text(ui->screen_order, "PLC Not Connected");//显示plc断开
}
if(USB_OK)//USB接入
{
{
lv_obj_clear_flag(ui->screen_inf_usb, LV_OBJ_FLAG_HIDDEN);
}else{
}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);

176
applications/lvgl/ui_data_csv.c

@ -0,0 +1,176 @@
#include <rtthread.h>
#include "libcsv.h"
#include "lvgl.h"
#define CSV_MAX_ROWS 260 // 最大行数
#define CSV_MAX_COLS 48 // 每行最大列数
#define CSV_MAX_FIELD 64 // 每个字段最大长度
// ============ 数据结构定义 ============
typedef struct {
int row; // 当前行号
int col; // 当前列号
int total_rows; // 总行数
int max_cols; // 最大列数
char data[CSV_MAX_ROWS][CSV_MAX_COLS][CSV_MAX_FIELD]; // 固定二维数组
} UserData;
// ============ 字段回调函数 ============
void field_callback(void *data, size_t size, void *user_data) {
UserData *user = (UserData *)user_data;
// 检查边界
if (user->row >= CSV_MAX_ROWS) {
//rt_kprintf("[W] 超出最大行数 %d\n", CSV_MAX_ROWS);
return;
}
if (user->col >= CSV_MAX_COLS) {
//rt_kprintf("[W] 超出最大列数 %d\n", CSV_MAX_COLS);
return;
}
// 限制字段长度
size_t copy_size = size;
if (copy_size >= CSV_MAX_FIELD) {
copy_size = CSV_MAX_FIELD - 1;
//rt_kprintf("[W] 字段截断\n");
}
// 复制数据到固定数组
rt_memcpy(user->data[user->row][user->col], data, copy_size);
user->data[user->row][user->col][copy_size] = '\0';
// 调试输出
//rt_kprintf("R:%d C:%d V:\"%s\"\n", user->row, user->col, user->data[user->row][user->col]);
// 列号+1
user->col++;
// 更新最大列数
if (user->col > user->max_cols) {
user->max_cols = user->col;
}
// 更新总行数
if (user->row + 1 > user->total_rows) {
user->total_rows = user->row + 1;
}
}
// ============ 行回调函数 ============
void row_callback(int c, void *user_data) {
UserData *user = (UserData *)user_data;
// 行结束,重置列号,行号+1
user->row++;
user->col = 0;
}
// ============ 获取指定单元格数据 ============
const char* csv_get_cell(UserData *user, int row, int col) {
if (user == NULL) {
return NULL;
}
if (row < 0 || row >= user->total_rows) {
return NULL;
}
if (col < 0 || col >= user->max_cols) {
return NULL;
}
return user->data[row][col];
}
// ============ 获取行数 ============
int csv_get_row_count(UserData *user) {
return user ? user->total_rows : 0;
}
// ============ 获取列数 ============
int csv_get_col_count(UserData *user) {
return user ? user->max_cols : 0;
}
// ============ 清空数据 ============
void csv_clear_data(UserData *user) {
if (user == NULL) {
return;
}
user->row = 0;
user->col = 0;
user->total_rows = 0;
user->max_cols = 0;
}
// ============ 解析后创建 LVGL 表格 ============
int parse_csv_string(lv_obj_t *container, const char *csv_data, UserData *user)
{
if (csv_data == NULL) {
rt_kprintf("[E] NOT DATA\n");
return -1;
}
if (user == NULL) {
rt_kprintf("[E] NOT USER DATA\n");
return -1;
}
// 初始化 UserData
csv_clear_data(user);
if (container != NULL) {
lv_obj_set_size(container, LV_PCT(100), LV_SIZE_CONTENT);
lv_obj_set_style_pad_all(container, 0, LV_PART_MAIN);
}
struct csv_parser parser;
csv_init(&parser, 0);
size_t data_len = rt_strlen(csv_data);
if (csv_parse(&parser, csv_data, data_len, field_callback, row_callback, user) != data_len) {
rt_kprintf("[E] ERR: %s\n", csv_strerror(csv_error(&parser)));
csv_fini(&parser, field_callback, row_callback, user);
csv_free(&parser);
return -1;
}
csv_fini(&parser, field_callback, row_callback, user);
csv_free(&parser);
//rt_kprintf("ROW: %d\n COL:%d", user->total_rows,user->max_cols);
return 0;
}
// ============ 全局指针 ============
static UserData *user = NULL;
extern struct rt_memheap sdram_heap;
int parse_csv_to_table(lv_obj_t *container, const char *csv_data) {
if (container == NULL || csv_data == NULL) {
return -1;
}
user = (UserData *)rt_memheap_alloc(&sdram_heap, sizeof(UserData));
// 解析 CSV
if (parse_csv_string(container, csv_data, user) != 0) {
return -1;
}
// 表格
lv_obj_set_size(container, LV_PCT(100), LV_SIZE_CONTENT);
lv_obj_set_style_pad_all(container, 0, LV_PART_MAIN);
lv_table_set_col_cnt(container,user->max_cols);
lv_table_set_row_cnt(container,user->total_rows);
// 填充表格数据
for (int i = 0; i < user->total_rows; i++) {
for (int j = 0; j < user->max_cols; j++) {
const char *val = csv_get_cell(user, i, j);
lv_table_set_cell_value(container, i, j, val ? val : "");
}
}
// 释放内存
rt_memheap_free(user);
return 0;
}

15
applications/lvgl/ui_data_csv.h

@ -0,0 +1,15 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2026-02-18 24018 the first version
*/
#ifndef APPLICATIONS_LVGL_UI_DATA_CSV_H_
#define APPLICATIONS_LVGL_UI_DATA_CSV_H_
int parse_csv_to_table(lv_obj_t *container, const char *csv_data);
#endif /* APPLICATIONS_LVGL_UI_DATA_CSV_H_ */

49
applications/lvgl/ui_data_labels.c

@ -21,7 +21,8 @@
#include <guider/generated/widgets_init.h>
#include "lvgl.h"
#include <ui_data_labels.h>
//#include "libcsv.h"
#include "libcsv.h"
// 全局或静态数组
char buf[8];
@ -35,6 +36,10 @@ Program_DATA_tab * ProgramDATA_tab=NULL;
STEP_DATA_tab * StepDATA_tab=NULL;
extern struct rt_memheap sram_SRAM1,sdram_heap;
/**
*
* DIO,AIO
*/
void ui_init_io(lv_ui *ui) {
WorkDATA_tab = rt_memheap_alloc(&sdram_heap, sizeof(WorkOrder_DATA_tab)*128);
@ -286,3 +291,45 @@ char* get_time_str(char *buf, size_t size)
return buf;
}
/**
*
**/
#include <guider/custom/custom.h>
#include <guider/generated/events_init.h>
#include <guider/generated/gui_guider.h>
#include <guider/generated/widgets_init.h>
#include "sql/DB_SQLite.h"
#include"ui_data_csv.h"
int Work_Program_DATA=0;
char select_data_ui[4096]= {0};
void Work_Program_ui(void)
{
Work_Program_DATA = ~Work_Program_DATA;
if(Work_Program_DATA==0)
{
char sqlSELECT[512] = {0}; // 初始化为 0
char time_str[32];
if (get_time_str(time_str, sizeof(time_str)) != RT_NULL)
{
// 安全格式化
rt_snprintf(sqlSELECT, sizeof(sqlSELECT),"%s'%s' LIMIT 16;",select_WorkOrder_DATA,time_str);
db_send_select(DB_CMD_SELECT, sqlSELECT, 500,select_data_ui);
// 表格绘图
parse_csv_to_table(guider_ui.screen_list_inf, select_data_ui);
}
}
else
{
// 查询工艺数据
db_send_select(DB_CMD_SELECT, select_Program_DATA, 500,select_data_ui);
// 表格绘图
parse_csv_to_table(guider_ui.screen_list_inf, select_data_ui);
}
}

15
applications/lvgl/ui_data_labels.h

@ -10,11 +10,11 @@
#ifndef APPLICATIONS_LVGL_UI_DATA_LABELS_H_
#define APPLICATIONS_LVGL_UI_DATA_LABELS_H_
#define select_WorkOrder_DATA "SELECT ProgramName,Time,\
StartTime,EndTime,WorkOrder,Dyelot,ReDye,lock,State,ColorName,\
ColorNumber,Client,ClothWeight,ClothSpecies,BathRatio,Total,\
Remark,USER FROM WorkOrder WHERE State=101 AND EndTime >"
#define select_Program_DATA "SELECT ProgramName,Time FROM ProgramName"
#define select_WorkOrder_DATA "SELECT WorkOrder,Dyelot,\
ReDye,StartTime,EndTime,ProgramName,Time,lock,State,\
USER FROM WorkOrder WHERE State=101 AND EndTime > "
#define select_Program_DATA "SELECT ProgramName,Step,Time FROM ProgramName"
typedef struct {
char WorkOrder[32];
@ -77,8 +77,6 @@ extern lv_obj_t *do_led_array[64];
extern lv_obj_t *di_labels[24]; // DI: AIO4001 ~ AIO4024 (24个)
extern lv_obj_t *do_labels[16]; // DO: AIO5001 ~ AIO5016 (16个)
void ui_init_io(lv_ui *ui);
void update_io_labels(void);
void update_led_i(void);
@ -86,4 +84,7 @@ void update_led_o(void);
char* get_time_str(char *buf, size_t size);
void Work_Program_ui(void);
#endif /* APPLICATIONS_LVGL_UI_DATA_LABELS_H_ */

2
applications/main.c

@ -28,7 +28,7 @@ int main(void)
thread_RUN_LED();//运行指示灯线程
rt_snprintf(sys_var, sizeof(sys_var),"0.0.01a");
wdt_sample();//启动看门狗
// wdt_sample();//启动看门狗
LTDC_BL(1);//屏幕背光开
return RT_EOK;
}

1
rtconfig.h

@ -305,6 +305,7 @@
#define LFS_READ_SIZE 256
#define LFS_PROG_SIZE 256
#define LFS_BLOCK_SIZE 4096
#define LFS_NO_DEBUG
#define LFS_CACHE_SIZE 256
#define LFS_BLOCK_CYCLES 500
#define LFS_THREADSAFE

20
scons_target.bat

@ -0,0 +1,20 @@
cd /d D:\RT-ThreadStudio\workspace\828F
set RTT_ROOT=
set ENV_ROOT=D:/RT-ThreadStudio/platform/env_released/env
set RTT_EXEC_PATH=D:/RT-ThreadStudio/repo/Extract/ToolChain_Support_Packages/ARM/GNU_Tools_for_ARM_Embedded_Processors/13.3/bin
set KCONF_EXEC_PATH=%ENV_ROOT%\tools\exec
set RTT_CC=gcc
set RTTS_PLATFORM=STUDIO
set SCONS=%ENV_ROOT%\tools\Python27\Scripts
set PKGS_ROOT=%ENV_ROOT%\packages
set PATH=%ENV_ROOT%\tools\MinGit-2.25.1-32-bit\cmd;%PATH%
set PATH=%ENV_ROOT%\tools\Python27;%PATH%
set PATH=%ENV_ROOT%\tools\Python27\Scripts;%PATH%
set PATH=%ENV_ROOT%\tools\bin;%PATH%
set PATH=%RTT_EXEC_PATH%;%PATH%
set PATH=%KCONF_EXEC_PATH%;%PATH%
set PATH=%ENV_ROOT%\tools\scripts\pkgs;%PATH%
set PATH=%ENV_ROOT%\tools\qemu\qemu32;%PATH%
set PYTHONPATH=%ENV_ROOT%\tools\Python27;
set PATH=%PATH%;
scons --target=eclipse --project-name=828F
Loading…
Cancel
Save