sggt/App/APP_WU/Src/app_screen_setting_trans.c

231 lines
7.4 KiB
C

#include "app_screen_setting_trans.h"
uint8_t com_switch_cursor = 0;
uint8_t com_switch_cursor_prv = 99;
void set_communication_text(uint8_t con)
{
char str_temp[32] = {0};
switch (con)
{
case TEXT_HART:
{
if(tabdata.content_focus == 0)
{
if(tabdata.hart_enable)
{
lv_label_set_text(guider_ui.screen_setting_label_01, text_pack.item_2_com_val[0]);
}
else
{
lv_label_set_text(guider_ui.screen_setting_label_01, text_pack.item_2_com_val[1]);
}
}
else
{
if(tabdata.hart_enable)
{
sprintf(str_temp,"< %s >",text_pack.item_2_com_val[0]);
}
else
{
sprintf(str_temp,"< %s >",text_pack.item_2_com_val[1]);
}
lv_label_set_text(guider_ui.screen_setting_label_01, str_temp);
}
}
break;
case TEXT_BLE:
{
if(tabdata.content_focus == 0)
{
if(tabdata.bluetooth_enable)
{
lv_label_set_text(guider_ui.screen_setting_label_11, text_pack.item_2_com_val[0]);
}
else
{
lv_label_set_text(guider_ui.screen_setting_label_11, text_pack.item_2_com_val[1]);
}
}
else
{
if(tabdata.bluetooth_enable)
{
sprintf(str_temp,"< %s >",text_pack.item_2_com_val[0]);
}
else
{
sprintf(str_temp,"< %s >",text_pack.item_2_com_val[1]);
}
lv_label_set_text(guider_ui.screen_setting_label_11, str_temp);
}
}
break;
case TEXT_MODBUS:
{
if(tabdata.content_focus == 0)
{
if(tabdata.modbus_enable)
{
if(tabdata.modbus_type == SIG_SLAVE)
{
lv_label_set_text(guider_ui.screen_setting_label_21, text_pack.item_2_com_val[3]);
lv_label_set_text(guider_ui.screen_setting_label_31, "---");
}
else
{
lv_label_set_text(guider_ui.screen_setting_label_21, text_pack.item_2_com_val[2]);
lv_label_set_text(guider_ui.screen_setting_label_31, ">");
}
}
else
{
lv_label_set_text(guider_ui.screen_setting_label_21, text_pack.item_2_com_val[1]);
lv_label_set_text(guider_ui.screen_setting_label_31, "---");
}
}
else
{
if(tabdata.modbus_enable)
{
if(tabdata.modbus_type == SIG_SLAVE)
{
sprintf(str_temp,"< %s >", text_pack.item_2_com_val[3]);
lv_label_set_text(guider_ui.screen_setting_label_31, "---");
}
else
{
sprintf(str_temp,"< %s >", text_pack.item_2_com_val[2]);
lv_label_set_text(guider_ui.screen_setting_label_31, ">");
}
}
else
{
sprintf(str_temp,"< %s >", text_pack.item_2_com_val[1]);
lv_label_set_text(guider_ui.screen_setting_label_31, "---");
}
lv_label_set_text(guider_ui.screen_setting_label_21, str_temp);
}
}
break;
default:
break;
}
}
void communication_switch(void)
{
//启用所需组件
if( lv_obj_has_flag(guider_ui.screen_setting_label_00, LV_OBJ_FLAG_HIDDEN) ) { lv_obj_clear_flag(guider_ui.screen_setting_label_00, LV_OBJ_FLAG_HIDDEN); };
if( lv_obj_has_flag(guider_ui.screen_setting_label_01, LV_OBJ_FLAG_HIDDEN) ) { lv_obj_clear_flag(guider_ui.screen_setting_label_01, LV_OBJ_FLAG_HIDDEN); };
if( lv_obj_has_flag(guider_ui.screen_setting_label_10, LV_OBJ_FLAG_HIDDEN) ) { lv_obj_clear_flag(guider_ui.screen_setting_label_10, LV_OBJ_FLAG_HIDDEN); };
if( lv_obj_has_flag(guider_ui.screen_setting_label_11, LV_OBJ_FLAG_HIDDEN) ) { lv_obj_clear_flag(guider_ui.screen_setting_label_11, LV_OBJ_FLAG_HIDDEN); };
if( lv_obj_has_flag(guider_ui.screen_setting_label_20, LV_OBJ_FLAG_HIDDEN) ) { lv_obj_clear_flag(guider_ui.screen_setting_label_20, LV_OBJ_FLAG_HIDDEN); };
if( lv_obj_has_flag(guider_ui.screen_setting_label_21, LV_OBJ_FLAG_HIDDEN) ) { lv_obj_clear_flag(guider_ui.screen_setting_label_21, LV_OBJ_FLAG_HIDDEN); };
if( lv_obj_has_flag(guider_ui.screen_setting_label_30, LV_OBJ_FLAG_HIDDEN) ) { lv_obj_clear_flag(guider_ui.screen_setting_label_30, LV_OBJ_FLAG_HIDDEN); };
if( lv_obj_has_flag(guider_ui.screen_setting_label_31, LV_OBJ_FLAG_HIDDEN) ) { lv_obj_clear_flag(guider_ui.screen_setting_label_31, LV_OBJ_FLAG_HIDDEN); };
//隐藏多余组件
lv_obj_add_flag(guider_ui.screen_setting_label_40, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(guider_ui.screen_setting_label_41, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(guider_ui.screen_setting_label_50, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(guider_ui.screen_setting_label_51, LV_OBJ_FLAG_HIDDEN);
//显示左列文本
lv_label_set_text(guider_ui.screen_setting_label_00, text_pack.item_2_com[0]);
lv_label_set_text(guider_ui.screen_setting_label_10, text_pack.item_2_com[1]);
lv_label_set_text(guider_ui.screen_setting_label_20, text_pack.item_2_com[2]);
lv_label_set_text(guider_ui.screen_setting_label_30, text_pack.item_2_com[3]);
//根据当前使能状态显示右列文本
set_communication_text(TEXT_HART);
set_communication_text(TEXT_BLE);
set_communication_text(TEXT_MODBUS);
com_switch_cursor = 0;
com_switch_cursor_prv = 99;
setting_contents_check(com_switch_cursor, com_switch_cursor_prv);
}
void set_communication_modify(uint8_t con, int8_t step)
{
switch (con)
{
case TEXT_HART:
{
tabdata.hart_enable = !tabdata.hart_enable;
}
break;
case TEXT_BLE:
{
tabdata.bluetooth_enable = !tabdata.bluetooth_enable;
}
break;
case TEXT_MODBUS:
{
tabdata.modbus_enable += step;
if( ( 2 < tabdata.modbus_enable )&&(tabdata.modbus_enable < 200) ) tabdata.modbus_enable = 0;
if(tabdata.modbus_enable > 200) tabdata.modbus_enable = 2;
if(tabdata.modbus_enable == 2)
{
tabdata.modbus_type = SIG_MASTER;
}
else
{
tabdata.modbus_type = SIG_SLAVE;
}
}
break;
default:
break;
}
}
void key_functions_modbus(void)
{
if( key_pv.status == KEY_STATUS_DISABLE ) return;
switch (key_pv.tag)
{
case KEY_UP:
{}
break;
case KEY_DOWN:
{}
break;
case KEY_LEFT:
{}
break;
case KEY_RIGHT:
{}
break;
case KEY_OK:
{}
break;
case KEY_BACK:
{}
break;
default:
break;
}
}