742 lines
29 KiB
C
742 lines
29 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
|
||
};
|
||
|
||
//设置菜单数据初始化
|
||
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] = m5data.input_mode_type;
|
||
tabdata.output_log_unit[0] = m5data.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_timeout_period = 1000; //默认超时时间为1000ms
|
||
|
||
//ITEMS_3(部分内容位于EERPOM读取)
|
||
tabdata.item3_page0_lightflag = 0; //照明状态标志,0熄灭,1开启
|
||
LIGHT_OFF;
|
||
tabdata.item3_page0_saveflag = 0;
|
||
tabdata.item3_page0_resetflag = 0;
|
||
|
||
}
|
||
|
||
//选项卡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, 7);
|
||
set_obj_color(guider_ui.screen_setting_label_31, 7);
|
||
}
|
||
|
||
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)
|
||
{
|
||
setting_items_page(ITEM_3, 1);
|
||
}
|
||
}
|
||
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)
|
||
{
|
||
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;
|
||
}
|
||
set_item3_text(DATA_SAVE);
|
||
|
||
//使能所有按键
|
||
key_config(KEY_ALL, KEY_STATUS_ENABLE);
|
||
|
||
save_step = 0;
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
uint8_t reset_step = 0;
|
||
//执行复位功能
|
||
void deal_data_reset(void)
|
||
{
|
||
if(tabdata.item3_page0_resetflag == 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;
|
||
set_item3_text(DATA_SAVE);
|
||
|
||
//选项卡与标题
|
||
setting_laguage_switch(tabdata.item3_page0_language);
|
||
title_item_refresh();
|
||
setting_items_page(ITEM_3, 1);
|
||
|
||
//使能所有按键
|
||
key_config(KEY_ALL, KEY_STATUS_ENABLE);
|
||
|
||
reset_step = 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;
|
||
}
|
||
|