parent
6f36d2609e
commit
477661196a
|
@ -32,28 +32,34 @@ void config_items_set_color(MOD_CONF_ITEMS cur, uint32_t color);
|
|||
void config_items_check(MOD_CONF_ITEMS cur, MOD_CONF_ITEMS cur_prv);
|
||||
|
||||
//Modbus配置界面,弹窗,选中cur,熄灭cur_prv
|
||||
void window_num_check(uint8_t cur, uint8_t cur_prv);
|
||||
void config_window_num_check(uint8_t cur, uint8_t cur_prv);
|
||||
|
||||
//Modbus配置界面,弹窗,设定显示内容
|
||||
void window_num_set(uint8_t pos, uint8_t num);
|
||||
void config_window_num_set(uint8_t pos, uint8_t num);
|
||||
|
||||
//Modbus配置界面,更新弹窗内容
|
||||
void window_display(void);
|
||||
void config_window_update(void);
|
||||
|
||||
//Modbus配置界面,弹窗内容转化为数值
|
||||
void window2value(void);
|
||||
void config_window2value(void);
|
||||
|
||||
//打开trx弹窗后,初始化显示内容
|
||||
void trx_window_init(void);
|
||||
|
||||
//Modbus收发界面,设置选项底色
|
||||
void trx_items_set_color(MOD_TRX_ITEMS cur, uint32_t color);
|
||||
|
||||
//Modbus收发界面,设置data中32个数字的底色
|
||||
void set_trx_num_color(uint8_t cur, uint32_t color);
|
||||
|
||||
//Modbus收发界面,选中选项
|
||||
void trx_items_check(MOD_TRX_ITEMS cur, MOD_TRX_ITEMS cur_prv);
|
||||
|
||||
//Modbus收发界面,设置data中32个数字的底色
|
||||
void trx_set_window_num_color(uint8_t cur, uint32_t color);
|
||||
|
||||
//Modbus收发界面,弹窗,选中数字
|
||||
void window_trx_check(uint8_t cur, uint8_t cur_prv);
|
||||
void trx_window_num_check(uint8_t cur, uint8_t cur_prv);
|
||||
|
||||
//Modbus收发界面,将弹窗内容转化成数值
|
||||
void trx_window_num2val(void);
|
||||
|
||||
//按键功能
|
||||
void key_functions_modbus(void);
|
||||
|
@ -67,9 +73,6 @@ void scr_modbus_trx_recover(void);
|
|||
//任务循环中反复执行的功能
|
||||
void screen_modbus_trx_run(void);
|
||||
|
||||
//打开trx弹窗后,初始化显示内容
|
||||
void window_trx_init(void);
|
||||
|
||||
extern uint8_t com_switch_cursor;
|
||||
extern uint8_t com_switch_cursor_prv;
|
||||
extern uint8_t trx_focus;
|
||||
|
@ -79,7 +82,7 @@ extern uint8_t config_focus;
|
|||
extern MOD_TRX_ITEMS mod_mas_trx_cursor;
|
||||
extern MOD_TRX_ITEMS mod_mas_trx_cursor_prv;
|
||||
extern uint8_t trx_focus;
|
||||
extern lv_obj_t *window_trx_nums[32];
|
||||
extern lv_obj_t *lvobj_window_trx_nums[32];
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
//Modbus配置界面,弹窗内部游标移动
|
||||
void cursor_move(int8_t step);
|
||||
|
||||
extern uint8_t window_config_num[4];
|
||||
extern uint8_t window_config_cursor;
|
||||
extern uint8_t window_config_cursor_prv;
|
||||
extern uint8_t window_trx_focus;
|
||||
extern uint8_t window_num[4];
|
||||
extern uint8_t window_cursor;
|
||||
extern uint8_t window_cursor_prv;
|
||||
extern uint8_t window_trx_num[32];
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "app_screen_modbus.h"
|
||||
|
||||
lv_obj_t *window_trx_nums[32];
|
||||
lv_obj_t *lvobj_window_trx_nums[32];
|
||||
|
||||
//modbus配置项的游标
|
||||
MOD_CONF_ITEMS mod_mas_conf_cursor = MOD_CONF_SLAVE_ID;
|
||||
|
@ -88,7 +88,7 @@ void config_items_check(MOD_CONF_ITEMS cur, MOD_CONF_ITEMS cur_prv)
|
|||
config_items_set_color(cur_prv, COLOR_ITEMS_UNCHECKED);
|
||||
}
|
||||
|
||||
void window_num_check(uint8_t cur, uint8_t cur_prv)
|
||||
void config_window_num_check(uint8_t cur, uint8_t cur_prv)
|
||||
{
|
||||
switch (cur)
|
||||
{
|
||||
|
@ -151,7 +151,7 @@ void window_num_check(uint8_t cur, uint8_t cur_prv)
|
|||
}
|
||||
}
|
||||
|
||||
void window_num_set(uint8_t pos, uint8_t num)
|
||||
void config_window_num_set(uint8_t pos, uint8_t num)
|
||||
{
|
||||
char str_temp[8] = {0};
|
||||
|
||||
|
@ -203,24 +203,24 @@ void window_num_set(uint8_t pos, uint8_t num)
|
|||
}
|
||||
}
|
||||
|
||||
void window_display(void)
|
||||
void config_window_update(void)
|
||||
{
|
||||
switch (mod_mas_conf_cursor)
|
||||
{
|
||||
case MOD_CONF_SLAVE_ID:
|
||||
{
|
||||
//前两位显示“0x”,游标从2开始,2-3
|
||||
window_num[0] = 20;
|
||||
window_num[1] = 21;
|
||||
window_num[2] = mod_master.target_id >> 4;
|
||||
window_num[3] = mod_master.target_id & 0x0F;
|
||||
window_config_num[0] = 20;
|
||||
window_config_num[1] = 21;
|
||||
window_config_num[2] = mod_master.target_id >> 4;
|
||||
window_config_num[3] = mod_master.target_id & 0x0F;
|
||||
for(uint8_t i = 0; i < 4; i++)
|
||||
{
|
||||
window_num_set(i, window_num[i]);
|
||||
config_window_num_set(i, window_config_num[i]);
|
||||
}
|
||||
window_cursor = 2;
|
||||
window_cursor_prv = 99;
|
||||
window_num_check(window_cursor, window_cursor_prv);
|
||||
window_config_cursor = 2;
|
||||
window_config_cursor_prv = 99;
|
||||
config_window_num_check(window_config_cursor, window_config_cursor_prv);
|
||||
|
||||
lv_obj_clear_flag(guider_ui.screen_modbus_config_window_config, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
@ -229,17 +229,17 @@ void window_display(void)
|
|||
case MOD_CONF_START_ADDRESS:
|
||||
{
|
||||
//游标从0开始,0-3
|
||||
window_num[0] = 0x000F & (mod_master.start_address >> 12);
|
||||
window_num[1] = 0x000F & (mod_master.start_address >> 8);
|
||||
window_num[2] = 0x000F & (mod_master.start_address >> 4);
|
||||
window_num[3] = 0x000F & (mod_master.start_address );
|
||||
window_config_num[0] = 0x000F & (mod_master.start_address >> 12);
|
||||
window_config_num[1] = 0x000F & (mod_master.start_address >> 8);
|
||||
window_config_num[2] = 0x000F & (mod_master.start_address >> 4);
|
||||
window_config_num[3] = 0x000F & (mod_master.start_address );
|
||||
for(uint8_t i = 0; i < 4; i++)
|
||||
{
|
||||
window_num_set(i, window_num[i]);
|
||||
config_window_num_set(i, window_config_num[i]);
|
||||
}
|
||||
window_cursor = 0;
|
||||
window_cursor_prv = 99;
|
||||
window_num_check(window_cursor, window_cursor_prv);
|
||||
window_config_cursor = 0;
|
||||
window_config_cursor_prv = 99;
|
||||
config_window_num_check(window_config_cursor, window_config_cursor_prv);
|
||||
|
||||
lv_obj_clear_flag(guider_ui.screen_modbus_config_window_config, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
@ -248,17 +248,17 @@ void window_display(void)
|
|||
case MOD_CONF_COMMAND:
|
||||
{
|
||||
//前两位显示“0x”,游标从2开始,2-3
|
||||
window_num[0] = 20;
|
||||
window_num[1] = 21;
|
||||
window_num[2] = mod_master.command_code >> 4;
|
||||
window_num[3] = mod_master.command_code & 0x0F;
|
||||
window_config_num[0] = 20;
|
||||
window_config_num[1] = 21;
|
||||
window_config_num[2] = mod_master.command_code >> 4;
|
||||
window_config_num[3] = mod_master.command_code & 0x0F;
|
||||
for(uint8_t i = 0; i < 4; i++)
|
||||
{
|
||||
window_num_set(i, window_num[i]);
|
||||
config_window_num_set(i, window_config_num[i]);
|
||||
}
|
||||
window_cursor = 2;
|
||||
window_cursor_prv = 99;
|
||||
window_num_check(window_cursor, window_cursor_prv);
|
||||
window_config_cursor = 2;
|
||||
window_config_cursor_prv = 99;
|
||||
config_window_num_check(window_config_cursor, window_config_cursor_prv);
|
||||
|
||||
lv_obj_clear_flag(guider_ui.screen_modbus_config_window_config, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
@ -267,17 +267,17 @@ void window_display(void)
|
|||
case MOD_CONF_REGISTER_NUM:
|
||||
{
|
||||
//第一位显示“0”,游标从1开始,1-3
|
||||
window_num[0] = 0;
|
||||
window_num[1] = mod_master.register_num / 100;
|
||||
window_num[2] = (mod_master.register_num / 10) % 10;
|
||||
window_num[3] = mod_master.register_num % 10;
|
||||
window_config_num[0] = 0;
|
||||
window_config_num[1] = mod_master.register_num / 100;
|
||||
window_config_num[2] = (mod_master.register_num / 10) % 10;
|
||||
window_config_num[3] = mod_master.register_num % 10;
|
||||
for(uint8_t i = 0; i < 4; i++)
|
||||
{
|
||||
window_num_set(i, window_num[i]);
|
||||
config_window_num_set(i, window_config_num[i]);
|
||||
}
|
||||
window_cursor = 1;
|
||||
window_cursor_prv = 99;
|
||||
window_num_check(window_cursor, window_cursor_prv);
|
||||
window_config_cursor = 1;
|
||||
window_config_cursor_prv = 99;
|
||||
config_window_num_check(window_config_cursor, window_config_cursor_prv);
|
||||
|
||||
lv_obj_clear_flag(guider_ui.screen_modbus_config_window_config, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ void window_display(void)
|
|||
}
|
||||
}
|
||||
|
||||
void window2value(void)
|
||||
void config_window2value(void)
|
||||
{
|
||||
char str_temp[16];
|
||||
|
||||
|
@ -296,9 +296,9 @@ void window2value(void)
|
|||
{
|
||||
case MOD_CONF_SLAVE_ID:
|
||||
{
|
||||
mod_master.target_id = window_num[2] & 0x0F;
|
||||
mod_master.target_id = window_config_num[2] & 0x0F;
|
||||
mod_master.target_id <<= 4;
|
||||
mod_master.target_id += window_num[3] & 0x0F;
|
||||
mod_master.target_id += window_config_num[3] & 0x0F;
|
||||
|
||||
sprintf(str_temp, "0x%02x", mod_master.target_id);
|
||||
lv_label_set_text(guider_ui.screen_modbus_config_value_device_addr, str_temp);
|
||||
|
@ -307,13 +307,13 @@ void window2value(void)
|
|||
|
||||
case MOD_CONF_START_ADDRESS:
|
||||
{
|
||||
mod_master.start_address = window_num[0] & 0x0F;
|
||||
mod_master.start_address = window_config_num[0] & 0x0F;
|
||||
mod_master.start_address <<= 4;
|
||||
mod_master.start_address += window_num[1] & 0x0F;
|
||||
mod_master.start_address += window_config_num[1] & 0x0F;
|
||||
mod_master.start_address <<= 4;
|
||||
mod_master.start_address += window_num[2] & 0x0F;
|
||||
mod_master.start_address += window_config_num[2] & 0x0F;
|
||||
mod_master.start_address <<= 4;
|
||||
mod_master.start_address += window_num[3] & 0x0F;
|
||||
mod_master.start_address += window_config_num[3] & 0x0F;
|
||||
|
||||
sprintf(str_temp, "0x%04x", mod_master.start_address);
|
||||
lv_label_set_text(guider_ui.screen_modbus_config_value_start_addr, str_temp);
|
||||
|
@ -322,9 +322,9 @@ void window2value(void)
|
|||
|
||||
case MOD_CONF_COMMAND:
|
||||
{
|
||||
mod_master.command_code= window_num[2];
|
||||
mod_master.command_code= window_config_num[2];
|
||||
mod_master.command_code <<= 4;
|
||||
mod_master.command_code += window_num[3];
|
||||
mod_master.command_code += window_config_num[3];
|
||||
|
||||
sprintf(str_temp, "0x%02x", mod_master.command_code);
|
||||
lv_label_set_text(guider_ui.screen_modbus_config_value_cmd, str_temp);
|
||||
|
@ -333,7 +333,7 @@ void window2value(void)
|
|||
|
||||
case MOD_CONF_REGISTER_NUM:
|
||||
{
|
||||
mod_master.register_num = window_num[1]*100 + window_num[2]*10 + window_num[3];
|
||||
mod_master.register_num = window_config_num[1]*100 + window_config_num[2]*10 + window_config_num[3];
|
||||
|
||||
sprintf(str_temp, "%d", mod_master.register_num);
|
||||
lv_label_set_text(guider_ui.screen_modbus_config_value_register_num, str_temp);
|
||||
|
@ -345,6 +345,66 @@ void window2value(void)
|
|||
}
|
||||
}
|
||||
|
||||
//打开trx弹窗后,初始化显示内容
|
||||
uint8_t lv_obj2nums_init_flag = 0;
|
||||
void trx_window_init(void)
|
||||
{
|
||||
if( lv_obj2nums_init_flag == 0 )
|
||||
{
|
||||
lv_obj2nums_init_flag = 1;
|
||||
|
||||
lvobj_window_trx_nums[0] = guider_ui.screen_modbus_trx_num_00;
|
||||
lvobj_window_trx_nums[1] = guider_ui.screen_modbus_trx_num_01;
|
||||
lvobj_window_trx_nums[2] = guider_ui.screen_modbus_trx_num_02;
|
||||
lvobj_window_trx_nums[3] = guider_ui.screen_modbus_trx_num_03;
|
||||
lvobj_window_trx_nums[4] = guider_ui.screen_modbus_trx_num_04;
|
||||
lvobj_window_trx_nums[5] = guider_ui.screen_modbus_trx_num_05;
|
||||
lvobj_window_trx_nums[6] = guider_ui.screen_modbus_trx_num_06;
|
||||
lvobj_window_trx_nums[7] = guider_ui.screen_modbus_trx_num_07;
|
||||
lvobj_window_trx_nums[8] = guider_ui.screen_modbus_trx_num_10;
|
||||
lvobj_window_trx_nums[9] = guider_ui.screen_modbus_trx_num_11;
|
||||
lvobj_window_trx_nums[10] = guider_ui.screen_modbus_trx_num_12;
|
||||
lvobj_window_trx_nums[11] = guider_ui.screen_modbus_trx_num_13;
|
||||
lvobj_window_trx_nums[12] = guider_ui.screen_modbus_trx_num_14;
|
||||
lvobj_window_trx_nums[13] = guider_ui.screen_modbus_trx_num_15;
|
||||
lvobj_window_trx_nums[14] = guider_ui.screen_modbus_trx_num_16;
|
||||
lvobj_window_trx_nums[15] = guider_ui.screen_modbus_trx_num_17;
|
||||
lvobj_window_trx_nums[16] = guider_ui.screen_modbus_trx_num_20;
|
||||
lvobj_window_trx_nums[17] = guider_ui.screen_modbus_trx_num_21;
|
||||
lvobj_window_trx_nums[18] = guider_ui.screen_modbus_trx_num_22;
|
||||
lvobj_window_trx_nums[19] = guider_ui.screen_modbus_trx_num_23;
|
||||
lvobj_window_trx_nums[20] = guider_ui.screen_modbus_trx_num_24;
|
||||
lvobj_window_trx_nums[21] = guider_ui.screen_modbus_trx_num_25;
|
||||
lvobj_window_trx_nums[22] = guider_ui.screen_modbus_trx_num_26;
|
||||
lvobj_window_trx_nums[23] = guider_ui.screen_modbus_trx_num_27;
|
||||
lvobj_window_trx_nums[24] = guider_ui.screen_modbus_trx_num_30;
|
||||
lvobj_window_trx_nums[25] = guider_ui.screen_modbus_trx_num_31;
|
||||
lvobj_window_trx_nums[26] = guider_ui.screen_modbus_trx_num_32;
|
||||
lvobj_window_trx_nums[27] = guider_ui.screen_modbus_trx_num_33;
|
||||
lvobj_window_trx_nums[28] = guider_ui.screen_modbus_trx_num_34;
|
||||
lvobj_window_trx_nums[29] = guider_ui.screen_modbus_trx_num_35;
|
||||
lvobj_window_trx_nums[30] = guider_ui.screen_modbus_trx_num_36;
|
||||
lvobj_window_trx_nums[31] = guider_ui.screen_modbus_trx_num_37;
|
||||
|
||||
memset(window_trx_num, 16, sizeof(window_trx_num));
|
||||
}
|
||||
|
||||
char str_temp[8];
|
||||
for(uint8_t i = 0; i < 32; i++)
|
||||
{
|
||||
if(window_trx_num[i] == 16)
|
||||
{
|
||||
lv_label_set_text(lvobj_window_trx_nums[i], "-");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(str_temp, "%x", window_trx_num[i]);
|
||||
lv_label_set_text(lvobj_window_trx_nums[i], str_temp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void trx_items_set_color(MOD_TRX_ITEMS cur, uint32_t color)
|
||||
{
|
||||
switch (cur)
|
||||
|
@ -397,57 +457,9 @@ void trx_items_check(MOD_TRX_ITEMS cur, MOD_TRX_ITEMS cur_prv)
|
|||
trx_items_set_color(cur_prv, COLOR_ITEMS_UNCHECKED);
|
||||
}
|
||||
|
||||
//打开trx弹窗后,初始化显示内容
|
||||
uint8_t lv_obj2nums_init_flag = 0;
|
||||
void window_trx_init(void)
|
||||
void trx_set_window_num_color(uint8_t cur, uint32_t color)
|
||||
{
|
||||
if( !lv_obj2nums_init_flag )
|
||||
{
|
||||
lv_obj2nums_init_flag = 1;
|
||||
|
||||
window_trx_nums[0] = guider_ui.screen_modbus_trx_num_00;
|
||||
window_trx_nums[1] = guider_ui.screen_modbus_trx_num_01;
|
||||
window_trx_nums[2] = guider_ui.screen_modbus_trx_num_02;
|
||||
window_trx_nums[3] = guider_ui.screen_modbus_trx_num_03;
|
||||
window_trx_nums[4] = guider_ui.screen_modbus_trx_num_04;
|
||||
window_trx_nums[5] = guider_ui.screen_modbus_trx_num_05;
|
||||
window_trx_nums[6] = guider_ui.screen_modbus_trx_num_06;
|
||||
window_trx_nums[7] = guider_ui.screen_modbus_trx_num_07;
|
||||
window_trx_nums[8] = guider_ui.screen_modbus_trx_num_10;
|
||||
window_trx_nums[9] = guider_ui.screen_modbus_trx_num_11;
|
||||
window_trx_nums[10] = guider_ui.screen_modbus_trx_num_12;
|
||||
window_trx_nums[11] = guider_ui.screen_modbus_trx_num_13;
|
||||
window_trx_nums[12] = guider_ui.screen_modbus_trx_num_14;
|
||||
window_trx_nums[13] = guider_ui.screen_modbus_trx_num_15;
|
||||
window_trx_nums[14] = guider_ui.screen_modbus_trx_num_16;
|
||||
window_trx_nums[15] = guider_ui.screen_modbus_trx_num_17;
|
||||
window_trx_nums[16] = guider_ui.screen_modbus_trx_num_20;
|
||||
window_trx_nums[17] = guider_ui.screen_modbus_trx_num_21;
|
||||
window_trx_nums[18] = guider_ui.screen_modbus_trx_num_22;
|
||||
window_trx_nums[19] = guider_ui.screen_modbus_trx_num_23;
|
||||
window_trx_nums[20] = guider_ui.screen_modbus_trx_num_24;
|
||||
window_trx_nums[21] = guider_ui.screen_modbus_trx_num_25;
|
||||
window_trx_nums[22] = guider_ui.screen_modbus_trx_num_26;
|
||||
window_trx_nums[23] = guider_ui.screen_modbus_trx_num_27;
|
||||
window_trx_nums[24] = guider_ui.screen_modbus_trx_num_30;
|
||||
window_trx_nums[25] = guider_ui.screen_modbus_trx_num_31;
|
||||
window_trx_nums[26] = guider_ui.screen_modbus_trx_num_32;
|
||||
window_trx_nums[27] = guider_ui.screen_modbus_trx_num_33;
|
||||
window_trx_nums[28] = guider_ui.screen_modbus_trx_num_34;
|
||||
window_trx_nums[29] = guider_ui.screen_modbus_trx_num_35;
|
||||
window_trx_nums[30] = guider_ui.screen_modbus_trx_num_36;
|
||||
window_trx_nums[31] = guider_ui.screen_modbus_trx_num_37;
|
||||
}
|
||||
|
||||
for(uint8_t i = 0; i < 32; i++)
|
||||
{
|
||||
lv_label_set_text(window_trx_nums[i], "-");
|
||||
}
|
||||
}
|
||||
|
||||
void set_trx_num_color(uint8_t cur, uint32_t color)
|
||||
{
|
||||
//设备底色的接口函数数据类型不一样,用window_trx_nums[i]循环会进入硬件错误中断
|
||||
//设备底色的接口函数数据类型不一样,用lvobj_window_trx_nums[i]循环会进入硬件错误中断
|
||||
|
||||
switch (cur)
|
||||
{
|
||||
|
@ -584,18 +596,62 @@ void set_trx_num_color(uint8_t cur, uint32_t color)
|
|||
}
|
||||
}
|
||||
|
||||
void window_trx_check(uint8_t cur, uint8_t cur_prv)
|
||||
void trx_window_num_check(uint8_t cur, uint8_t cur_prv)
|
||||
{
|
||||
if(window_trx_focus == 1)
|
||||
{
|
||||
set_trx_num_color(cur, COLOR_CONTENTS_FOCUSED);
|
||||
trx_set_window_num_color(cur, COLOR_CONTENTS_FOCUSED);
|
||||
}
|
||||
else
|
||||
{
|
||||
set_trx_num_color(cur, COLOR_CONTENTS_CHECKED);
|
||||
trx_set_window_num_color(cur, COLOR_CONTENTS_CHECKED);
|
||||
}
|
||||
|
||||
set_trx_num_color(cur_prv, COLOR_CONTENTS_UNCHECKED);
|
||||
trx_set_window_num_color(cur_prv, COLOR_CONTENTS_UNCHECKED);
|
||||
}
|
||||
|
||||
void trx_window_num2val(void)
|
||||
{
|
||||
//初次打开trx界面的弹窗时,所有的位置均为“-”。
|
||||
//从左往右,从上往下,以第一个出现的“-”作为终止位
|
||||
uint8_t val_len = 0;
|
||||
char str0[10] = {0};
|
||||
char str_temp[150] = {0};
|
||||
|
||||
//从第0个开始,寻找终止位
|
||||
for(uint8_t i = 0; i < 32; i++)
|
||||
{
|
||||
//[0,15]为十六进制单字符,16规定为“-”
|
||||
if( window_trx_num[i] == 16 )
|
||||
{
|
||||
if( i % 2 )
|
||||
{ //[][][]...[x,-],“-”在奇数位,置零
|
||||
window_trx_num[i] = 0;
|
||||
val_len = (i+1)/2;
|
||||
}
|
||||
else
|
||||
{
|
||||
val_len = i/2;
|
||||
}
|
||||
|
||||
for(uint8_t j = 0; j < val_len; j++)
|
||||
{
|
||||
mod_master.data_tx_value[j] = window_trx_num[2*j];
|
||||
mod_master.data_tx_value[j] <<= 4;
|
||||
mod_master.data_tx_value[j] += window_trx_num[2*j + 1]&0x0F;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//在Data窗格内显示mod_master.data_tx_value
|
||||
for(uint8_t k = 0; k < val_len; k++)
|
||||
{
|
||||
sprintf(str0, "%02x ", mod_master.data_tx_value[k]);
|
||||
strcat(str_temp, str0);
|
||||
}
|
||||
lv_label_set_text(guider_ui.screen_modbus_trx_value_Data, str_temp);
|
||||
}
|
||||
|
||||
void scr_modbus_config_recover(void)
|
||||
|
@ -630,7 +686,8 @@ void scr_modbus_config_recover(void)
|
|||
//lv_label_set_text(guider_ui.screen_modbus_config_value_calibration, );
|
||||
//lv_label_set_text(guider_ui.screen_modbus_config_value_next, );
|
||||
|
||||
mod_mas_conf_cursor = MOD_CONF_SLAVE_ID; //配置项的游标
|
||||
//配置项的游标
|
||||
mod_mas_conf_cursor = MOD_CONF_SLAVE_ID;
|
||||
mod_mas_conf_cursor_prv = MOD_CONF_NONE;
|
||||
config_items_check(mod_mas_conf_cursor, mod_mas_conf_cursor_prv);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include "key_functions_modbus.h"
|
||||
|
||||
uint8_t mod_trx_set_flag = 0; //trx的屏幕是否加载过
|
||||
uint8_t window_cursor = 0; //弹窗游标位置
|
||||
uint8_t window_cursor_prv = 0;
|
||||
uint8_t window_num[4] = {0}; //配置窗口内的四个数字
|
||||
uint8_t mod_trx_set_flag = 0; //trx的屏幕是否加载过
|
||||
uint8_t window_config_cursor = 0; //弹窗游标位置
|
||||
uint8_t window_config_cursor_prv = 0; //前一时刻的游标位置
|
||||
uint8_t window_config_num[4] = {0}; //配置窗口内的四个数字
|
||||
|
||||
uint8_t window_trx_num[32] = {0}; //收发界面data窗口内的32个数字
|
||||
uint8_t window_trx_num[32] = {0}; //收发界面data窗口内的32个数字,范围[0,16],其中[0,15]为十六进制单字符,16定义为“-”
|
||||
uint8_t window_trx_cursor = 0;
|
||||
uint8_t window_trx_cursor_prv = 0;
|
||||
uint8_t window_trx_focus = 0; //收发界面data窗口内的焦点
|
||||
|
@ -16,44 +16,44 @@ void cursor_move(int8_t step)
|
|||
{
|
||||
case MOD_CONF_SLAVE_ID:
|
||||
{
|
||||
window_cursor_prv = window_cursor;
|
||||
window_cursor = 3*(window_cursor == 2) + 2*(window_cursor == 3);
|
||||
window_config_cursor_prv = window_config_cursor;
|
||||
window_config_cursor = 3*(window_config_cursor == 2) + 2*(window_config_cursor == 3);
|
||||
}
|
||||
break;
|
||||
|
||||
case MOD_CONF_START_ADDRESS:
|
||||
{
|
||||
window_cursor_prv = window_cursor;
|
||||
window_cursor += step;
|
||||
if(window_cursor > 200)
|
||||
window_config_cursor_prv = window_config_cursor;
|
||||
window_config_cursor += step;
|
||||
if(window_config_cursor > 200)
|
||||
{
|
||||
window_cursor = 3;
|
||||
window_config_cursor = 3;
|
||||
}
|
||||
else if (window_cursor > 3)
|
||||
else if (window_config_cursor > 3)
|
||||
{
|
||||
window_cursor = 0;
|
||||
window_config_cursor = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MOD_CONF_COMMAND:
|
||||
{
|
||||
window_cursor_prv = window_cursor;
|
||||
window_cursor = 3*(window_cursor == 2) + 2*(window_cursor == 3);
|
||||
window_config_cursor_prv = window_config_cursor;
|
||||
window_config_cursor = 3*(window_config_cursor == 2) + 2*(window_config_cursor == 3);
|
||||
}
|
||||
break;
|
||||
|
||||
case MOD_CONF_REGISTER_NUM:
|
||||
{
|
||||
window_cursor_prv = window_cursor;
|
||||
window_cursor += step;
|
||||
if(window_cursor < 1)
|
||||
window_config_cursor_prv = window_config_cursor;
|
||||
window_config_cursor += step;
|
||||
if(window_config_cursor < 1)
|
||||
{
|
||||
window_cursor = 3;
|
||||
window_config_cursor = 3;
|
||||
}
|
||||
else if (window_cursor > 3)
|
||||
else if (window_config_cursor > 3)
|
||||
{
|
||||
window_cursor = 1;
|
||||
window_config_cursor = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -62,7 +62,7 @@ void cursor_move(int8_t step)
|
|||
break;
|
||||
}
|
||||
|
||||
window_num_check(window_cursor, window_cursor_prv);
|
||||
config_window_num_check(window_config_cursor, window_config_cursor_prv);
|
||||
}
|
||||
|
||||
void key_functions_modbus(void)
|
||||
|
@ -104,17 +104,17 @@ void key_functions_modbus(void)
|
|||
{
|
||||
if( (mod_mas_conf_cursor == MOD_CONF_SLAVE_ID)||(mod_mas_conf_cursor == MOD_CONF_START_ADDRESS)||(mod_mas_conf_cursor == MOD_CONF_COMMAND) )
|
||||
{
|
||||
window_num[window_cursor] += 1;
|
||||
if(window_num[window_cursor] >= 16) window_num[window_cursor] = 0;
|
||||
window_config_num[window_config_cursor] += 1;
|
||||
if(window_config_num[window_config_cursor] >= 16) window_config_num[window_config_cursor] = 0;
|
||||
|
||||
window_num_set(window_cursor, window_num[window_cursor]);
|
||||
config_window_num_set(window_config_cursor, window_config_num[window_config_cursor]);
|
||||
}
|
||||
else if (mod_mas_conf_cursor == MOD_CONF_REGISTER_NUM)
|
||||
{
|
||||
window_num[window_cursor] += 1;
|
||||
if(window_num[window_cursor] >= 10) window_num[window_cursor] = 0;
|
||||
window_config_num[window_config_cursor] += 1;
|
||||
if(window_config_num[window_config_cursor] >= 10) window_config_num[window_config_cursor] = 0;
|
||||
|
||||
window_num_set(window_cursor, window_num[window_cursor]);
|
||||
config_window_num_set(window_config_cursor, window_config_num[window_config_cursor]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -139,7 +139,7 @@ void key_functions_modbus(void)
|
|||
window_trx_cursor -= 8;
|
||||
if( window_trx_cursor > 200 ) window_trx_cursor += 32;
|
||||
|
||||
window_trx_check(window_trx_cursor, window_trx_cursor_prv);
|
||||
trx_window_num_check(window_trx_cursor, window_trx_cursor_prv);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -149,11 +149,11 @@ void key_functions_modbus(void)
|
|||
if(window_trx_num[window_trx_cursor] != 16)
|
||||
{
|
||||
sprintf(str_temp, "%x", window_trx_num[window_trx_cursor]);
|
||||
lv_label_set_text(window_trx_nums[window_trx_cursor], str_temp);
|
||||
lv_label_set_text(lvobj_window_trx_nums[window_trx_cursor], str_temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_label_set_text(window_trx_nums[window_trx_cursor], "-");
|
||||
lv_label_set_text(lvobj_window_trx_nums[window_trx_cursor], "-");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -195,17 +195,17 @@ void key_functions_modbus(void)
|
|||
{
|
||||
if( (mod_mas_conf_cursor == MOD_CONF_SLAVE_ID)||(mod_mas_conf_cursor == MOD_CONF_START_ADDRESS)||(mod_mas_conf_cursor == MOD_CONF_COMMAND) )
|
||||
{
|
||||
window_num[window_cursor] -= 1;
|
||||
if(window_num[window_cursor] > 200) window_num[window_cursor] = 15;
|
||||
window_config_num[window_config_cursor] -= 1;
|
||||
if(window_config_num[window_config_cursor] > 200) window_config_num[window_config_cursor] = 15;
|
||||
|
||||
window_num_set(window_cursor, window_num[window_cursor]);
|
||||
config_window_num_set(window_config_cursor, window_config_num[window_config_cursor]);
|
||||
}
|
||||
else if (mod_mas_conf_cursor == MOD_CONF_REGISTER_NUM)
|
||||
{
|
||||
window_num[window_cursor] -= 1;
|
||||
if(window_num[window_cursor] > 200) window_num[window_cursor] = 9;
|
||||
window_config_num[window_config_cursor] -= 1;
|
||||
if(window_config_num[window_config_cursor] > 200) window_config_num[window_config_cursor] = 9;
|
||||
|
||||
window_num_set(window_cursor, window_num[window_cursor]);
|
||||
config_window_num_set(window_config_cursor, window_config_num[window_config_cursor]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -230,7 +230,7 @@ void key_functions_modbus(void)
|
|||
window_trx_cursor += 8;
|
||||
if( window_trx_cursor > 31 ) window_trx_cursor -= 32;
|
||||
|
||||
window_trx_check(window_trx_cursor, window_trx_cursor_prv);
|
||||
trx_window_num_check(window_trx_cursor, window_trx_cursor_prv);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -240,11 +240,11 @@ void key_functions_modbus(void)
|
|||
if(window_trx_num[window_trx_cursor] != 16)
|
||||
{
|
||||
sprintf(str_temp, "%x", window_trx_num[window_trx_cursor]);
|
||||
lv_label_set_text(window_trx_nums[window_trx_cursor], str_temp);
|
||||
lv_label_set_text(lvobj_window_trx_nums[window_trx_cursor], str_temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_label_set_text(window_trx_nums[window_trx_cursor], "-");
|
||||
lv_label_set_text(lvobj_window_trx_nums[window_trx_cursor], "-");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ void key_functions_modbus(void)
|
|||
window_trx_cursor -= 1;
|
||||
if( window_trx_cursor > 200 ) window_trx_cursor = 31;
|
||||
|
||||
window_trx_check(window_trx_cursor, window_trx_cursor_prv);
|
||||
trx_window_num_check(window_trx_cursor, window_trx_cursor_prv);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -458,7 +458,7 @@ void key_functions_modbus(void)
|
|||
window_trx_cursor += 1;
|
||||
if( window_trx_cursor > 31 ) window_trx_cursor = 0;
|
||||
|
||||
window_trx_check(window_trx_cursor, window_trx_cursor_prv);
|
||||
trx_window_num_check(window_trx_cursor, window_trx_cursor_prv);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -482,7 +482,7 @@ void key_functions_modbus(void)
|
|||
{
|
||||
case MOD_CONF_SLAVE_ID:
|
||||
{
|
||||
window_display();
|
||||
config_window_update();
|
||||
current_operation = MODBUS_MASTER_CONFIG_MODIFY;
|
||||
key_config_update(current_operation);
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ void key_functions_modbus(void)
|
|||
|
||||
case MOD_CONF_START_ADDRESS:
|
||||
{
|
||||
window_display();
|
||||
config_window_update();
|
||||
current_operation = MODBUS_MASTER_CONFIG_MODIFY;
|
||||
key_config_update(current_operation);
|
||||
}
|
||||
|
@ -514,7 +514,7 @@ void key_functions_modbus(void)
|
|||
|
||||
case MOD_CONF_COMMAND:
|
||||
{
|
||||
window_display();
|
||||
config_window_update();
|
||||
current_operation = MODBUS_MASTER_CONFIG_MODIFY;
|
||||
key_config_update(current_operation);
|
||||
}
|
||||
|
@ -522,7 +522,7 @@ void key_functions_modbus(void)
|
|||
|
||||
case MOD_CONF_REGISTER_NUM:
|
||||
{
|
||||
window_display();
|
||||
config_window_update();
|
||||
current_operation = MODBUS_MASTER_CONFIG_MODIFY;
|
||||
key_config_update(current_operation);
|
||||
}
|
||||
|
@ -581,10 +581,9 @@ void key_functions_modbus(void)
|
|||
|
||||
window_trx_cursor = 0;
|
||||
window_trx_cursor_prv = 99;
|
||||
window_trx_check(window_trx_cursor, window_trx_cursor_prv);
|
||||
trx_window_num_check(window_trx_cursor, window_trx_cursor_prv);
|
||||
|
||||
memset(window_trx_num, 16, sizeof(window_trx_num));
|
||||
window_trx_init();
|
||||
trx_window_init();
|
||||
|
||||
current_operation = MODBUS_MASTER_TRX_MODIFY;
|
||||
key_config_update(current_operation);
|
||||
|
@ -662,7 +661,7 @@ void key_functions_modbus(void)
|
|||
case MODBUS_MASTER_TRX_MODIFY:
|
||||
{
|
||||
window_trx_focus = 1;
|
||||
window_trx_check(window_trx_cursor, window_trx_cursor_prv);
|
||||
trx_window_num_check(window_trx_cursor, window_trx_cursor_prv);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -733,12 +732,12 @@ void key_functions_modbus(void)
|
|||
case MOD_CONF_REGISTER_NUM:
|
||||
{
|
||||
lv_obj_add_flag(guider_ui.screen_modbus_config_window_config, LV_OBJ_FLAG_HIDDEN);
|
||||
window_num_check(99, window_cursor);
|
||||
window_cursor = 0;
|
||||
window_cursor_prv = 99;
|
||||
config_window_num_check(99, window_config_cursor);
|
||||
window_config_cursor = 0;
|
||||
window_config_cursor_prv = 99;
|
||||
|
||||
window2value();
|
||||
memset(window_num, 0, 4);
|
||||
config_window2value();
|
||||
memset(window_config_num, 0, 4);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -787,17 +786,22 @@ void key_functions_modbus(void)
|
|||
{
|
||||
if(window_trx_focus == 1)
|
||||
{
|
||||
//存在焦点的情况下,熄灭焦点
|
||||
window_trx_focus = 0;
|
||||
window_trx_check(window_trx_cursor, window_trx_cursor_prv);
|
||||
trx_window_num_check(window_trx_cursor, window_trx_cursor_prv);
|
||||
}
|
||||
else
|
||||
{
|
||||
//不存在焦点的情况下,关闭弹窗、熄灭游标、数值转换,返回trx界面
|
||||
lv_obj_add_flag(guider_ui.screen_modbus_trx_window_data, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
window_trx_check(99, window_trx_cursor);
|
||||
|
||||
trx_window_num_check(99, window_trx_cursor);
|
||||
window_trx_cursor = 0;
|
||||
window_trx_cursor_prv = 99;
|
||||
|
||||
//窗口内容转换为数值
|
||||
trx_window_num2val();
|
||||
|
||||
current_operation = MODBUS_MASTER_TRX;
|
||||
key_config_update(current_operation);
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ static char modbus_master_config_item_english[MODBUS_MASTER_CONFIG_ITEM_MAX][TEX
|
|||
|
||||
static char modbus_master_trx_item_chinese[MODBUS_MASTER_TRX_ITEM_MAX][TEXT_LENGTH_MAX] =
|
||||
{
|
||||
"数据",
|
||||
"(HEX)数据",
|
||||
"上一步",
|
||||
"设置",
|
||||
"发送"
|
||||
|
@ -224,7 +224,7 @@ static char modbus_master_trx_item_chinese[MODBUS_MASTER_TRX_ITEM_MAX][TEXT_LENG
|
|||
|
||||
static char modbus_master_trx_item_english[MODBUS_MASTER_TRX_ITEM_MAX][TEXT_LENGTH_MAX] =
|
||||
{
|
||||
"Data",
|
||||
"(HEX)Data",
|
||||
"Previous",
|
||||
"Set",
|
||||
"Send"
|
||||
|
|
|
@ -41,8 +41,7 @@ typedef struct
|
|||
uint16_t register_num; //线圈、寄存器数量
|
||||
uint16_t crc16; //MODBUS_CRC16校验码
|
||||
uint8_t byte_num; //需要写入的线圈、保持寄存器字节数
|
||||
uint8_t data_tx_value8[TX_DATA_MAX]; //需要写入的数值,8位
|
||||
uint16_t data_tx_value16[TX_DATA_MAX/2];//需要写入的数值,16位
|
||||
uint8_t data_tx_value[TX_DATA_MAX]; //需要写入的数值,8位
|
||||
uint8_t data_tx[TX_BUFF_MAX]; //存放完整的发送数据报
|
||||
uint8_t data_rx[RX_BUFF_MAX]; //存放完整的接收数据报
|
||||
uint8_t data_tx_len; //发送的数据报长度
|
||||
|
@ -53,7 +52,7 @@ typedef struct
|
|||
uint8_t rx_flag; //接收标志位
|
||||
uint8_t tx_flag; //发送标志位
|
||||
|
||||
char result_display[100]; //在显示屏上显示读取到的结果
|
||||
char result_display[200]; //在显示屏上显示读取到的结果
|
||||
}MODBUS_MASTER;
|
||||
|
||||
extern MODBUS_MASTER mod_master;
|
||||
|
|
|
@ -10,8 +10,7 @@ void modbus_rtu_master_init(void)
|
|||
mod_master.register_num = 0x0000;
|
||||
mod_master.crc16 = 0x0000;
|
||||
mod_master.byte_num = 0;
|
||||
memset(mod_master.data_tx_value8, 0, TX_DATA_MAX);
|
||||
memset(mod_master.data_tx_value16, 0, TX_DATA_MAX);
|
||||
memset(mod_master.data_tx_value, 0, TX_DATA_MAX);
|
||||
memset(mod_master.data_tx, 0, TX_BUFF_MAX);
|
||||
memset(mod_master.data_rx, 0, RX_BUFF_MAX);
|
||||
mod_master.data_tx_len = 0;
|
||||
|
@ -73,7 +72,7 @@ void modbus_rtu_master_load(void)
|
|||
{
|
||||
mod_master.data_tx[2] = (uint8_t)(mod_master.start_address >> 8);
|
||||
mod_master.data_tx[3] = (uint8_t)(mod_master.start_address & 0x00FF);
|
||||
mod_master.data_tx[4] = (mod_master.data_tx_value8[0] == 0xFF)?(0xFF):(0x00);
|
||||
mod_master.data_tx[4] = (mod_master.data_tx_value[0] == 0xFF)?(0xFF):(0x00);
|
||||
mod_master.data_tx[5] = 0x00;
|
||||
mod_master.crc16 = ModbusCRC16(mod_master.data_tx, 6);
|
||||
mod_master.data_tx[6] = (uint8_t)(mod_master.crc16 & 0x00FF);
|
||||
|
@ -88,8 +87,8 @@ void modbus_rtu_master_load(void)
|
|||
{
|
||||
mod_master.data_tx[2] = (uint8_t)(mod_master.start_address >> 8);
|
||||
mod_master.data_tx[3] = (uint8_t)(mod_master.start_address & 0x00FF);
|
||||
mod_master.data_tx[4] = (uint8_t)(mod_master.data_tx_value16[0] >> 8);
|
||||
mod_master.data_tx[5] = (uint8_t)(mod_master.data_tx_value16[0] & 0x00FF);
|
||||
mod_master.data_tx[4] = mod_master.data_tx_value[0];
|
||||
mod_master.data_tx[5] = mod_master.data_tx_value[1];
|
||||
mod_master.crc16 = ModbusCRC16(mod_master.data_tx, 6);
|
||||
mod_master.data_tx[6] = (uint8_t)(mod_master.crc16 & 0x00FF);
|
||||
mod_master.data_tx[7] = (uint8_t)(mod_master.crc16 >> 8);
|
||||
|
@ -127,7 +126,7 @@ void modbus_rtu_master_load(void)
|
|||
mod_master.data_tx[6] = mod_master.byte_num;
|
||||
for(uint8_t i = 1; i <= mod_master.byte_num; i++ )
|
||||
{
|
||||
mod_master.data_tx[6 + i] = mod_master.data_tx_value8[i - 1];
|
||||
mod_master.data_tx[6 + i] = mod_master.data_tx_value[i - 1];
|
||||
}
|
||||
mod_master.crc16 = ModbusCRC16(mod_master.data_tx, 7 + mod_master.byte_num);
|
||||
mod_master.data_tx[7 + mod_master.byte_num] = (uint8_t)(mod_master.crc16 & 0x00FF);
|
||||
|
@ -154,7 +153,7 @@ void modbus_rtu_master_load(void)
|
|||
mod_master.data_tx[6] = mod_master.byte_num;
|
||||
for(uint8_t i = 1; i <= mod_master.byte_num; i++ )
|
||||
{
|
||||
mod_master.data_tx[6 + i] = mod_master.data_tx_value16[ (i - 1)/2 ] >> ( 8*(i%2) );
|
||||
mod_master.data_tx[6 + i] = mod_master.data_tx_value[i - 1];
|
||||
}
|
||||
mod_master.crc16 = ModbusCRC16(mod_master.data_tx, 7 + mod_master.byte_num);
|
||||
mod_master.data_tx[7 + mod_master.byte_num] = (uint8_t)(mod_master.crc16 & 0x00FF);
|
||||
|
@ -251,7 +250,7 @@ void modbus_rtu_master_data_process(void)
|
|||
}
|
||||
|
||||
//数据解析
|
||||
sprintf(mod_master.result_display, "Address:0x%02x, Command:0x%02x, Data: ", mod_master.data_rx[0], mod_master.data_rx[1]);
|
||||
sprintf(mod_master.result_display, "Address:0x%02x Command:0x%02x Bytes:%02x Data: ", mod_master.data_rx[0], mod_master.data_rx[1], mod_master.data_rx[2]);
|
||||
char num2str[2];
|
||||
for(uint8_t i = 0; i < mod_master.data_rx[2]; i++)
|
||||
{
|
||||
|
@ -272,6 +271,13 @@ void modbus_rtu_master_data_process(void)
|
|||
}
|
||||
|
||||
//数据解析
|
||||
sprintf(mod_master.result_display, "Address:0x%02x Command:0x%02x Bytes:%02x Data: ", mod_master.data_rx[0], mod_master.data_rx[1], mod_master.data_rx[2]);
|
||||
char num2str[2];
|
||||
for(uint8_t i = 0; i < mod_master.data_rx[2]; i++)
|
||||
{
|
||||
sprintf(num2str, "%02x ", mod_master.data_rx[3 + i]);
|
||||
strcat(mod_master.result_display, num2str);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -286,6 +292,13 @@ void modbus_rtu_master_data_process(void)
|
|||
}
|
||||
|
||||
//数据解析
|
||||
sprintf(mod_master.result_display, "Address:0x%02x Command:0x%02x Bytes:%02x Data: ", mod_master.data_rx[0], mod_master.data_rx[1], mod_master.data_rx[2]);
|
||||
char num2str[2];
|
||||
for(uint8_t i = 0; i < mod_master.data_rx[2]; i++)
|
||||
{
|
||||
sprintf(num2str, "%02x ", mod_master.data_rx[3 + i]);
|
||||
strcat(mod_master.result_display, num2str);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -300,6 +313,13 @@ void modbus_rtu_master_data_process(void)
|
|||
}
|
||||
|
||||
//数据解析
|
||||
sprintf(mod_master.result_display, "Address:0x%02x Command:0x%02x Bytes:%02x Data: ", mod_master.data_rx[0], mod_master.data_rx[1], mod_master.data_rx[2]);
|
||||
char num2str[2];
|
||||
for(uint8_t i = 0; i < mod_master.data_rx[2]; i++)
|
||||
{
|
||||
sprintf(num2str, "%02x ", mod_master.data_rx[3 + i]);
|
||||
strcat(mod_master.result_display, num2str);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -314,6 +334,7 @@ void modbus_rtu_master_data_process(void)
|
|||
}
|
||||
|
||||
//数据解析
|
||||
sprintf(mod_master.result_display, "Address:0x%02x Command:0x%02x CoilAddress:0x%02x%02x Bits:0x%02x%02x", mod_master.data_rx[0], mod_master.data_rx[1], mod_master.data_rx[2], mod_master.data_rx[3], mod_master.data_rx[4], mod_master.data_rx[5]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -328,6 +349,7 @@ void modbus_rtu_master_data_process(void)
|
|||
}
|
||||
|
||||
//数据解析
|
||||
sprintf(mod_master.result_display, "Address:0x%02x Command:0x%02x RegAddress:0x%02x%02x Data:0x%02x%02x", mod_master.data_rx[0], mod_master.data_rx[1], mod_master.data_rx[2], mod_master.data_rx[3], mod_master.data_rx[4], mod_master.data_rx[5]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -342,6 +364,7 @@ void modbus_rtu_master_data_process(void)
|
|||
}
|
||||
|
||||
//数据解析
|
||||
sprintf(mod_master.result_display, "Address:0x%02x Command:0x%02x CoilAddress:0x%02x%02x Num:0x%02x%02x", mod_master.data_rx[0], mod_master.data_rx[1], mod_master.data_rx[2], mod_master.data_rx[3], mod_master.data_rx[4], mod_master.data_rx[5]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -356,6 +379,7 @@ void modbus_rtu_master_data_process(void)
|
|||
}
|
||||
|
||||
//数据解析
|
||||
sprintf(mod_master.result_display, "Address:0x%02x Command:0x%02x RegAddress:0x%02x%02x Num:0x%02x%02x", mod_master.data_rx[0], mod_master.data_rx[1], mod_master.data_rx[2], mod_master.data_rx[3], mod_master.data_rx[4], mod_master.data_rx[5]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ void setup_scr_screen_modbus_trx(lv_ui *ui)
|
|||
lv_label_set_text(ui->screen_modbus_trx_label_Rx, "(HEX)Rx:");
|
||||
lv_label_set_long_mode(ui->screen_modbus_trx_label_Rx, LV_LABEL_LONG_WRAP);
|
||||
lv_obj_set_pos(ui->screen_modbus_trx_label_Rx, 3, 150);
|
||||
lv_obj_set_size(ui->screen_modbus_trx_label_Rx, 90, 18);
|
||||
lv_obj_set_size(ui->screen_modbus_trx_label_Rx, 85, 18);
|
||||
|
||||
//Write style for screen_modbus_trx_label_Rx, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
|
||||
lv_obj_set_style_border_width(ui->screen_modbus_trx_label_Rx, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
|
@ -121,7 +121,7 @@ void setup_scr_screen_modbus_trx(lv_ui *ui)
|
|||
lv_obj_set_style_text_color(ui->screen_modbus_trx_label_Rx, lv_color_hex(0x000000), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_font(ui->screen_modbus_trx_label_Rx, &lv_font_SourceHanSerifSC_Regular_16, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_opa(ui->screen_modbus_trx_label_Rx, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_letter_space(ui->screen_modbus_trx_label_Rx, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_letter_space(ui->screen_modbus_trx_label_Rx, 1, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_line_space(ui->screen_modbus_trx_label_Rx, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_align(ui->screen_modbus_trx_label_Rx, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_opa(ui->screen_modbus_trx_label_Rx, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
|
@ -220,7 +220,7 @@ void setup_scr_screen_modbus_trx(lv_ui *ui)
|
|||
lv_label_set_text(ui->screen_modbus_trx_label_Tx, "(HEX)Tx:");
|
||||
lv_label_set_long_mode(ui->screen_modbus_trx_label_Tx, LV_LABEL_LONG_WRAP);
|
||||
lv_obj_set_pos(ui->screen_modbus_trx_label_Tx, 166, 3);
|
||||
lv_obj_set_size(ui->screen_modbus_trx_label_Tx, 90, 18);
|
||||
lv_obj_set_size(ui->screen_modbus_trx_label_Tx, 85, 18);
|
||||
|
||||
//Write style for screen_modbus_trx_label_Tx, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
|
||||
lv_obj_set_style_border_width(ui->screen_modbus_trx_label_Tx, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
|
@ -228,7 +228,7 @@ void setup_scr_screen_modbus_trx(lv_ui *ui)
|
|||
lv_obj_set_style_text_color(ui->screen_modbus_trx_label_Tx, lv_color_hex(0x000000), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_font(ui->screen_modbus_trx_label_Tx, &lv_font_SourceHanSerifSC_Regular_16, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_opa(ui->screen_modbus_trx_label_Tx, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_letter_space(ui->screen_modbus_trx_label_Tx, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_letter_space(ui->screen_modbus_trx_label_Tx, 1, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_line_space(ui->screen_modbus_trx_label_Tx, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_align(ui->screen_modbus_trx_label_Tx, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_opa(ui->screen_modbus_trx_label_Tx, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
|
@ -243,7 +243,7 @@ void setup_scr_screen_modbus_trx(lv_ui *ui)
|
|||
lv_label_set_text(ui->screen_modbus_trx_label_Data, "数据:");
|
||||
lv_label_set_long_mode(ui->screen_modbus_trx_label_Data, LV_LABEL_LONG_WRAP);
|
||||
lv_obj_set_pos(ui->screen_modbus_trx_label_Data, 3, 3);
|
||||
lv_obj_set_size(ui->screen_modbus_trx_label_Data, 60, 18);
|
||||
lv_obj_set_size(ui->screen_modbus_trx_label_Data, 95, 18);
|
||||
|
||||
//Write style for screen_modbus_trx_label_Data, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
|
||||
lv_obj_set_style_border_width(ui->screen_modbus_trx_label_Data, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
|
@ -251,7 +251,7 @@ void setup_scr_screen_modbus_trx(lv_ui *ui)
|
|||
lv_obj_set_style_text_color(ui->screen_modbus_trx_label_Data, lv_color_hex(0x000000), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_font(ui->screen_modbus_trx_label_Data, &lv_font_SourceHanSerifSC_Regular_16, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_opa(ui->screen_modbus_trx_label_Data, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_letter_space(ui->screen_modbus_trx_label_Data, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_letter_space(ui->screen_modbus_trx_label_Data, 1, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_line_space(ui->screen_modbus_trx_label_Data, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_align(ui->screen_modbus_trx_label_Data, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_opa(ui->screen_modbus_trx_label_Data, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
||||
|
|
|
@ -265,6 +265,11 @@
|
|||
<WinNumber>1</WinNumber>
|
||||
<ItemText>window_trx_cursor,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>22</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>window_trx_num</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<WatchWindow2>
|
||||
<Ww>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue