#include "app_screen_modbus.h" //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 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); } 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]); 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_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); } } }