1470 lines
51 KiB
C
1470 lines
51 KiB
C
#include "app_screen_setting.h"
|
||
|
||
TABVIEW_DATA tabdata; //设置页面参数初始化
|
||
int32_t color_table[7] =
|
||
{
|
||
COLOR_BLUE_VALUE,
|
||
COLOR_DARK_BLUE_VALUE,
|
||
COLOR_YELLOW_VALUE,
|
||
COLOR_GREEN_VALUE,
|
||
COLOR_RED_VALUE,
|
||
COLOR_PURPLE_VALUE,
|
||
COLOR_BLACK_VALUE
|
||
};
|
||
|
||
//设置界面中,通讯选择的游标
|
||
uint8_t com_switch_cursor = 0;
|
||
uint8_t com_switch_cursor_prv = 99;
|
||
|
||
//串口中的数字,第0-3表示数字,第4为标志符号(0正,1负)
|
||
uint8_t setting_window_num[5] = {0};
|
||
|
||
//设置菜单数据初始化
|
||
void tab_data_init(void)
|
||
{
|
||
tabdata.item_cursor = ITEM_0; //选项卡的游标(焦点)
|
||
tabdata.item_cursor_prv = ITEM_0; //前一刻的选项卡游标
|
||
tabdata.item_page = 1; //当前页
|
||
tabdata.item_page_prv = 1; //前一页
|
||
tabdata.content_cursor = 0; //某一选项卡内部的游标
|
||
tabdata.content_cursor_prv = 99; //前一刻的~
|
||
tabdata.content_focus = 0; //默认无焦点
|
||
tabdata.current_content = CONTENT_EMPTY; //当前指向内容,枚举类型
|
||
|
||
//EEPROM部分
|
||
eeprom_item_data_init();
|
||
|
||
//ITEMS_0 选项卡0(注释项位于EERPOM读取)
|
||
tabdata.item0_page0_vunit = VOLTAGE_V; //电压单位默认为V
|
||
tabdata.item0_page1_TCtype = TC_K; //默认为K类型的热电偶
|
||
|
||
//ITEMS_1(部分内容位于EERPOM读取)
|
||
|
||
|
||
//ITEMS_2(部分内容位于EERPOM读取)
|
||
memset(tabdata.log_time, 0, sizeof(tabdata.log_time));
|
||
memset(tabdata.input_log_value, 0, sizeof(tabdata.input_log_value));
|
||
memset(tabdata.input_log_unit, 0, sizeof(tabdata.input_log_unit));
|
||
memset(tabdata.output_log_value, 0, sizeof(tabdata.output_log_value));
|
||
memset(tabdata.output_log_unit, 0, sizeof(tabdata.output_log_unit));
|
||
sprintf(tabdata.log_time[0], "00:00:00");
|
||
tabdata.input_log_unit[0] = menu_data.input_mode_type;
|
||
tabdata.output_log_unit[0] = menu_data.output_mode_type;
|
||
tabdata.hart_enable = 0; //HART默认使能状态
|
||
tabdata.bluetooth_enable = 0; //HART默认使能状态
|
||
tabdata.modbus_enable = 0; //HART默认使能状态
|
||
tabdata.modbus_type = SIG_SLAVE; //SIG默认作为从设备
|
||
tabdata.modbus_master_send_flag = 0; //触发发送后置1,发送完成后置0
|
||
|
||
//ITEMS_3(部分内容位于EERPOM读取)
|
||
tabdata.item3_page0_lightflag = 0; //照明状态标志,0熄灭,1开启
|
||
LIGHT_OFF;
|
||
tabdata.item3_page0_saveflag = 0;
|
||
tabdata.item3_page0_resetflag = 0;
|
||
|
||
HoldReg[HOLD_ADDR_SAMPLE_INTERVAL] = tabdata.item1_page0_sample_interval;
|
||
HoldReg[HOLD_ADDR_PLOT_COUNTS] = 0x00FF & tabdata.item1_page0_plot_num;
|
||
HoldReg[HOLD_ADDR_INPUT_COLOR] = 0x00FF & (uint8_t)tabdata.item1_page0_color_input;
|
||
HoldReg[HOLD_ADDR_OUTPUT_COLOR] = 0x00FF & (uint8_t)tabdata.item1_page0_color_output;
|
||
HoldReg[HOLD_ADDR_LANGUAGE] = 0x00FF & (uint8_t)tabdata.item3_page0_language;
|
||
}
|
||
|
||
//选项卡EEPROM部分数据初始化
|
||
void eeprom_item_data_init(void)
|
||
{
|
||
if(tabdata.item3_page0_resetflag != 1)
|
||
{
|
||
//判断eeprom内是否存在数据
|
||
if(eeprom_device_check() == 1)
|
||
{
|
||
eeprom_dataread();
|
||
}
|
||
else
|
||
{
|
||
//针对不存在数据的情况,在eeprom_device_check()中已经进行了处理
|
||
return;
|
||
}
|
||
}
|
||
|
||
//读取过程中出现过错误,或者触发复位
|
||
if( (system_sts.eeprom_read_error == 1)||(tabdata.item3_page0_resetflag == 1) )
|
||
{
|
||
tabdata.item0_page0_vup[0] = VOL[0].up; //电压V上限
|
||
tabdata.item0_page0_vlow[0] = VOL[0].low; //电压V下限
|
||
tabdata.item0_page0_vup[1] = VOL[1].up; //电压mV上限
|
||
tabdata.item0_page0_vlow[1] = VOL[1].low; //电压mV下限
|
||
tabdata.item0_page0_cup = CUR.up; //电流上限
|
||
tabdata.item0_page0_clow = CUR.low; //电流下限
|
||
tabdata.item0_page0_rup = RES.up; //电阻上限
|
||
tabdata.item0_page1_rlow = RES.low; //电阻下限
|
||
tabdata.item0_page1_fup = FRE.up; //频率上限
|
||
tabdata.item0_page1_flow = FRE.low; //频率下限
|
||
tabdata.item0_page1_TCup[0] = TC[0].up; //TCK上限
|
||
tabdata.item0_page1_TClow[0] = TC[0].low; //TCK下限
|
||
tabdata.item0_page1_TCup[1] = TC[1].up; //TCS上限
|
||
tabdata.item0_page1_TClow[1] = TC[1].low; //TCS下限
|
||
tabdata.item0_page1_TCup[2] = TC[2].up; //TCN上限
|
||
tabdata.item0_page1_TClow[2] = TC[2].low; //TCN下限
|
||
tabdata.item0_page1_TCup[3] = TC[3].up; //TCB上限
|
||
tabdata.item0_page1_TClow[3] = TC[3].low; //TCB下限
|
||
tabdata.item0_page1_TCup[4] = TC[4].up; //TCE上限
|
||
tabdata.item0_page1_TClow[4] = TC[4].low; //TCE下限
|
||
tabdata.item0_page1_TCup[5] = TC[5].up; //TCJ上限
|
||
tabdata.item0_page1_TClow[5] = TC[5].low; //TCJ下限
|
||
tabdata.item0_page1_TCup[6] = TC[6].up; //TCR上限
|
||
tabdata.item0_page1_TClow[6] = TC[6].low; //TCR下限
|
||
tabdata.item0_page1_TCup[7] = TC[7].up; //TCT上限
|
||
tabdata.item0_page1_TClow[7] = TC[7].low; //TCT下限
|
||
tabdata.item0_page2_RTDup = RTD.up; //RTD上限
|
||
tabdata.item0_page2_RTDlow = RTD.low; //RTD下限
|
||
tabdata.item1_page0_sample_interval = 1500; //采样间隔
|
||
tabdata.item1_page0_plot_num = 5; //描点数量
|
||
tabdata.item1_page0_color_input = COLOR_YELLOW; //输入曲线颜色
|
||
tabdata.item1_page0_color_output = COLOR_BLUE; //输出曲线颜色
|
||
tabdata.item3_page0_language = MENU_SIMPLYFY_CHINESE; //语言选择
|
||
|
||
//针对复位的情况追加进行保存
|
||
if(tabdata.item3_page0_resetflag == 1)
|
||
{
|
||
//eeprom_datasave();
|
||
eeprom_datasave_changed();
|
||
}
|
||
}
|
||
}
|
||
|
||
void setting_items_check(ITEMS cursor, ITEMS cursor_prv)
|
||
{
|
||
tabdata.item_page = 1;
|
||
|
||
//操作选项卡
|
||
switch (cursor) //点亮选项卡,刷新当前选项卡内容至第1页
|
||
{
|
||
case ITEM_0:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_s0, lv_color_hex(COLOR_ITEMS_CHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
setting_items_page(ITEM_0, 1);
|
||
}
|
||
break;
|
||
|
||
case ITEM_1:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_s1, lv_color_hex(COLOR_ITEMS_CHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
setting_items_page(ITEM_1, 1);
|
||
}
|
||
break;
|
||
|
||
case ITEM_2:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_s2, lv_color_hex(COLOR_ITEMS_CHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
setting_items_page(ITEM_2, 1);
|
||
}
|
||
break;
|
||
|
||
case ITEM_3:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_s3, lv_color_hex(COLOR_ITEMS_CHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
setting_items_page(ITEM_3, 1);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
switch (cursor_prv) //熄灭前一时刻选项卡,并隐藏选项卡内容(已在 setting_items_page 中实现)
|
||
{
|
||
case ITEM_0:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_s0, lv_color_hex(COLOR_ITEMS_UNCHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case ITEM_1:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_s1, lv_color_hex(COLOR_ITEMS_UNCHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case ITEM_2:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_s2, lv_color_hex(COLOR_ITEMS_UNCHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case ITEM_3:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_s3, lv_color_hex(COLOR_ITEMS_UNCHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
//当前选项卡内容翻页:隐藏当前页,显示目标页page
|
||
void setting_items_page(ITEMS ite, uint8_t page)
|
||
{
|
||
//特殊处理,避免其他选项卡也被染上颜色
|
||
if(ite != ITEM_1)
|
||
{
|
||
set_obj_color(guider_ui.screen_setting_label_21, 6);
|
||
set_obj_color(guider_ui.screen_setting_label_31, 6);
|
||
}
|
||
|
||
switch (ite)
|
||
{
|
||
case ITEM_0:
|
||
{
|
||
//启用所需组件
|
||
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); };
|
||
if( lv_obj_has_flag(guider_ui.screen_setting_label_40, LV_OBJ_FLAG_HIDDEN) ) { lv_obj_clear_flag(guider_ui.screen_setting_label_40, LV_OBJ_FLAG_HIDDEN); };
|
||
if( lv_obj_has_flag(guider_ui.screen_setting_label_41, LV_OBJ_FLAG_HIDDEN) ) { lv_obj_clear_flag(guider_ui.screen_setting_label_41, LV_OBJ_FLAG_HIDDEN); };
|
||
if( lv_obj_has_flag(guider_ui.screen_setting_label_50, LV_OBJ_FLAG_HIDDEN) ) { lv_obj_clear_flag(guider_ui.screen_setting_label_50, LV_OBJ_FLAG_HIDDEN); };
|
||
if( lv_obj_has_flag(guider_ui.screen_setting_label_51, LV_OBJ_FLAG_HIDDEN) ) { lv_obj_clear_flag(guider_ui.screen_setting_label_51, LV_OBJ_FLAG_HIDDEN); };
|
||
|
||
//显示目标页
|
||
switch (page)
|
||
{
|
||
case 1:
|
||
{
|
||
lv_label_set_text(guider_ui.screen_setting_label_00, text_pack.item_0[0]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_10, text_pack.item_0[1]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_20, text_pack.item_0[2]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_30, text_pack.item_0[3]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_40, text_pack.item_0[4]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_50, text_pack.item_0[5]);
|
||
|
||
set_item0_text(VOL_UNIT_SET);
|
||
set_item0_text(VOL_UP_SET);
|
||
set_item0_text(VOL_LOW_SET);
|
||
set_item0_text(CURRENT_UP_SET);
|
||
set_item0_text(CURRENT_LOW_SET);
|
||
set_item0_text(RES_UP_SET);
|
||
}
|
||
break;
|
||
|
||
case 2:
|
||
{
|
||
lv_label_set_text(guider_ui.screen_setting_label_00, text_pack.item_0[6]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_10, text_pack.item_0[7]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_20, text_pack.item_0[8]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_30, text_pack.item_0[9]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_40, text_pack.item_0[10]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_50, text_pack.item_0[11]);
|
||
|
||
set_item0_text(TC_LOW_SET);
|
||
set_item0_text(TC_UP_SET);
|
||
set_item0_text(TC_TYPE_SET);
|
||
set_item0_text(FRE_LOW_SET);
|
||
set_item0_text(FRE_UP_SET);
|
||
set_item0_text(RES_LOW_SET);
|
||
}
|
||
break;
|
||
|
||
case 3:
|
||
{
|
||
lv_label_set_text(guider_ui.screen_setting_label_00, text_pack.item_0[12]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_10, text_pack.item_0[13]);
|
||
|
||
set_item0_text(RTD_UP_SET);
|
||
set_item0_text(RTD_LOW_SET);
|
||
|
||
//隐藏多余组件
|
||
lv_obj_add_flag(guider_ui.screen_setting_label_20, LV_OBJ_FLAG_HIDDEN);
|
||
lv_obj_add_flag(guider_ui.screen_setting_label_21, LV_OBJ_FLAG_HIDDEN);
|
||
lv_obj_add_flag(guider_ui.screen_setting_label_30, LV_OBJ_FLAG_HIDDEN);
|
||
lv_obj_add_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);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
//更新页码
|
||
set_item0_text(PAGE_PV_ITEM_0);
|
||
}
|
||
break;
|
||
|
||
case ITEM_1:
|
||
{
|
||
//启用所需组件
|
||
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); };
|
||
|
||
//显示目标页
|
||
switch (page)
|
||
{
|
||
case 1:
|
||
{
|
||
lv_label_set_text(guider_ui.screen_setting_label_00, text_pack.item_1[0]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_10, text_pack.item_1[1]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_20, text_pack.item_1[2]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_30, text_pack.item_1[3]);
|
||
|
||
set_item1_text(SAMPLE_INTERVAL);
|
||
set_item1_text(PLOT_NUM);
|
||
set_item1_text(INPUT_COLOR);
|
||
set_item1_text(OUTPUT_COLOR);
|
||
|
||
//隐藏多余组件
|
||
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);
|
||
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
//更新页码
|
||
set_item1_text(PAGE_PV_ITEM_1);
|
||
}
|
||
break;
|
||
|
||
case ITEM_2:
|
||
{
|
||
//启用所需组件
|
||
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); };
|
||
|
||
//显示目标页
|
||
switch (page)
|
||
{
|
||
case 1:
|
||
{
|
||
lv_label_set_text(guider_ui.screen_setting_label_00, text_pack.item_2[0]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_10, text_pack.item_2[1]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_20, text_pack.item_2[2]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_30, text_pack.item_2[3]);
|
||
|
||
set_item2_text(INPUT_LOG);
|
||
set_item2_text(OUTPUT_LOG);
|
||
set_item2_text(COMMUNICATION);
|
||
set_item2_text(PROGRAM_OUTPUT);
|
||
|
||
//隐藏多余组件
|
||
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);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
//更新页码
|
||
set_item2_text(PAGE_PV_ITEM_2);
|
||
}
|
||
break;
|
||
|
||
case ITEM_3:
|
||
{
|
||
//启用所需组件
|
||
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); };
|
||
|
||
//显示目标页
|
||
switch (page)
|
||
{
|
||
case 1:
|
||
{
|
||
lv_label_set_text(guider_ui.screen_setting_label_00, text_pack.item_3[0]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_10, text_pack.item_3[1]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_20, text_pack.item_3[2]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_30, text_pack.item_3[3]);
|
||
|
||
set_item3_text(LIGHT_STATUS);
|
||
set_item3_text(LANGUAGE_SELECT);
|
||
set_item3_text(DATA_SAVE);
|
||
set_item3_text(DATA_RESET);
|
||
|
||
//隐藏多余组件
|
||
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);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
//更新页码
|
||
set_item3_text(PAGE_PV_ITEM_3);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
//设置界面选项卡内部内容选中:点亮cursor;熄灭cursor_prv;焦点focus
|
||
void setting_contents_check(uint8_t cursor, uint8_t cursor_prv)
|
||
{
|
||
//根据焦点与否切换点亮时的颜色
|
||
uint32_t color = 0;
|
||
if(tabdata.content_focus)
|
||
{
|
||
color = COLOR_CONTENTS_FOCUSED;
|
||
}
|
||
else
|
||
{
|
||
color = COLOR_CONTENTS_CHECKED;
|
||
}
|
||
|
||
//点亮cursor
|
||
set_contents_color(cursor, color);
|
||
|
||
//熄灭cursor_prv
|
||
color = COLOR_CONTENTS_UNCHECKED;
|
||
set_contents_color(cursor_prv, color);
|
||
|
||
}
|
||
|
||
//设置界面选项卡内部内容选中之后,修改内容,修改第ite个选项卡的第con个内容
|
||
void setting_contents_modify(ITEMS ite, ITEM_CONTENTS con, int8_t step)
|
||
{
|
||
//选中某一选项卡后,对选项卡内部的内容进行选择
|
||
switch (ite)
|
||
{
|
||
case ITEM_0:
|
||
{
|
||
set_item0_value(con, step);
|
||
set_item0_text(con);
|
||
|
||
if(tabdata.item3_page0_saveflag == 2) tabdata.item3_page0_saveflag = 0;
|
||
if(tabdata.item3_page0_resetflag == 2) tabdata.item3_page0_resetflag = 0;
|
||
}
|
||
break;
|
||
|
||
case ITEM_1:
|
||
{
|
||
set_item1_value(con, step);
|
||
set_item1_text(con);
|
||
|
||
if(tabdata.item3_page0_saveflag == 2) tabdata.item3_page0_saveflag = 0;
|
||
if(tabdata.item3_page0_resetflag == 2) tabdata.item3_page0_resetflag = 0;
|
||
}
|
||
break;
|
||
|
||
case ITEM_2:
|
||
{
|
||
set_item2_value(con, step);
|
||
set_item2_text(con);
|
||
}
|
||
break;
|
||
|
||
case ITEM_3:
|
||
{
|
||
set_item3_value(con, step);
|
||
set_item3_text(con);
|
||
|
||
//切换语言后,更新本页的其他文本
|
||
if(con == LANGUAGE_SELECT)
|
||
{
|
||
tabdata.content_focus = 0;
|
||
setting_items_page(ITEM_3, 1);
|
||
|
||
tabdata.content_focus = 1;
|
||
set_item3_text(con);
|
||
}
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
//设置修改项的底色,表示选中和焦点
|
||
void set_contents_color(uint8_t cursor, uint32_t color)
|
||
{
|
||
switch (cursor)
|
||
{
|
||
case 0:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_01, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 1:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_11, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 2:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_21, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 3:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_31, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 4:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_41, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 5:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_51, lv_color_hex(color), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
//刷新标题和选项卡文本
|
||
void title_item_refresh(void)
|
||
{
|
||
lv_label_set_text(guider_ui.screen_setting_label_title, text_pack.title);
|
||
|
||
lv_label_set_text(guider_ui.screen_setting_label_s0, text_pack.items[0]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_s1, text_pack.items[1]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_s2, text_pack.items[2]);
|
||
lv_label_set_text(guider_ui.screen_setting_label_s3, text_pack.items[3]);
|
||
}
|
||
|
||
void scr_setting_recover(void)
|
||
{
|
||
//当前操作切换至“选项卡选择”,按键配置同步更新
|
||
current_operation = SET_ITEM_CHOOSE;
|
||
key_config_update(current_operation);
|
||
|
||
//在这里恢复选项卡0第1页的显示内容
|
||
tabdata.item_cursor = ITEM_0;
|
||
tabdata.item_cursor_prv = ITEM_NONE;
|
||
setting_items_check(tabdata.item_cursor, tabdata.item_cursor_prv);
|
||
|
||
setting_laguage_switch(tabdata.item3_page0_language);
|
||
title_item_refresh();
|
||
|
||
tabdata.item_page = 1;
|
||
setting_items_page(ITEM_0 ,tabdata.item_page);
|
||
|
||
key = 0;
|
||
key_char2struct();
|
||
}
|
||
|
||
void scr_setting_run(void) //详细设置界面
|
||
{
|
||
//处理保存事件
|
||
deal_data_save();
|
||
|
||
//处理复位事件
|
||
deal_data_reset();
|
||
}
|
||
|
||
//执行保存功能
|
||
uint8_t save_step = 0;
|
||
void deal_data_save(void)
|
||
{
|
||
if(tabdata.item3_page0_saveflag == 1)
|
||
{
|
||
//D2位置1
|
||
//CoilState[0] |= 0x04;
|
||
set_coil_val(COIL_ADDR_CONFIG_SAVE, 1);
|
||
|
||
if(save_step == 0)
|
||
{
|
||
save_step = 1;
|
||
|
||
//执行保存
|
||
//eeprom_datasave();
|
||
eeprom_datasave_changed();
|
||
|
||
//关闭所有按键
|
||
key_config(KEY_ALL, KEY_STATUS_DISABLE);
|
||
}
|
||
else
|
||
{
|
||
save_cnt++;
|
||
if(save_cnt > 5)
|
||
{
|
||
save_cnt = 0;
|
||
|
||
if(system_sts.eeprom_write_error == 0)
|
||
{
|
||
//未出错,保存完成
|
||
tabdata.item3_page0_saveflag = 2;
|
||
}
|
||
else
|
||
{
|
||
//出现过错误,未保存
|
||
tabdata.item3_page0_saveflag = 0;
|
||
}
|
||
|
||
setting_items_check(ITEM_NONE, tabdata.item_cursor);
|
||
tabdata.item_cursor = ITEM_3;
|
||
setting_items_check(tabdata.item_cursor, ITEM_NONE);
|
||
|
||
//使能所有按键
|
||
key_config(KEY_ALL, KEY_STATUS_ENABLE);
|
||
|
||
save_step = 0;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//D2位置0
|
||
//CoilState[0] &= 0xFB;
|
||
set_coil_val(COIL_ADDR_CONFIG_SAVE, 0);
|
||
}
|
||
}
|
||
|
||
uint8_t reset_step = 0;
|
||
//执行复位功能
|
||
void deal_data_reset(void)
|
||
{
|
||
if(tabdata.item3_page0_resetflag == 1)
|
||
{
|
||
//D3位置1
|
||
//CoilState[0] |= 0x08;
|
||
set_coil_val(COIL_ADDR_CONFIG_RESET, 1);
|
||
|
||
if(reset_step == 0)
|
||
{
|
||
reset_step = 1;
|
||
|
||
//执行复位
|
||
eeprom_item_data_init();
|
||
tabdata.item3_page0_lightflag = 0; //照明状态标志,0熄灭,1开启
|
||
LIGHT_OFF;
|
||
tabdata.item0_page0_vunit = VOLTAGE_V; //电压单位
|
||
tabdata.item0_page1_TCtype = TC_K; //默认为K类型的热电偶
|
||
|
||
//关闭所有按键
|
||
key_config(KEY_ALL, KEY_STATUS_DISABLE);
|
||
}
|
||
else
|
||
{
|
||
reset_cnt++;
|
||
if(reset_cnt > 5)
|
||
{
|
||
reset_cnt = 0;
|
||
tabdata.item3_page0_resetflag = 2; //已复位
|
||
tabdata.item3_page0_saveflag = 0; //保存状态更改为“未保存”
|
||
|
||
//复位后语言可能发生改变,因此刷新选项卡与标题
|
||
setting_laguage_switch(tabdata.item3_page0_language);
|
||
title_item_refresh();
|
||
|
||
//通过modbus触发时,需要刷新一下选项卡的内容
|
||
setting_items_check(ITEM_NONE, tabdata.item_cursor);
|
||
tabdata.item_cursor = ITEM_3;
|
||
setting_items_check(tabdata.item_cursor, ITEM_NONE);
|
||
|
||
//使能所有按键
|
||
key_config(KEY_ALL, KEY_STATUS_ENABLE);
|
||
|
||
reset_step = 0;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//D3位置0
|
||
//CoilState[0] &= 0xF7;
|
||
set_coil_val(COIL_ADDR_CONFIG_RESET, 0);
|
||
}
|
||
}
|
||
|
||
//内容游标 uint8_t -> enum
|
||
ITEM_CONTENTS content_cur_char2enum(ITEMS ite, uint8_t cur_uint8)
|
||
{
|
||
ITEM_CONTENTS result = CONTENT_EMPTY;
|
||
uint8_t cur_temp = 0;
|
||
|
||
cur_temp = cur_uint8 + (tabdata.item_page - 1)*6;
|
||
|
||
switch (ite)
|
||
{
|
||
case ITEM_0:
|
||
{
|
||
result = (ITEM_CONTENTS)cur_temp;
|
||
}
|
||
break;
|
||
|
||
case ITEM_1:
|
||
{
|
||
//head
|
||
cur_temp += (uint8_t)SAMPLE_INTERVAL;
|
||
|
||
result = (ITEM_CONTENTS)cur_temp;
|
||
}
|
||
break;
|
||
|
||
case ITEM_2:
|
||
{
|
||
//head
|
||
cur_temp += (uint8_t)INPUT_LOG;
|
||
|
||
result = (ITEM_CONTENTS)cur_temp;
|
||
}
|
||
break;
|
||
|
||
case ITEM_3:
|
||
{
|
||
//head
|
||
cur_temp += (uint8_t)LIGHT_STATUS;
|
||
|
||
result = (ITEM_CONTENTS)cur_temp;
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
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_select(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;
|
||
|
||
//通讯方式互斥
|
||
if(tabdata.hart_enable)
|
||
{
|
||
tabdata.bluetooth_enable = 0;
|
||
tabdata.modbus_enable = 0;
|
||
|
||
tabdata.content_focus = 0;
|
||
set_communication_text(TEXT_BLE);
|
||
set_communication_text(TEXT_MODBUS);
|
||
tabdata.content_focus = 1;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case TEXT_BLE:
|
||
{
|
||
tabdata.bluetooth_enable = !tabdata.bluetooth_enable;
|
||
|
||
//通讯方式互斥
|
||
if(tabdata.bluetooth_enable)
|
||
{
|
||
tabdata.hart_enable = 0;
|
||
tabdata.modbus_enable = 0;
|
||
|
||
tabdata.content_focus = 0;
|
||
set_communication_text(TEXT_HART);
|
||
set_communication_text(TEXT_MODBUS);
|
||
tabdata.content_focus = 1;
|
||
}
|
||
}
|
||
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;
|
||
}
|
||
|
||
//通讯方式互斥
|
||
if(tabdata.modbus_enable)
|
||
{
|
||
tabdata.hart_enable = 0;
|
||
tabdata.bluetooth_enable = 0;
|
||
|
||
tabdata.content_focus = 0;
|
||
set_communication_text(TEXT_HART);
|
||
set_communication_text(TEXT_BLE);
|
||
tabdata.content_focus = 1;
|
||
}
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
void setting_val2window(int16_t val)
|
||
{
|
||
//符号位
|
||
if( val < 0 )
|
||
{
|
||
lv_label_set_text(guider_ui.screen_setting_num_sign, "-");
|
||
val *= -1;
|
||
setting_window_num[4] = 1;
|
||
}
|
||
else
|
||
{
|
||
lv_label_set_text(guider_ui.screen_setting_num_sign, "+");
|
||
setting_window_num[4] = 0;
|
||
}
|
||
|
||
char str_temp[8] = {0};
|
||
|
||
setting_window_num[0] = (uint8_t)( val/1000 );
|
||
sprintf(str_temp, "%d", setting_window_num[0]);
|
||
lv_label_set_text(guider_ui.screen_setting_num_0, str_temp);
|
||
|
||
setting_window_num[1] = (uint8_t)( ( val/100 )%10 );
|
||
sprintf(str_temp, "%d", setting_window_num[1]);
|
||
lv_label_set_text(guider_ui.screen_setting_num_1, str_temp);
|
||
|
||
setting_window_num[2] = (uint8_t)( ( val/10 )%10 );
|
||
sprintf(str_temp, "%d", setting_window_num[2]);
|
||
lv_label_set_text(guider_ui.screen_setting_num_2, str_temp);
|
||
|
||
setting_window_num[3] = (uint8_t)( val%10 );
|
||
sprintf(str_temp, "%d", setting_window_num[3]);
|
||
lv_label_set_text(guider_ui.screen_setting_num_3, str_temp);
|
||
}
|
||
|
||
void setting_window2val(void)
|
||
{
|
||
int16_t val_win = 0;
|
||
|
||
val_win = setting_window_num[0]*1000 + setting_window_num[1]*100 + setting_window_num[2]*10 + setting_window_num[3];
|
||
if( setting_window_num[4] == 1 ) val_win *= -1;
|
||
|
||
switch (tabdata.current_content)
|
||
{
|
||
case VOL_UP_SET:
|
||
{
|
||
//既要保证不超出最大上限,又要保证不低于当前的下限
|
||
if(tabdata.item0_page0_vunit != VOLTAGE_MV) return;
|
||
|
||
if( val_win <= tabdata.item0_page0_vlow[1] )
|
||
{
|
||
tabdata.item0_page0_vup[1] = tabdata.item0_page0_vlow[1];
|
||
}
|
||
else if( val_win >= VOL[1].up )
|
||
{
|
||
tabdata.item0_page0_vup[1] = VOL[1].up;
|
||
}
|
||
else
|
||
{
|
||
tabdata.item0_page0_vup[1] = val_win;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case VOL_LOW_SET:
|
||
{
|
||
//既要保证不低于最小下限,又要保证不超过当前的上限
|
||
if(tabdata.item0_page0_vunit != VOLTAGE_MV) return;
|
||
|
||
if( val_win <= VOL[1].low )
|
||
{
|
||
tabdata.item0_page0_vlow[1] = VOL[1].low;
|
||
}
|
||
else if( val_win >= tabdata.item0_page0_vup[1] )
|
||
{
|
||
tabdata.item0_page0_vlow[1] = tabdata.item0_page0_vup[1];
|
||
}
|
||
else
|
||
{
|
||
tabdata.item0_page0_vlow[1] = val_win;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case RES_UP_SET:
|
||
{
|
||
//既要保证不超出最大上限,又要保证不低于当前的下限
|
||
if( val_win <= tabdata.item0_page1_rlow)
|
||
{
|
||
tabdata.item0_page0_rup = tabdata.item0_page1_rlow;
|
||
}
|
||
else if( val_win >= RES.up )
|
||
{
|
||
tabdata.item0_page0_rup = RES.up;
|
||
}
|
||
else
|
||
{
|
||
tabdata.item0_page0_rup = val_win;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case RES_LOW_SET:
|
||
{
|
||
//既要保证不低于最小下限,又要保证不超过当前的上限
|
||
if( val_win <= RES.low )
|
||
{
|
||
tabdata.item0_page1_rlow = RES.low;
|
||
}
|
||
else if( val_win >= tabdata.item0_page0_rup )
|
||
{
|
||
tabdata.item0_page1_rlow = tabdata.item0_page0_rup;
|
||
}
|
||
else
|
||
{
|
||
tabdata.item0_page1_rlow = val_win;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case FRE_UP_SET:
|
||
{
|
||
//既要保证不超出最大上限,又要保证不低于当前的下限
|
||
if( val_win <= tabdata.item0_page1_flow )
|
||
{
|
||
tabdata.item0_page1_fup = tabdata.item0_page1_flow;
|
||
}
|
||
else if( val_win >= FRE.up )
|
||
{
|
||
tabdata.item0_page1_fup = FRE.up;
|
||
}
|
||
else
|
||
{
|
||
tabdata.item0_page1_fup = (uint8_t)val_win;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case FRE_LOW_SET:
|
||
{
|
||
//既要保证不低于最小下限,又要保证不超过当前的上限
|
||
if( val_win <= FRE.low )
|
||
{
|
||
tabdata.item0_page1_flow = FRE.low;
|
||
}
|
||
else if( val_win >= tabdata.item0_page1_fup )
|
||
{
|
||
tabdata.item0_page1_flow = tabdata.item0_page1_fup;
|
||
}
|
||
else
|
||
{
|
||
tabdata.item0_page1_flow = (uint8_t)val_win;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case TC_UP_SET:
|
||
{
|
||
//既要保证不超出最大上限,又要保证不低于当前的下限
|
||
uint8_t type = (uint8_t)tabdata.item0_page1_TCtype - 5;
|
||
|
||
if( val_win <= tabdata.item0_page1_TClow[type] )
|
||
{
|
||
tabdata.item0_page1_TCup[type] = tabdata.item0_page1_TClow[type];
|
||
}
|
||
else if( val_win >= TC[type].up )
|
||
{
|
||
tabdata.item0_page1_TCup[type] = TC[type].up;
|
||
}
|
||
else
|
||
{
|
||
tabdata.item0_page1_TCup[type] = val_win;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case TC_LOW_SET:
|
||
{
|
||
//既要保证不低于最小下限,又要保证不超过当前的上限
|
||
uint8_t type = (uint8_t)tabdata.item0_page1_TCtype - 5;
|
||
|
||
if( val_win <= TC[type].low )
|
||
{
|
||
tabdata.item0_page1_TClow[type] = TC[type].low;
|
||
}
|
||
else if( val_win >= tabdata.item0_page1_TCup[type] )
|
||
{
|
||
tabdata.item0_page1_TClow[type] = tabdata.item0_page1_TCup[type];
|
||
}
|
||
else
|
||
{
|
||
tabdata.item0_page1_TClow[type] = val_win;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case RTD_UP_SET:
|
||
{
|
||
//既要保证不超出最大上限,又要保证不低于当前的下限
|
||
if( val_win <= tabdata.item0_page2_RTDlow )
|
||
{
|
||
tabdata.item0_page2_RTDup = tabdata.item0_page2_RTDlow;
|
||
}
|
||
else if( val_win >= RTD.up )
|
||
{
|
||
tabdata.item0_page2_RTDup = RTD.up;
|
||
}
|
||
else
|
||
{
|
||
tabdata.item0_page2_RTDup = val_win;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case RTD_LOW_SET:
|
||
{
|
||
//既要保证不低于最小下限,又要保证不超过当前的上限
|
||
if( val_win <= RTD.low )
|
||
{
|
||
tabdata.item0_page2_RTDlow = RTD.low;
|
||
}
|
||
else if( val_win >= tabdata.item0_page2_RTDup )
|
||
{
|
||
tabdata.item0_page2_RTDlow = tabdata.item0_page2_RTDup;
|
||
}
|
||
else
|
||
{
|
||
tabdata.item0_page2_RTDlow = val_win;
|
||
}
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
uint8_t setting_window_display(void)
|
||
{
|
||
uint8_t result = 0;
|
||
|
||
//根据内容游标获取当前数值
|
||
int16_t val_current = 0;
|
||
switch (tabdata.current_content)
|
||
{
|
||
case VOL_UP_SET:
|
||
{
|
||
if(tabdata.item0_page0_vunit != VOLTAGE_MV) return result;
|
||
|
||
val_current = tabdata.item0_page0_vup[1];
|
||
|
||
result = 1;
|
||
}
|
||
break;
|
||
|
||
case VOL_LOW_SET:
|
||
{
|
||
if(tabdata.item0_page0_vunit != VOLTAGE_MV) return result;
|
||
|
||
val_current = tabdata.item0_page0_vlow[1];
|
||
|
||
result = 1;
|
||
}
|
||
break;
|
||
|
||
case RES_UP_SET:
|
||
{
|
||
val_current = tabdata.item0_page0_rup;
|
||
|
||
result = 1;
|
||
}
|
||
break;
|
||
|
||
case RES_LOW_SET:
|
||
{
|
||
val_current = tabdata.item0_page1_rlow;
|
||
|
||
result = 1;
|
||
}
|
||
break;
|
||
|
||
case FRE_UP_SET:
|
||
{
|
||
val_current = (int16_t)tabdata.item0_page1_fup;
|
||
|
||
result = 1;
|
||
}
|
||
break;
|
||
|
||
case FRE_LOW_SET:
|
||
{
|
||
val_current = (int16_t)tabdata.item0_page1_flow;
|
||
|
||
result = 1;
|
||
}
|
||
break;
|
||
|
||
case TC_UP_SET:
|
||
{
|
||
val_current = tabdata.item0_page1_TCup[(uint8_t)tabdata.item0_page1_TCtype - 5];
|
||
|
||
result = 1;
|
||
}
|
||
break;
|
||
|
||
case TC_LOW_SET:
|
||
{
|
||
val_current = tabdata.item0_page1_TClow[(uint8_t)tabdata.item0_page1_TCtype - 5];
|
||
|
||
result = 1;
|
||
}
|
||
break;
|
||
|
||
case RTD_UP_SET:
|
||
{
|
||
val_current = tabdata.item0_page2_RTDup;
|
||
|
||
result = 1;
|
||
}
|
||
break;
|
||
|
||
case RTD_LOW_SET:
|
||
{
|
||
val_current = tabdata.item0_page2_RTDlow;
|
||
|
||
result = 1;
|
||
}
|
||
break;
|
||
|
||
default:
|
||
result = 0;
|
||
break;
|
||
}
|
||
|
||
if(result == 1)
|
||
{
|
||
//显示弹窗
|
||
setting_val2window(val_current);
|
||
lv_obj_clear_flag(guider_ui.screen_setting_window_set, LV_OBJ_FLAG_HIDDEN);
|
||
//点亮游标
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
void setting_window_num_check(uint8_t cur, uint8_t cur_prv)
|
||
{
|
||
switch (cur)
|
||
{
|
||
case 0:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_num_0, lv_color_hex(COLOR_ITEMS_CHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 1:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_num_1, lv_color_hex(COLOR_ITEMS_CHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 2:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_num_2, lv_color_hex(COLOR_ITEMS_CHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 3:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_num_3, lv_color_hex(COLOR_ITEMS_CHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 4:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_num_sign, lv_color_hex(COLOR_ITEMS_CHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
switch (cur_prv)
|
||
{
|
||
case 0:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_num_0, lv_color_hex(COLOR_ITEMS_UNCHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 1:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_num_1, lv_color_hex(COLOR_ITEMS_UNCHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 2:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_num_2, lv_color_hex(COLOR_ITEMS_UNCHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 3:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_num_3, lv_color_hex(COLOR_ITEMS_UNCHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
case 4:
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_num_sign, lv_color_hex(COLOR_ITEMS_UNCHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
void setting_window_set_num(uint8_t cur)
|
||
{
|
||
char str_temp[8] = {0};
|
||
|
||
switch (cur)
|
||
{
|
||
case 0:
|
||
{
|
||
sprintf(str_temp, "%d", setting_window_num[0]);
|
||
lv_label_set_text(guider_ui.screen_setting_num_0, str_temp);
|
||
}
|
||
break;
|
||
|
||
case 1:
|
||
{
|
||
sprintf(str_temp, "%d", setting_window_num[1]);
|
||
lv_label_set_text(guider_ui.screen_setting_num_1, str_temp);
|
||
}
|
||
break;
|
||
|
||
case 2:
|
||
{
|
||
sprintf(str_temp, "%d", setting_window_num[2]);
|
||
lv_label_set_text(guider_ui.screen_setting_num_2, str_temp);
|
||
}
|
||
break;
|
||
|
||
case 3:
|
||
{
|
||
sprintf(str_temp, "%d", setting_window_num[3]);
|
||
lv_label_set_text(guider_ui.screen_setting_num_3, str_temp);
|
||
}
|
||
break;
|
||
|
||
case 4:
|
||
{
|
||
if( setting_window_num[4] == 1)
|
||
{
|
||
lv_label_set_text(guider_ui.screen_setting_num_sign, "-");
|
||
}
|
||
else
|
||
{
|
||
lv_label_set_text(guider_ui.screen_setting_num_sign, "+");
|
||
}
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|