信息修改,通讯,显示相关
This commit is contained in:
1 parent
c9633041ab
commit
ac7e06bbd2
15 files changed
+89
-47
No files matched your search
+15
-1
@@ -38,6 +38,7 @@ static void mb_plc_read_regs(mb_inst_t *hinst)
|
||||
{
|
||||
if (mb_connect(hinst) < 0)//连接失败, 延时返回
|
||||
{
|
||||
PLCLINK_OK = 0;
|
||||
LOG_E("modbus connect fail.");
|
||||
return;
|
||||
}
|
||||
@@ -47,12 +48,15 @@ static void mb_plc_read_regs(mb_inst_t *hinst)
|
||||
//读取 Modbus bits
|
||||
int mrx = mb_read_bits(hinst, 2000, DI_TABLE_SIZE, r_buffer);
|
||||
if (mrx > 0)
|
||||
{ //解包到数据表
|
||||
{
|
||||
PLCLINK_OK = 1;
|
||||
//解包到数据表
|
||||
for (int i = 0; i < DI_TABLE_SIZE; i++) {
|
||||
di_table[i].current_state = (r_buffer[i / 8] >> (i % 8)) & 1;
|
||||
}
|
||||
}else
|
||||
{
|
||||
PLCLINK_OK = 0;
|
||||
rt_thread_mdelay(500);
|
||||
}
|
||||
|
||||
@@ -73,8 +77,12 @@ static void mb_plc_read_regs(mb_inst_t *hinst)
|
||||
int mwy = mb_write_bits(hinst, 2256, DO_TABLE_SIZE, w_buffer);
|
||||
if (mwy ==0)
|
||||
{
|
||||
PLCLINK_OK = 0;
|
||||
rt_thread_mdelay(500);
|
||||
}
|
||||
else{
|
||||
PLCLINK_OK = 1;
|
||||
}
|
||||
|
||||
//输入寄存器d0->6000
|
||||
//u16 r_regsD[AI_TABLE_SIZE];
|
||||
@@ -82,11 +90,13 @@ static void mb_plc_read_regs(mb_inst_t *hinst)
|
||||
int mrd = mb_read_regs(hinst, 6000, AI_TABLE_SIZE, r_regsD);
|
||||
if (mrd > 0)
|
||||
{
|
||||
PLCLINK_OK = 1;
|
||||
for (int i = 0; i < AI_TABLE_SIZE; i++)
|
||||
{
|
||||
ai_table[i].current_Value = r_regsD[i];
|
||||
}
|
||||
}else {
|
||||
PLCLINK_OK = 0;
|
||||
rt_thread_mdelay(500);
|
||||
}
|
||||
|
||||
@@ -100,8 +110,12 @@ static void mb_plc_read_regs(mb_inst_t *hinst)
|
||||
int mwd = mb_write_regs(hinst, 6100, AO_TABLE_SIZE, w_regsD);
|
||||
if (mwd == 0)
|
||||
{
|
||||
PLCLINK_OK = 0;
|
||||
rt_thread_mdelay(500);
|
||||
}
|
||||
else{
|
||||
PLCLINK_OK = 1;
|
||||
}
|
||||
}
|
||||
|
||||
extern struct rt_memheap sram_DTCMRAM,sdram_heap;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <rtdevice.h>
|
||||
#include "data_comm.h"
|
||||
#include <rs485.h>
|
||||
#include "SC828_DATA_table.h"
|
||||
|
||||
#define DBG_TAG "SCCM_link"
|
||||
#define DBG_LVL DBG_LOG
|
||||
@@ -58,6 +59,7 @@ void uart_thread_entry(void *parameter)
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
SCLINK_OK=1;
|
||||
// 动态分配请求结构体(见之前完整代码)
|
||||
struct proc_request *req = rt_malloc(sizeof(struct proc_request));
|
||||
if (!req) continue;
|
||||
@@ -68,7 +70,7 @@ void uart_thread_entry(void *parameter)
|
||||
if (rt_mq_send(request_mq, &req, sizeof(req)) == RT_EOK)
|
||||
{
|
||||
// 等待处理完成
|
||||
if (rt_mq_recv(response_mq, &req, sizeof(req), 500) >= RT_EOK)
|
||||
if (rt_mq_recv(response_mq, &req, sizeof(req), 1000) >= RT_EOK)
|
||||
{
|
||||
if(req->output_len>0) rs485_send(hinst, req->output, req->output_len);
|
||||
}
|
||||
|
||||
@@ -210,6 +210,8 @@ const unsigned char DO_TABLE_SIZE = sizeof(do_table) / sizeof(do_table[0]);
|
||||
const unsigned char AI_TABLE_SIZE = sizeof(ai_table) / sizeof(ai_table[0]);
|
||||
const unsigned char AO_TABLE_SIZE = sizeof(ao_table) / sizeof(ao_table[0]);
|
||||
const unsigned char DATA_TABLE_SIZE = sizeof(data_table) / sizeof(data_table[0]);
|
||||
int8_t PLCLINK_OK = 0;
|
||||
int8_t SCLINK_OK = 0;
|
||||
|
||||
//步骤数据表最大
|
||||
//IO_STEP_DATA step_table[256] ;
|
||||
@@ -399,11 +401,11 @@ void table_thread_entry(void *parameter)
|
||||
rt_thread_delay(500);
|
||||
|
||||
//Ai输入
|
||||
MTT = get_ai_value(4001)/10.0f;
|
||||
MUT = get_ai_value(4002)/10.0f;
|
||||
STTA = get_ai_value(4003)/10.0f;
|
||||
STTB = get_ai_value(4004)/10.0f;
|
||||
STTC = get_ai_value(4005)/10.0f;
|
||||
MTT = get_ai_value(4001);///浮点
|
||||
MUT = get_ai_value(4002);///浮点
|
||||
STTA = get_ai_value(4003);///浮点
|
||||
STTB = get_ai_value(4004);///浮点
|
||||
STTC = get_ai_value(4005);///浮点
|
||||
MTL = get_ai_value(4007);
|
||||
STLA = get_ai_value(4008);
|
||||
STLB = get_ai_value(4009);
|
||||
|
||||
@@ -70,6 +70,9 @@ extern IO_State_DATA data_table[];
|
||||
//extern IO_STEP_DATA step_table[256];
|
||||
extern IO_STEP_DATA *step_table;
|
||||
|
||||
extern int8_t PLCLINK_OK;//plc连接状态
|
||||
extern int8_t SCLINK_OK;//中控连接
|
||||
|
||||
extern const unsigned char DI_TABLE_SIZE;
|
||||
extern const unsigned char DO_TABLE_SIZE;
|
||||
extern const unsigned char AI_TABLE_SIZE;
|
||||
|
||||
@@ -41,18 +41,18 @@ unsigned int UserInfoStart = 900;
|
||||
unsigned int RUN = 0;
|
||||
unsigned int STEPID = 0;
|
||||
|
||||
// 浮点变量
|
||||
float MTT = 0.0f;//主缸温度
|
||||
float MTL = 0.0f;//主缸水位
|
||||
float MTH = 6.0f;//主缸ph
|
||||
float MST = 0.0f;//目标温度
|
||||
float MUT = 0.0f;//主缸温度2
|
||||
float STTA = 0.0f;//料a温度
|
||||
float STLA = 0.0f;//料a水位
|
||||
float STTB = 0.0f;//料b温度
|
||||
float STLB = 0.0f;//料b水位
|
||||
float STTC = 0.0f;//料c温度
|
||||
float STLC = 0.0f;//料c水位
|
||||
// 需要小数点变量
|
||||
unsigned int MTT = 0;//主缸温度
|
||||
unsigned int MTL = 0;//主缸水位
|
||||
unsigned int MTH = 6;//主缸ph
|
||||
unsigned int MST = 0;//目标温度
|
||||
unsigned int MUT = 0;//主缸温度2
|
||||
unsigned int STTA = 0;//料a温度
|
||||
unsigned int STLA = 0;//料a水位
|
||||
unsigned int STTB = 0;//料b温度
|
||||
unsigned int STLB = 0;//料b水位
|
||||
unsigned int STTC = 0;//料c温度
|
||||
unsigned int STLC = 0;//料c水位
|
||||
|
||||
// 控制输出
|
||||
unsigned int Pump = 0;//主泵
|
||||
|
||||
@@ -64,17 +64,17 @@ extern unsigned int P9;
|
||||
extern unsigned int P10;
|
||||
|
||||
// ===== 浮点数变量 =====
|
||||
extern float MTT;
|
||||
extern float MTL;
|
||||
extern float MTH;
|
||||
extern float MST;
|
||||
extern float MUT;
|
||||
extern float STTA;
|
||||
extern float STLA;
|
||||
extern float STTB;
|
||||
extern float STLB;
|
||||
extern float STTC;
|
||||
extern float STLC;
|
||||
extern unsigned int MTT;
|
||||
extern unsigned int MTL;
|
||||
extern unsigned int MTH;
|
||||
extern unsigned int MST;
|
||||
extern unsigned int MUT;
|
||||
extern unsigned int STTA;
|
||||
extern unsigned int STLA;
|
||||
extern unsigned int STTB;
|
||||
extern unsigned int STLB;
|
||||
extern unsigned int STTC;
|
||||
extern unsigned int STLC;
|
||||
extern unsigned int P1;
|
||||
extern unsigned int P2;
|
||||
extern unsigned int P3;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#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
|
||||
@@ -56,13 +57,26 @@ void setup_s_screen(lv_ui *ui)
|
||||
//工单
|
||||
lv_label_set_text(ui->screen_order, (const char *)Work);
|
||||
//水位
|
||||
snprintf(wter_str, sizeof(wter_str), "%04.0f", MTL);
|
||||
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);
|
||||
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{
|
||||
|
||||
}
|
||||
|
||||
update_led_i();
|
||||
update_led_o();
|
||||
|
||||
@@ -61,7 +61,7 @@ static lv_color_t *buf_3_2 = RT_NULL;
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
extern struct rt_memheap sdram_heap; //
|
||||
extern struct rt_memheap sdram_lcd; //
|
||||
void lv_port_disp_init(void)
|
||||
{
|
||||
/*-------------------------
|
||||
@@ -128,21 +128,21 @@ void lv_port_disp_init(void)
|
||||
|
||||
|
||||
// 使用对齐分配函数
|
||||
buf_1 = (lv_color_t *)rt_memheap_alloc_align(&sdram_heap,
|
||||
buf_1 = (lv_color_t *)rt_memheap_alloc_align(&sdram_lcd,
|
||||
sizeof(lv_color_t) * MY_DISP_HOR_RES * 10,
|
||||
4); // ← 关键:对齐到 4 字节
|
||||
|
||||
buf_2_1 = (lv_color_t *)rt_memheap_alloc_align(&sdram_heap,
|
||||
buf_2_1 = (lv_color_t *)rt_memheap_alloc_align(&sdram_lcd,
|
||||
sizeof(lv_color_t) * MY_DISP_HOR_RES * 10,
|
||||
4);
|
||||
buf_2_2 = (lv_color_t *)rt_memheap_alloc_align(&sdram_heap,
|
||||
buf_2_2 = (lv_color_t *)rt_memheap_alloc_align(&sdram_lcd,
|
||||
sizeof(lv_color_t) * MY_DISP_HOR_RES * 10,
|
||||
4);
|
||||
|
||||
buf_3_1 = (lv_color_t *)rt_memheap_alloc_align(&sdram_heap,
|
||||
buf_3_1 = (lv_color_t *)rt_memheap_alloc_align(&sdram_lcd,
|
||||
sizeof(lv_color_t) * MY_DISP_HOR_RES * MY_DISP_VER_RES,
|
||||
4);
|
||||
buf_3_2 = (lv_color_t *)rt_memheap_alloc_align(&sdram_heap,
|
||||
buf_3_2 = (lv_color_t *)rt_memheap_alloc_align(&sdram_lcd,
|
||||
sizeof(lv_color_t) * MY_DISP_HOR_RES * MY_DISP_VER_RES,
|
||||
4);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <guider/generated/widgets_init.h>
|
||||
#include "lvgl.h"
|
||||
#include <ui_data_labels.h>
|
||||
#include "libcsv.h"
|
||||
//#include "libcsv.h"
|
||||
|
||||
// 全局或静态数组
|
||||
char buf[8];
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
static SDRAM_HandleTypeDef hsdram1;
|
||||
static FMC_SDRAM_CommandTypeDef command;
|
||||
#ifdef RT_USING_MEMHEAP_AS_HEAP
|
||||
struct rt_memheap sdram_heap;
|
||||
struct rt_memheap sdram_heap,sdram_lcd;
|
||||
#endif
|
||||
/**
|
||||
* @brief Perform the SDRAM exernal memory inialization sequence
|
||||
@@ -161,6 +161,7 @@ static int SDRAM_Init(void)
|
||||
#ifdef RT_USING_MEMHEAP_AS_HEAP
|
||||
/* If RT_USING_MEMHEAP_AS_HEAP is enabled, SDRAM is initialized to the heap */
|
||||
rt_memheap_init(&sdram_heap, "SDRAM", (void *)SDRAM1_START, SDRAM1_SIZE);
|
||||
rt_memheap_init(&sdram_lcd, "LCDRAM", (void *)SDRAM_LCD_START, SDRAM_LCD_SIZE);
|
||||
#endif
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "DB_SQLite.h"
|
||||
#include "sqlite3.h"
|
||||
#include <stdbool.h>
|
||||
#include "libcsv.h"
|
||||
//#include "libcsv.h"
|
||||
|
||||
#define DB_NAME "/sddisk/SC828.db"
|
||||
int db_HelperInit;
|
||||
|
||||
Reference in new issue
Block a user