876 lines
31 KiB
C
876 lines
31 KiB
C
#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 = 3000;
|
||
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 = 5000;
|
||
}
|
||
|
||
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;
|
||
}
|
||
}
|
||
|
||
void program_out_run(void)
|
||
{
|
||
switch (progout_data.output_mode)
|
||
{
|
||
case PROG_OUT_STEP:
|
||
{
|
||
program_out_step();
|
||
}
|
||
break;
|
||
|
||
case PROG_OUT_TRIANGLE:
|
||
{
|
||
program_out_triangle();
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
void percent2val_out(float32 perc)
|
||
{
|
||
if( (perc < 0)||(perc > 100) ) return;
|
||
|
||
mux_signal.data_sv = perc / (float32)100 * (progout_data.out_max - progout_data.out_min) + progout_data.out_min;
|
||
mux_signal.data_sv = real2mux(mux_signal.data_sv);
|
||
}
|
||
|
||
int8_t step_dir = 0;
|
||
uint8_t cir_times = 0;
|
||
void program_out_step(void)
|
||
{
|
||
switch (progout_data.process)
|
||
{
|
||
case PROGOUT_START:
|
||
{
|
||
if( progout_tick_flag == 0 )
|
||
{
|
||
//计时开始
|
||
progout_tick_flag = 1;
|
||
progout_tick = 0;
|
||
|
||
progout_data.out_percent = progout_data.start_percent;
|
||
percent2val_out(progout_data.out_percent);
|
||
step_dir = 1;
|
||
}
|
||
else
|
||
{
|
||
//到达起点%后等待一段时间
|
||
if(progout_tick >= 3000)
|
||
{
|
||
//计时结束
|
||
progout_tick_flag = 0;
|
||
progout_tick = 0;
|
||
|
||
progout_data.process = PROGOUT_RUNNING;
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
|
||
case PROGOUT_RUNNING:
|
||
{
|
||
//迁移至mux任务内
|
||
}
|
||
break;
|
||
|
||
case PROGOUT_END:
|
||
{
|
||
if( progout_tick_flag == 0 )
|
||
{
|
||
progout_tick_flag = 1;
|
||
progout_tick = 0;
|
||
|
||
//相关参数清零
|
||
step_dir = 0;
|
||
cir_times = 0;
|
||
}
|
||
else
|
||
{
|
||
//等待3秒后返回config2界面
|
||
if(progout_tick >= 3000)
|
||
{
|
||
//计时结束
|
||
progout_tick_flag = 0;
|
||
progout_tick = 0;
|
||
|
||
//输出关闭、清零
|
||
menu_data.io_on2off = IO_OFF;
|
||
mux_signal.data_sv = 0;
|
||
|
||
//加载菜单界面
|
||
lv_scr_load(guider_ui.screen_setting);
|
||
scr_setting_recover();
|
||
lv_obj_clear_flag(guider_ui.screen_setting, LV_OBJ_FLAG_HIDDEN);
|
||
|
||
//隐藏主界面对象
|
||
lv_obj_add_flag(guider_ui.screen_main, LV_OBJ_FLAG_HIDDEN);
|
||
|
||
//当前界面为详细设置菜单,切换至ITEM2
|
||
menu_data.scr_now = SCREEN_SETTING;
|
||
tabdata.item_cursor_prv = ITEM_0;
|
||
tabdata.item_cursor = ITEM_2;
|
||
setting_items_check(tabdata.item_cursor, tabdata.item_cursor_prv);
|
||
|
||
//返回config2界面
|
||
program_out_config2();
|
||
current_operation = PROG_OUT_CONFIG_2;
|
||
key_config_update(current_operation);
|
||
|
||
progout_data.process = PROGOUT_WAITING;
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
void running_process_step(void)
|
||
{
|
||
if(progout_tick_flag == 0)
|
||
{
|
||
//计时开始
|
||
progout_tick_flag = 1;
|
||
progout_tick = 0;
|
||
|
||
progout_data.out_percent += step_dir * progout_data.step_percent;
|
||
|
||
if(progout_data.out_percent <= progout_data.start_percent)
|
||
{
|
||
//向下触底后本次循环结束
|
||
progout_data.out_percent = progout_data.start_percent;
|
||
step_dir = 1;
|
||
|
||
cir_times++;
|
||
if( progout_data.circulations < 11 )
|
||
{
|
||
//循环次数达到目标后,跳转至终止步骤
|
||
if(cir_times >= progout_data.circulations)
|
||
{
|
||
progout_data.process = PROGOUT_END;
|
||
progout_tick_flag = 0;
|
||
progout_tick = 0;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//无限循环
|
||
cir_times = 0;
|
||
}
|
||
}
|
||
else if(progout_data.out_percent >= progout_data.end_percent)
|
||
{
|
||
//向上触顶后反向
|
||
progout_data.out_percent = progout_data.end_percent;
|
||
step_dir = -1;
|
||
}
|
||
percent2val_out(progout_data.out_percent);
|
||
}
|
||
else
|
||
{
|
||
if( progout_tick >= progout_data.hold_time )
|
||
{
|
||
//计时结束
|
||
progout_tick_flag = 0;
|
||
progout_tick = 0;
|
||
}
|
||
}
|
||
}
|
||
|
||
uint8_t tri_interval = 0; //控制周期,调整输出的时间间隔
|
||
uint8_t tri_step_up = 0; //上升阶段每次变化的步长
|
||
uint8_t tri_step_down = 0; //下降阶段每次变化的步长
|
||
uint8_t tri_up2down = 0; //上升和下降的分界点,第几个间隔
|
||
void program_out_triangle(void)
|
||
{
|
||
switch (progout_data.process)
|
||
{
|
||
case PROGOUT_START:
|
||
{
|
||
if( progout_tick_flag == 0 )
|
||
{
|
||
//计时开始
|
||
progout_tick_flag = 1;
|
||
progout_tick = 0;
|
||
|
||
progout_data.out_percent = progout_data.start_percent;
|
||
percent2val_out(progout_data.out_percent);
|
||
|
||
//初始方向、控制间隔、上升&下降的分界点、上升&下降各自的步长
|
||
step_dir = 1;
|
||
tri_interval = progout_data.period / TRIANLE_PLOT_INTERVAL_MAX;
|
||
tri_up2down = ( (float32)progout_data.rising_percent/(float32)100 ) * TRIANLE_PLOT_INTERVAL_MAX;
|
||
if( tri_up2down == 0 )
|
||
{
|
||
tri_step_up = progout_data.end_percent - progout_data.start_percent;
|
||
tri_step_down = (progout_data.end_percent - progout_data.start_percent)/TRIANLE_PLOT_INTERVAL_MAX;
|
||
}
|
||
else if( tri_up2down == TRIANLE_PLOT_INTERVAL_MAX)
|
||
{
|
||
tri_step_up = (progout_data.end_percent - progout_data.start_percent)/TRIANLE_PLOT_INTERVAL_MAX;
|
||
tri_step_down = progout_data.end_percent - progout_data.start_percent;
|
||
}
|
||
else
|
||
{
|
||
tri_step_up = (progout_data.end_percent - progout_data.start_percent)/tri_up2down;
|
||
tri_step_down = (progout_data.end_percent - progout_data.start_percent)/(TRIANLE_PLOT_INTERVAL_MAX - tri_up2down);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//到达起点%后等待一段时间
|
||
if(progout_tick >= 3000)
|
||
{
|
||
//计时结束
|
||
progout_tick_flag = 0;
|
||
progout_tick = 0;
|
||
|
||
progout_data.process = PROGOUT_RUNNING;
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
|
||
case PROGOUT_RUNNING:
|
||
{
|
||
//迁移至mux任务内
|
||
}
|
||
break;
|
||
|
||
case PROGOUT_END:
|
||
{
|
||
if( progout_tick_flag == 0 )
|
||
{
|
||
progout_tick_flag = 1;
|
||
progout_tick = 0;
|
||
|
||
//相关参数清零
|
||
step_dir = 0;
|
||
cir_times = 0;
|
||
tri_interval = 0;
|
||
tri_step_up = 0;
|
||
tri_step_down = 0;
|
||
tri_up2down = 0;
|
||
}
|
||
else
|
||
{
|
||
//等待3秒后返回config2界面
|
||
if(progout_tick >= 3000)
|
||
{
|
||
//计时结束
|
||
progout_tick_flag = 0;
|
||
progout_tick = 0;
|
||
|
||
//输出关闭、清零
|
||
menu_data.io_on2off = IO_OFF;
|
||
mux_signal.data_sv = 0;
|
||
|
||
//加载菜单界面
|
||
lv_scr_load(guider_ui.screen_setting);
|
||
scr_setting_recover();
|
||
lv_obj_clear_flag(guider_ui.screen_setting, LV_OBJ_FLAG_HIDDEN);
|
||
|
||
//隐藏主界面对象
|
||
lv_obj_add_flag(guider_ui.screen_main, LV_OBJ_FLAG_HIDDEN);
|
||
|
||
menu_data.scr_now = SCREEN_SETTING; //当前界面为详细设置菜单
|
||
|
||
tabdata.item_cursor_prv = ITEM_0;
|
||
tabdata.item_cursor = ITEM_2;
|
||
setting_items_check(tabdata.item_cursor, tabdata.item_cursor_prv);
|
||
|
||
//返回config2界面
|
||
program_out_config2();
|
||
current_operation = PROG_OUT_CONFIG_2;
|
||
key_config_update(current_operation);
|
||
|
||
progout_data.process = PROGOUT_WAITING;
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
void running_process_triangle(void)
|
||
{
|
||
if( progout_tick_flag == 0 )
|
||
{
|
||
//计时开始
|
||
progout_tick_flag = 1;
|
||
progout_tick = 0;
|
||
|
||
if(step_dir == 1)
|
||
{
|
||
progout_data.out_percent += tri_step_up;
|
||
if(progout_data.out_percent >= progout_data.end_percent)
|
||
{
|
||
progout_data.out_percent = progout_data.end_percent;
|
||
step_dir = -1;
|
||
}
|
||
}
|
||
else if(step_dir == -1)
|
||
{
|
||
progout_data.out_percent -= tri_step_down;
|
||
if( (progout_data.out_percent <= progout_data.start_percent)||(progout_data.out_percent > 101) )
|
||
{
|
||
progout_data.out_percent = progout_data.start_percent;
|
||
|
||
cir_times++;
|
||
step_dir = 1;
|
||
if( progout_data.circulations < 11 )
|
||
{
|
||
//循环次数达到目标后,跳转至终止步骤
|
||
if(cir_times >= progout_data.circulations) progout_data.process = PROGOUT_END;
|
||
}
|
||
else
|
||
{
|
||
//无限循环
|
||
cir_times = 0;
|
||
}
|
||
}
|
||
}
|
||
percent2val_out(progout_data.out_percent);
|
||
}
|
||
else
|
||
{
|
||
if(progout_tick >= tri_interval)
|
||
{
|
||
//计时结束
|
||
progout_tick_flag = 0;
|
||
progout_tick = 0;
|
||
}
|
||
}
|
||
}
|
||
|