668 lines
22 KiB
C
668 lines
22 KiB
C
#include "app_screen_modbus.h"
|
||
|
||
lv_obj_t *window_trx_nums[32];
|
||
|
||
//modbus配置项的游标
|
||
MOD_CONF_ITEMS mod_mas_conf_cursor = MOD_CONF_SLAVE_ID;
|
||
MOD_CONF_ITEMS mod_mas_conf_cursor_prv = MOD_CONF_NONE;
|
||
uint8_t config_focus = 0;
|
||
|
||
//modbus收发界面的选项游标
|
||
MOD_TRX_ITEMS mod_mas_trx_cursor = MOD_TRX_PREVIOUS;
|
||
MOD_TRX_ITEMS mod_mas_trx_cursor_prv = MOD_TRX_NONE;
|
||
uint8_t trx_focus = 0;
|
||
|
||
void config_items_set_color(MOD_CONF_ITEMS cur, uint32_t color)
|
||
{
|
||
switch (cur)
|
||
{
|
||
case MOD_CONF_SLAVE_ID:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_value_device_addr, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case MOD_CONF_START_ADDRESS:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_value_start_addr, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case MOD_CONF_BYTES:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_value_bytes, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case MOD_CONF_TIMEOUT:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_value_timeout, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case MOD_CONF_COMMAND:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_value_cmd, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case MOD_CONF_REGISTER_NUM:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_value_register_num, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case MOD_CONF_CALIBRATION:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_value_calibration, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case MOD_CONF_NEXT:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_value_next, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
void config_items_check(MOD_CONF_ITEMS cur, MOD_CONF_ITEMS cur_prv)
|
||
{
|
||
uint32_t color = 0;
|
||
if(config_focus == 1)
|
||
{
|
||
color = COLOR_CONTENTS_FOCUSED;
|
||
}
|
||
else
|
||
{
|
||
color = COLOR_CONTENTS_CHECKED;
|
||
}
|
||
|
||
//点亮cur
|
||
config_items_set_color(cur, color);
|
||
|
||
//熄灭cur——prv
|
||
config_items_set_color(cur_prv, COLOR_ITEMS_UNCHECKED);
|
||
}
|
||
|
||
void window_num_check(uint8_t cur, uint8_t cur_prv)
|
||
{
|
||
switch (cur)
|
||
{
|
||
case 0:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_num_0, lv_color_hex(COLOR_CONTENTS_CHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 1:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_num_1, lv_color_hex(COLOR_CONTENTS_CHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 2:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_num_2, lv_color_hex(COLOR_CONTENTS_CHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 3:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_num_3, lv_color_hex(COLOR_CONTENTS_CHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
switch (cur_prv)
|
||
{
|
||
case 0:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_num_0, lv_color_hex(COLOR_CONTENTS_UNCHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 1:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_num_1, lv_color_hex(COLOR_CONTENTS_UNCHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 2:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_num_2, lv_color_hex(COLOR_CONTENTS_UNCHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 3:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_config_num_3, lv_color_hex(COLOR_CONTENTS_UNCHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
void window_num_set(uint8_t pos, uint8_t num)
|
||
{
|
||
char str_temp[8] = {0};
|
||
|
||
if( num < 16 )
|
||
{
|
||
sprintf(str_temp, "%x", num);
|
||
}
|
||
else if (num == 20)
|
||
{
|
||
strcpy(str_temp, "0");
|
||
}
|
||
else if (num == 21)
|
||
{
|
||
strcpy(str_temp, "x");
|
||
}
|
||
else
|
||
{
|
||
strcpy(str_temp, "-");
|
||
}
|
||
|
||
switch (pos)
|
||
{
|
||
case 0:
|
||
{
|
||
lv_label_set_text(guider_ui.screen_modbus_config_num_0, str_temp);
|
||
}
|
||
break;
|
||
|
||
case 1:
|
||
{
|
||
lv_label_set_text(guider_ui.screen_modbus_config_num_1, str_temp);
|
||
}
|
||
break;
|
||
|
||
case 2:
|
||
{
|
||
lv_label_set_text(guider_ui.screen_modbus_config_num_2, str_temp);
|
||
}
|
||
break;
|
||
|
||
case 3:
|
||
{
|
||
lv_label_set_text(guider_ui.screen_modbus_config_num_3, str_temp);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
void window_display(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;
|
||
for(uint8_t i = 0; i < 4; i++)
|
||
{
|
||
window_num_set(i, window_num[i]);
|
||
}
|
||
window_cursor = 2;
|
||
window_cursor_prv = 99;
|
||
window_num_check(window_cursor, window_cursor_prv);
|
||
|
||
lv_obj_clear_flag(guider_ui.screen_modbus_config_window_config, LV_OBJ_FLAG_HIDDEN);
|
||
}
|
||
break;
|
||
|
||
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 );
|
||
for(uint8_t i = 0; i < 4; i++)
|
||
{
|
||
window_num_set(i, window_num[i]);
|
||
}
|
||
window_cursor = 0;
|
||
window_cursor_prv = 99;
|
||
window_num_check(window_cursor, window_cursor_prv);
|
||
|
||
lv_obj_clear_flag(guider_ui.screen_modbus_config_window_config, LV_OBJ_FLAG_HIDDEN);
|
||
}
|
||
break;
|
||
|
||
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;
|
||
for(uint8_t i = 0; i < 4; i++)
|
||
{
|
||
window_num_set(i, window_num[i]);
|
||
}
|
||
window_cursor = 2;
|
||
window_cursor_prv = 99;
|
||
window_num_check(window_cursor, window_cursor_prv);
|
||
|
||
lv_obj_clear_flag(guider_ui.screen_modbus_config_window_config, LV_OBJ_FLAG_HIDDEN);
|
||
}
|
||
break;
|
||
|
||
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;
|
||
for(uint8_t i = 0; i < 4; i++)
|
||
{
|
||
window_num_set(i, window_num[i]);
|
||
}
|
||
window_cursor = 1;
|
||
window_cursor_prv = 99;
|
||
window_num_check(window_cursor, window_cursor_prv);
|
||
|
||
lv_obj_clear_flag(guider_ui.screen_modbus_config_window_config, LV_OBJ_FLAG_HIDDEN);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
void window2value(void)
|
||
{
|
||
char str_temp[16];
|
||
|
||
switch (mod_mas_conf_cursor)
|
||
{
|
||
case MOD_CONF_SLAVE_ID:
|
||
{
|
||
mod_master.target_id = window_num[2] & 0x0F;
|
||
mod_master.target_id <<= 4;
|
||
mod_master.target_id += window_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);
|
||
}
|
||
break;
|
||
|
||
case MOD_CONF_START_ADDRESS:
|
||
{
|
||
mod_master.start_address = window_num[0] & 0x0F;
|
||
mod_master.start_address <<= 4;
|
||
mod_master.start_address += window_num[1] & 0x0F;
|
||
mod_master.start_address <<= 4;
|
||
mod_master.start_address += window_num[2] & 0x0F;
|
||
mod_master.start_address <<= 4;
|
||
mod_master.start_address += window_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);
|
||
}
|
||
break;
|
||
|
||
case MOD_CONF_COMMAND:
|
||
{
|
||
mod_master.command_code= window_num[2];
|
||
mod_master.command_code <<= 4;
|
||
mod_master.command_code += window_num[3];
|
||
|
||
sprintf(str_temp, "0x%02x", mod_master.command_code);
|
||
lv_label_set_text(guider_ui.screen_modbus_config_value_cmd, str_temp);
|
||
}
|
||
break;
|
||
|
||
case MOD_CONF_REGISTER_NUM:
|
||
{
|
||
mod_master.register_num = window_num[1]*100 + window_num[2]*10 + window_num[3];
|
||
|
||
sprintf(str_temp, "%d", mod_master.register_num);
|
||
lv_label_set_text(guider_ui.screen_modbus_config_value_register_num, str_temp);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
void trx_items_set_color(MOD_TRX_ITEMS cur, uint32_t color)
|
||
{
|
||
switch (cur)
|
||
{
|
||
case MOD_TRX_DATA:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_value_Data, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case MOD_TRX_PREVIOUS:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_label_previous, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case MOD_TRX_SET:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_label_set, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case MOD_TRX_SEND:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_label_send, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
void trx_items_check(MOD_TRX_ITEMS cur, MOD_TRX_ITEMS cur_prv)
|
||
{
|
||
uint32_t color = 0;
|
||
if(trx_focus == 1)
|
||
{
|
||
color = COLOR_CONTENTS_FOCUSED;
|
||
}
|
||
else
|
||
{
|
||
color = COLOR_CONTENTS_CHECKED;
|
||
}
|
||
|
||
//点亮cur
|
||
trx_items_set_color(cur, color);
|
||
|
||
//熄灭cur——prv
|
||
trx_items_set_color(cur_prv, COLOR_ITEMS_UNCHECKED);
|
||
}
|
||
|
||
//打开trx弹窗后,初始化显示内容
|
||
uint8_t lv_obj2nums_init_flag = 0;
|
||
void window_trx_init(void)
|
||
{
|
||
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]循环会进入硬件错误中断
|
||
|
||
switch (cur)
|
||
{
|
||
case 0:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_00, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 1:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_01, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 2:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_02, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 3:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_03, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 4:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_04, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 5:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_05, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 6:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_06, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 7:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_07, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 8:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_10, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 9:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_11, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 10:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_12, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 11:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_13, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 12:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_14, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 13:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_15, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 14:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_16, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 15:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_17, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 16:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_20, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 17:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_21, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 18:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_22, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 19:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_23, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 20:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_24, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 21:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_25, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 22:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_26, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 23:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_27, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 24:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_30, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 25:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_31, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 26:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_32, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 27:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_33, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 28:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_34, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 29:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_35, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 30:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_36, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
case 31:
|
||
lv_obj_set_style_bg_color(guider_ui.screen_modbus_trx_num_37, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
void window_trx_check(uint8_t cur, uint8_t cur_prv)
|
||
{
|
||
if(window_trx_focus == 1)
|
||
{
|
||
set_trx_num_color(cur, COLOR_CONTENTS_FOCUSED);
|
||
}
|
||
else
|
||
{
|
||
set_trx_num_color(cur, COLOR_CONTENTS_CHECKED);
|
||
}
|
||
|
||
set_trx_num_color(cur_prv, COLOR_CONTENTS_UNCHECKED);
|
||
}
|
||
|
||
void scr_modbus_config_recover(void)
|
||
{
|
||
//标题
|
||
lv_label_set_text(guider_ui.screen_modbus_config_label_title, text_pack.modbus_master_title);
|
||
|
||
//左列名称
|
||
lv_label_set_text(guider_ui.screen_modbus_config_label_device_addr, text_pack.modbus_master_item[0]);
|
||
lv_label_set_text(guider_ui.screen_modbus_config_label_start_addr, text_pack.modbus_master_item[1]);
|
||
lv_label_set_text(guider_ui.screen_modbus_config_label_bytes, text_pack.modbus_master_item[2]);
|
||
lv_label_set_text(guider_ui.screen_modbus_config_label_timeout, text_pack.modbus_master_item[3]);
|
||
lv_label_set_text(guider_ui.screen_modbus_config_label_cmd, text_pack.modbus_master_item[4]);
|
||
lv_label_set_text(guider_ui.screen_modbus_config_label_register_num, text_pack.modbus_master_item[5]);
|
||
lv_label_set_text(guider_ui.screen_modbus_config_label_calibration, text_pack.modbus_master_item[6]);
|
||
lv_label_set_text(guider_ui.screen_modbus_config_label_next, text_pack.modbus_master_item[7]);
|
||
|
||
char str_temp[16];
|
||
//右列值
|
||
sprintf(str_temp, "0x%02x", mod_master.target_id);
|
||
lv_label_set_text(guider_ui.screen_modbus_config_value_device_addr, str_temp);
|
||
sprintf(str_temp, "0x%04x", mod_master.start_address);
|
||
lv_label_set_text(guider_ui.screen_modbus_config_value_start_addr, str_temp);
|
||
sprintf(str_temp, "%d", mod_master.byte_num);
|
||
lv_label_set_text(guider_ui.screen_modbus_config_value_bytes, str_temp);
|
||
sprintf(str_temp, "%d", mod_master.timeout);
|
||
lv_label_set_text(guider_ui.screen_modbus_config_value_timeout, str_temp);
|
||
sprintf(str_temp, "0x%02x", mod_master.command_code);
|
||
lv_label_set_text(guider_ui.screen_modbus_config_value_cmd, str_temp);
|
||
sprintf(str_temp, "%d", mod_master.register_num);
|
||
lv_label_set_text(guider_ui.screen_modbus_config_value_register_num, str_temp);
|
||
//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_prv = MOD_CONF_NONE;
|
||
config_items_check(mod_mas_conf_cursor, mod_mas_conf_cursor_prv);
|
||
}
|
||
|
||
void scr_modbus_trx_recover(void)
|
||
{
|
||
//根据当前语言,刷新标题
|
||
lv_label_set_text(guider_ui.screen_modbus_trx_label_Data, text_pack.modbus_master_trx_item[0]);
|
||
|
||
//清空数据、发送、接收框
|
||
lv_label_set_text(guider_ui.screen_modbus_trx_value_Data,"");
|
||
lv_label_set_text(guider_ui.screen_modbus_trx_value_Tx,"");
|
||
lv_label_set_text(guider_ui.screen_modbus_trx_value_Rx,"");
|
||
|
||
mod_mas_trx_cursor = MOD_TRX_PREVIOUS;
|
||
mod_mas_trx_cursor_prv = MOD_TRX_NONE;
|
||
trx_items_check(mod_mas_trx_cursor, mod_mas_trx_cursor_prv);
|
||
}
|
||
|
||
uint8_t trx_focus_cnt = 0;
|
||
void screen_modbus_trx_run(void)
|
||
{
|
||
//mobus收发界面,ok按下焦点后,亮一段时间后恢复原色
|
||
if(trx_focus)
|
||
{
|
||
trx_focus_cnt++;
|
||
if(trx_focus_cnt >= 2)
|
||
{
|
||
trx_focus_cnt = 0;
|
||
trx_focus = 0;
|
||
trx_items_check(mod_mas_trx_cursor, MOD_TRX_NONE);
|
||
}
|
||
}
|
||
}
|