#include "scr_setting_progam_out.h" PROGRAM_OUT_DATA progout_data; uint8_t cursor_conf1 = 0; uint8_t cursor_conf1_prv = 99; uint8_t cursor_conf2 = 0; uint8_t cursor_conf2_prv = 99; void program_out_init(void) { progout_data.output_unit = PROG_OUT_MA; progout_data.output_mode = PROG_OUT_STEP; progout_data.circulations = 3; progout_data.hold_time = 2000; progout_data.start_percent = 0; progout_data.end_percent = 100; progout_data.step_percent = 25; progout_data.rising_percent = 100; progout_data.falling_percent = 0; progout_data.period = 3000; } void program_out_config1(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.program_out_config1[0]); lv_label_set_text(guider_ui.screen_setting_label_10, text_pack.program_out_config1[1]); lv_label_set_text(guider_ui.screen_setting_label_20, text_pack.program_out_config1[2]); lv_label_set_text(guider_ui.screen_setting_label_30, text_pack.program_out_config1[3]); //显示右列值 text_update_conf1(CONF1_OUTPUT_UNIT); text_update_conf1(CONF1_OUTPUT_MODE); text_update_conf1(CONF1_CIRCULATIONS); lv_label_set_text(guider_ui.screen_setting_label_31, ">"); //初始化游标 cursor_conf1 = 0; cursor_conf1_prv = 99; setting_contents_check(cursor_conf1, cursor_conf1_prv); } void val_modify_conf1(int8_t step) { switch(cursor_conf1) { case CONF1_OUTPUT_UNIT: { progout_data.output_unit += step; if( (1 < progout_data.output_unit)&&(progout_data.output_unit < 200) ) progout_data.output_unit = 0; if( progout_data.output_unit > 200 ) progout_data.output_unit = 1; } break; case CONF1_OUTPUT_MODE: { progout_data.output_mode += step; if( (1 < progout_data.output_mode)&&(progout_data.output_mode < 200) ) progout_data.output_mode = 0; if( progout_data.output_mode > 200 ) progout_data.output_mode = 1; } break; case CONF1_CIRCULATIONS: { progout_data.circulations += step; if( (11 < progout_data.circulations)&&(progout_data.circulations < 200) ) progout_data.circulations = 1; if( progout_data.circulations < 1 ) progout_data.circulations = 11; } break; default: break; } } void text_update_conf1(uint8_t con) { char str_temp[20] = {0}; switch (con) { case CONF1_OUTPUT_UNIT: { switch (progout_data.output_unit) { case PROG_OUT_V: { if(tabdata.content_focus == 0) { lv_label_set_text(guider_ui.screen_setting_label_01, "V"); } else { lv_label_set_text(guider_ui.screen_setting_label_01, "< V >"); } } break; case PROG_OUT_MA: { if(tabdata.content_focus == 0) { lv_label_set_text(guider_ui.screen_setting_label_01, "mA"); } else { lv_label_set_text(guider_ui.screen_setting_label_01, "< mA >"); } } break; default: break; } } break; case CONF1_OUTPUT_MODE: { if(tabdata.content_focus == 0) { lv_label_set_text(guider_ui.screen_setting_label_11, text_pack.program_out_config1_val[progout_data.output_mode]); } else { sprintf(str_temp, "< %s >", text_pack.program_out_config1_val[progout_data.output_mode]); lv_label_set_text(guider_ui.screen_setting_label_11, str_temp); } } break; case CONF1_CIRCULATIONS: { if(tabdata.content_focus == 0) { if(progout_data.circulations <= CIRCULATIONS_MAX ) { sprintf(str_temp, "%d", progout_data.circulations); lv_label_set_text(guider_ui.screen_setting_label_21, str_temp); } else { lv_label_set_text(guider_ui.screen_setting_label_21, "∞"); } } else { if(progout_data.circulations <= CIRCULATIONS_MAX ) { sprintf(str_temp, "< %d >", progout_data.circulations); lv_label_set_text(guider_ui.screen_setting_label_21, str_temp); } else { lv_label_set_text(guider_ui.screen_setting_label_21, "< ∞ >"); } } } break; default: break; } } void program_out_config2(void) { switch (progout_data.output_mode) { case PROG_OUT_STEP: { //启用所需组件 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); }; //隐藏多余组件 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.program_out_config2[0]); lv_label_set_text(guider_ui.screen_setting_label_10, text_pack.program_out_config2[2]); lv_label_set_text(guider_ui.screen_setting_label_20, text_pack.program_out_config2[3]); lv_label_set_text(guider_ui.screen_setting_label_30, text_pack.program_out_config2[4]); lv_label_set_text(guider_ui.screen_setting_label_40, text_pack.program_out_config2[1]); //显示右列值 text_update_conf2(CONF2_OUTPUT_MODE); text_update_conf2(CONF2_START_PERCENT); text_update_conf2(CONF2_END_PERCENT); text_update_conf2(CONF2_STEP_PERCENT); text_update_conf2(CONF2_HOLD_TIME); //初始化游标 cursor_conf2 = 1; cursor_conf2_prv = 99; setting_contents_check(cursor_conf2, cursor_conf2_prv); } break; case PROG_OUT_TRIANGLE: { //启用所需组件 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); }; //显示左列文本 lv_label_set_text(guider_ui.screen_setting_label_00, text_pack.program_out_config2[0]); lv_label_set_text(guider_ui.screen_setting_label_10, text_pack.program_out_config2[2]); lv_label_set_text(guider_ui.screen_setting_label_20, text_pack.program_out_config2[3]); lv_label_set_text(guider_ui.screen_setting_label_30, text_pack.program_out_config2[5]); lv_label_set_text(guider_ui.screen_setting_label_40, text_pack.program_out_config2[6]); lv_label_set_text(guider_ui.screen_setting_label_50, text_pack.program_out_config2[7]); //显示右列值 text_update_conf2(CONF2_OUTPUT_MODE); text_update_conf2(CONF2_START_PERCENT); text_update_conf2(CONF2_END_PERCENT); text_update_conf2(CONF2_RISING_PERCENT); text_update_conf2(CONF2_FALLING_PERCENT); text_update_conf2(CONF2_PERIOD); //初始化游标 cursor_conf2 = 1; cursor_conf2_prv = 99; setting_contents_check(cursor_conf2, cursor_conf2_prv); } break; default: break; } } void text_update_conf2(uint8_t con) { char str_temp[20] = {0}; switch (con) { case CONF2_OUTPUT_MODE: { lv_label_set_text(guider_ui.screen_setting_label_01, text_pack.program_out_config1_val[progout_data.output_mode]); } break; case CONF2_START_PERCENT: { if(tabdata.content_focus == 0) { sprintf(str_temp, "%d%%", progout_data.start_percent); lv_label_set_text(guider_ui.screen_setting_label_11, str_temp); } else { sprintf(str_temp, "< %d%% >", progout_data.start_percent); lv_label_set_text(guider_ui.screen_setting_label_11, str_temp); } } break; case CONF2_END_PERCENT: { if(tabdata.content_focus == 0) { sprintf(str_temp, "%d%%", progout_data.end_percent); lv_label_set_text(guider_ui.screen_setting_label_21, str_temp); } else { sprintf(str_temp, "< %d%% >", progout_data.end_percent); lv_label_set_text(guider_ui.screen_setting_label_21, str_temp); } } break; case CONF2_STEP_PERCENT: { if(tabdata.content_focus == 0) { sprintf(str_temp, "%d%%", progout_data.step_percent); lv_label_set_text(guider_ui.screen_setting_label_31, str_temp); } else { sprintf(str_temp, "< %d%% >", progout_data.step_percent); lv_label_set_text(guider_ui.screen_setting_label_31, str_temp); } } break; case CONF2_HOLD_TIME: { if(tabdata.content_focus == 0) { sprintf(str_temp, "%d", progout_data.hold_time); lv_label_set_text(guider_ui.screen_setting_label_41, str_temp); } else { sprintf(str_temp, "< %d >", progout_data.hold_time); lv_label_set_text(guider_ui.screen_setting_label_41, str_temp); } } break; case CONF2_RISING_PERCENT: { if(tabdata.content_focus == 0) { sprintf(str_temp, "%d%%", progout_data.rising_percent); lv_label_set_text(guider_ui.screen_setting_label_31, str_temp); } else { sprintf(str_temp, "< %d%% >", progout_data.rising_percent); lv_label_set_text(guider_ui.screen_setting_label_31, str_temp); } } break; case CONF2_FALLING_PERCENT: { if(tabdata.content_focus == 0) { sprintf(str_temp, "%d%%", progout_data.falling_percent); lv_label_set_text(guider_ui.screen_setting_label_41, str_temp); } else { sprintf(str_temp, "< %d%% >", progout_data.falling_percent); lv_label_set_text(guider_ui.screen_setting_label_41, str_temp); } } break; case CONF2_PERIOD: { if(tabdata.content_focus == 0) { sprintf(str_temp, "%d", progout_data.period); lv_label_set_text(guider_ui.screen_setting_label_51, str_temp); } else { sprintf(str_temp, "< %d >", progout_data.period); lv_label_set_text(guider_ui.screen_setting_label_51, str_temp); } } break; default: break; } } void val_modify_conf2(int8_t step) { uint8_t cur_temp = 0; //阶跃和三角波的枚举类型存在交叉 if( (progout_data.output_mode == PROG_OUT_STEP)||(cursor_conf2 <= 2) ) { cur_temp = cursor_conf2; } else { cur_temp = cursor_conf2 + 2; } switch(cur_temp) { //0~95 case CONF2_START_PERCENT: { progout_data.start_percent += step; if(progout_data.start_percent > 200) progout_data.start_percent = 0; if( (progout_data.end_percent - 5) <= progout_data.start_percent ) progout_data.start_percent = progout_data.end_percent - 5; text_update_conf2(cur_temp); if(progout_data.output_mode == PROG_OUT_STEP) { //起点与终点的间隔较小时,步长同步变化 if(progout_data.step_percent > (progout_data.end_percent - progout_data.start_percent)) progout_data.step_percent = progout_data.end_percent - progout_data.start_percent; tabdata.content_focus = 0; text_update_conf2(CONF2_STEP_PERCENT); tabdata.content_focus = 1; } } break; //5~100 case CONF2_END_PERCENT: { progout_data.end_percent += step; if(progout_data.end_percent > 100) progout_data.end_percent = 100; if( (progout_data.end_percent - 5) <= progout_data.start_percent ) progout_data.end_percent = progout_data.start_percent + 5; text_update_conf2(cur_temp); if(progout_data.output_mode == PROG_OUT_STEP) { //起点与终点的间隔较小时,步长同步变化 if(progout_data.step_percent > (progout_data.end_percent - progout_data.start_percent)) progout_data.step_percent = progout_data.end_percent - progout_data.start_percent; tabdata.content_focus = 0; text_update_conf2(CONF2_STEP_PERCENT); tabdata.content_focus = 1; } } break; case CONF2_STEP_PERCENT: { progout_data.step_percent += step; if(progout_data.step_percent < 5) progout_data.step_percent = 5; if(progout_data.step_percent > (progout_data.end_percent - progout_data.start_percent)) progout_data.step_percent = progout_data.end_percent - progout_data.start_percent; text_update_conf2(cur_temp); } break; case CONF2_HOLD_TIME: { if( step > 0 ) { progout_data.hold_time += 500; } else { progout_data.hold_time -= 500; } if(progout_data.hold_time < 500) progout_data.hold_time = 500; if(progout_data.hold_time > 30000) progout_data.hold_time = 30000; text_update_conf2(cur_temp); } break; case CONF2_RISING_PERCENT: { progout_data.rising_percent += step; if( progout_data.rising_percent > 200 ) progout_data.rising_percent = 0; if( progout_data.rising_percent > 100 ) progout_data.rising_percent = 100; text_update_conf2(CONF2_RISING_PERCENT); //下降占比同步更新 progout_data.falling_percent = 100 - progout_data.rising_percent; tabdata.content_focus = 0; text_update_conf2(CONF2_FALLING_PERCENT); tabdata.content_focus = 1; } break; case CONF2_FALLING_PERCENT: { progout_data.falling_percent += step; if( progout_data.falling_percent > 200 ) progout_data.falling_percent = 0; if( progout_data.falling_percent > 100 ) progout_data.falling_percent = 100; text_update_conf2(CONF2_FALLING_PERCENT); //上升占比同步更新 progout_data.rising_percent = 100 - progout_data.falling_percent; tabdata.content_focus = 0; text_update_conf2(CONF2_RISING_PERCENT); tabdata.content_focus = 1; } break; case CONF2_PERIOD: { if( step > 0 ) { progout_data.period += 500; } else { progout_data.period -= 500; } if(progout_data.period < 1000) progout_data.period = 1000; if(progout_data.period > 10000) progout_data.period = 10000; text_update_conf2(cur_temp); } break; default: break; } }