1236 lines
39 KiB
C
1236 lines
39 KiB
C
#include "key_functions.h"
|
||
|
||
KEYS key_pv; //当前按键
|
||
KEYS_STATUS key_sts[11] = {KEY_STATUS_DISABLE}; //11个按键的状态,排列顺序与枚举顺序一致
|
||
|
||
//按键数据类型转换
|
||
void key_char2struct(void)
|
||
{
|
||
key_pv.value = (KEYS_VALUE)key;
|
||
|
||
switch (key_pv.value)
|
||
{
|
||
case KEY_OUT_VAL:
|
||
{
|
||
key_pv.tag = KEY_OUT;
|
||
key_pv.status = key_sts[key_pv.tag];
|
||
}
|
||
break;
|
||
|
||
case KEY_UP_VAL:
|
||
{
|
||
key_pv.tag = KEY_UP;
|
||
key_pv.status = key_sts[key_pv.tag];
|
||
}
|
||
break;
|
||
|
||
case KEY_MENU_VAL:
|
||
{
|
||
key_pv.tag = KEY_MENU;
|
||
key_pv.status = key_sts[key_pv.tag];
|
||
}
|
||
break;
|
||
|
||
case KEY_IN_VAL:
|
||
{
|
||
key_pv.tag = KEY_IN;
|
||
key_pv.status = key_sts[key_pv.tag];
|
||
}
|
||
break;
|
||
|
||
case KEY_LEFT_VAL:
|
||
{
|
||
key_pv.tag = KEY_LEFT;
|
||
key_pv.status = key_sts[key_pv.tag];
|
||
}
|
||
break;
|
||
|
||
case KEY_OK_VAL:
|
||
{
|
||
key_pv.tag = KEY_OK;
|
||
key_pv.status = key_sts[key_pv.tag];
|
||
}
|
||
break;
|
||
|
||
case KEY_RIGHT_VAL:
|
||
{
|
||
key_pv.tag = KEY_RIGHT;
|
||
key_pv.status = key_sts[key_pv.tag];
|
||
}
|
||
break;
|
||
|
||
case KEY_SWITCH_VAL:
|
||
{
|
||
key_pv.tag = KEY_SWITCH;
|
||
key_pv.status = key_sts[key_pv.tag];
|
||
}
|
||
break;
|
||
|
||
case KEY_SOURCE_VAL:
|
||
{
|
||
key_pv.tag = KEY_SOURCE;
|
||
key_pv.status = key_sts[key_pv.tag];
|
||
}
|
||
break;
|
||
|
||
case KEY_DOWN_VAL:
|
||
{
|
||
key_pv.tag = KEY_DOWN;
|
||
key_pv.status = key_sts[key_pv.tag];
|
||
}
|
||
break;
|
||
|
||
case KEY_BACK_VAL:
|
||
{
|
||
key_pv.tag = KEY_BACK;
|
||
key_pv.status = key_sts[key_pv.tag];
|
||
}
|
||
break;
|
||
|
||
case KEY_NONE_VAL:
|
||
{
|
||
key_pv.tag = KEY_NONE;
|
||
key_pv.status = KEY_STATUS_DISABLE;
|
||
}
|
||
break;
|
||
|
||
case KEY_ALL_VAL:
|
||
{
|
||
key_pv.tag = KEY_ALL;
|
||
key_pv.status = KEY_STATUS_DISABLE;
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
//按键状态配置
|
||
void key_config(KEYS_TAG key_t, KEYS_STATUS sts)
|
||
{
|
||
if(key_t != KEY_ALL)
|
||
{
|
||
key_sts[key_t] = sts;
|
||
}
|
||
else
|
||
{
|
||
for (uint8_t i = 0; i < 11; i++)
|
||
{
|
||
key_sts[i] = sts;
|
||
}
|
||
}
|
||
}
|
||
|
||
//按键配置更新
|
||
void key_config_update(OPERATIONS ope)
|
||
{
|
||
switch (ope)
|
||
{
|
||
case OPENNING_ANIME:
|
||
{
|
||
key_config(KEY_ALL, KEY_STATUS_DISABLE);
|
||
}
|
||
break;
|
||
|
||
case MAIN_FUNCTION:
|
||
{
|
||
key_config(KEY_ALL, KEY_STATUS_ENABLE);
|
||
}
|
||
break;
|
||
|
||
case SET_ITEM_CHOOSE:
|
||
{
|
||
//使能:上、下、确认(OK)、返回
|
||
key_config(KEY_UP, KEY_STATUS_ENABLE);
|
||
key_config(KEY_DOWN, KEY_STATUS_ENABLE);
|
||
key_config(KEY_OK, KEY_STATUS_ENABLE);
|
||
key_config(KEY_BACK, KEY_STATUS_ENABLE);
|
||
|
||
//不使能其他按键
|
||
key_config(KEY_LEFT, KEY_STATUS_DISABLE);
|
||
key_config(KEY_RIGHT, KEY_STATUS_DISABLE);
|
||
key_config(KEY_IN, KEY_STATUS_DISABLE);
|
||
key_config(KEY_OUT, KEY_STATUS_DISABLE);
|
||
key_config(KEY_SOURCE, KEY_STATUS_DISABLE);
|
||
key_config(KEY_MENU, KEY_STATUS_DISABLE);
|
||
key_config(KEY_SWITCH, KEY_STATUS_DISABLE);
|
||
}
|
||
break;
|
||
|
||
case SET_CONTENT_CHOOSE:
|
||
{
|
||
//使能:上、下、左、右、确认(OK)、返回
|
||
key_config(KEY_UP, KEY_STATUS_ENABLE);
|
||
key_config(KEY_DOWN, KEY_STATUS_ENABLE);
|
||
key_config(KEY_LEFT, KEY_STATUS_ENABLE);
|
||
key_config(KEY_RIGHT, KEY_STATUS_ENABLE);
|
||
key_config(KEY_OK, KEY_STATUS_ENABLE);
|
||
key_config(KEY_BACK, KEY_STATUS_ENABLE);
|
||
|
||
//不使能其他按键
|
||
key_config(KEY_IN, KEY_STATUS_DISABLE);
|
||
key_config(KEY_OUT, KEY_STATUS_DISABLE);
|
||
key_config(KEY_SOURCE, KEY_STATUS_DISABLE);
|
||
key_config(KEY_MENU, KEY_STATUS_DISABLE);
|
||
key_config(KEY_SWITCH, KEY_STATUS_DISABLE);
|
||
}
|
||
break;
|
||
|
||
case SET_CONTENT_MODIFY:
|
||
{
|
||
//使能:左、右、返回
|
||
key_config(KEY_LEFT, KEY_STATUS_ENABLE);
|
||
key_config(KEY_RIGHT, KEY_STATUS_ENABLE);
|
||
key_config(KEY_BACK, KEY_STATUS_ENABLE);
|
||
|
||
//不使能其他按键
|
||
key_config(KEY_UP, KEY_STATUS_DISABLE);
|
||
key_config(KEY_DOWN, KEY_STATUS_DISABLE);
|
||
key_config(KEY_OK, KEY_STATUS_DISABLE);
|
||
key_config(KEY_IN, KEY_STATUS_DISABLE);
|
||
key_config(KEY_OUT, KEY_STATUS_DISABLE);
|
||
key_config(KEY_SOURCE, KEY_STATUS_DISABLE);
|
||
key_config(KEY_MENU, KEY_STATUS_DISABLE);
|
||
key_config(KEY_SWITCH, KEY_STATUS_DISABLE);
|
||
}
|
||
break;
|
||
|
||
case SET_SHOW_LOG:
|
||
{
|
||
//使能:左、右、返回
|
||
key_config(KEY_LEFT, KEY_STATUS_ENABLE);
|
||
key_config(KEY_RIGHT, KEY_STATUS_ENABLE);
|
||
key_config(KEY_BACK, KEY_STATUS_ENABLE);
|
||
|
||
//不使能其他按键
|
||
key_config(KEY_UP, KEY_STATUS_DISABLE);
|
||
key_config(KEY_DOWN, KEY_STATUS_DISABLE);
|
||
key_config(KEY_OK, KEY_STATUS_DISABLE);
|
||
key_config(KEY_IN, KEY_STATUS_DISABLE);
|
||
key_config(KEY_OUT, KEY_STATUS_DISABLE);
|
||
key_config(KEY_SOURCE, KEY_STATUS_DISABLE);
|
||
key_config(KEY_MENU, KEY_STATUS_DISABLE);
|
||
key_config(KEY_SWITCH, KEY_STATUS_DISABLE);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
//KEY_MAIN
|
||
void key_functions_main(void)
|
||
{
|
||
if( key_pv.status == KEY_STATUS_DISABLE ) return;
|
||
|
||
uint8_t cursor_temp = 0; //临时游标,替代枚举变量进行加减运算
|
||
|
||
switch (key_pv.tag)
|
||
{
|
||
case KEY_OUT:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
|
||
//交替按下 in 和 out 时,只改变输入/输出,连续按同一个键的时候才改变类型
|
||
if(m5data.io_mode == IO_INPUT)
|
||
{
|
||
m5data.io_mode = IO_OUTPUT;
|
||
m5data.output_mode = m5data.input_mode;
|
||
|
||
io_on2off_status(); //更新状态指示
|
||
}
|
||
else
|
||
{
|
||
cursor_temp = (uint8_t)m5data.output_mode;
|
||
cursor_temp = (cursor_temp >= 5)?(0):(cursor_temp + 1);
|
||
m5data.output_mode = (SIG_FUNCTIONS)cursor_temp;
|
||
}
|
||
|
||
switch (m5data.output_mode)
|
||
{
|
||
case SIG_VOLTAGE: //电压
|
||
{
|
||
m5data.output_mode_type = VOLTAGE_V;
|
||
set_working_mode(m5data.output_mode, m5data.output_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_CURRENT: //电流
|
||
{
|
||
m5data.output_mode_type = CURRENT_MA;
|
||
set_working_mode(m5data.output_mode, m5data.output_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_RESISTANT: //电阻
|
||
{
|
||
m5data.output_mode_type = RESISTANT_OHM;
|
||
set_working_mode(m5data.output_mode, m5data.output_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_FREQUENCE: //频率
|
||
{
|
||
m5data.output_mode_type = FREQUENCE_KHZ;
|
||
set_working_mode(m5data.output_mode, m5data.output_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_TC: //热电偶
|
||
{
|
||
m5data.output_mode_type = TC_K;
|
||
set_working_mode(m5data.output_mode, m5data.output_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_RTD: //热电阻
|
||
{
|
||
m5data.output_mode_type = RTD_DC;
|
||
set_working_mode(m5data.output_mode, m5data.output_mode_type);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case KEY_UP:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
|
||
if(m5data.io_mode == IO_INPUT)
|
||
{
|
||
return;
|
||
}
|
||
|
||
#if NIXIE_CUBE_ENABLE
|
||
m5data.twk_flag = 1; // 上、下、左、右 任意一个键按下后,闪烁开始
|
||
m5data.twk_cnt = 0; //每次按下后闪烁计数清零
|
||
#endif
|
||
keyset_output(1);
|
||
}
|
||
break;
|
||
|
||
case KEY_MENU:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
|
||
//加载菜单界面
|
||
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);
|
||
|
||
m5data.scr_now = SCREEN_SETTING; //当前界面为详细设置菜单
|
||
}
|
||
break;
|
||
|
||
case KEY_IN:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
|
||
if(m5data.io_mode == IO_OUTPUT)
|
||
{
|
||
m5data.io_mode = IO_INPUT;
|
||
|
||
//继承之前的输出类型
|
||
m5data.input_mode = m5data.output_mode;
|
||
|
||
io_on2off_status(); //更新状态指示
|
||
}
|
||
else
|
||
{
|
||
//枚举类型不能直接运算,于是使用临时变量cursor_temp
|
||
cursor_temp = (uint8_t)m5data.input_mode;
|
||
cursor_temp = (cursor_temp >= 5)?(0):(cursor_temp + 1);
|
||
m5data.input_mode = (SIG_FUNCTIONS)cursor_temp;
|
||
}
|
||
|
||
switch (m5data.input_mode)
|
||
{
|
||
case SIG_VOLTAGE: //电压
|
||
{
|
||
m5data.input_mode_type = VOLTAGE_V;
|
||
set_working_mode(m5data.input_mode, m5data.input_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_CURRENT: //电流
|
||
{
|
||
m5data.input_mode_type = CURRENT_MA;
|
||
set_working_mode(m5data.input_mode, m5data.input_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_RESISTANT: //电阻
|
||
{
|
||
m5data.input_mode_type = RESISTANT_OHM;
|
||
set_working_mode(m5data.input_mode, m5data.input_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_FREQUENCE: //频率
|
||
{
|
||
m5data.input_mode_type = FREQUENCE_KHZ;
|
||
set_working_mode(m5data.input_mode, m5data.input_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_TC: //热电偶
|
||
{
|
||
m5data.input_mode_type = TC_K;
|
||
set_working_mode(m5data.input_mode, m5data.input_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_RTD: //热电阻
|
||
{
|
||
m5data.input_mode_type = RTD_DC;
|
||
set_working_mode(m5data.input_mode, m5data.input_mode_type);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case KEY_LEFT:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
|
||
if(m5data.io_mode == IO_INPUT)
|
||
{
|
||
return;
|
||
}
|
||
|
||
#if NIXIE_CUBE_ENABLE
|
||
// m5data.twk_flag = 1; //上、下、左、右 任意一个键按下后,闪烁开始
|
||
// m5data.twk_cnt = 0; //每次按下后闪烁计数清零
|
||
#endif
|
||
|
||
//避免游标移动的瞬间,前一刻的数值处于闪烁熄灭的状态,移动游标前重新显示一次当前数值
|
||
set_nixie_cube(IO_OUTPUT, m5data.io_cursor, m5data.o_numbers[m5data.io_cursor]);
|
||
|
||
m5data.io_cursor_prv = m5data.io_cursor;
|
||
m5data.io_cursor = (m5data.io_cursor <= 0)?(6):(m5data.io_cursor - 1);
|
||
set_cursor_position();
|
||
|
||
}
|
||
break;
|
||
|
||
case KEY_OK:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
|
||
//主界面用OK键控制开关ON&OFF
|
||
if(m5data.io_on2off == IO_ON)
|
||
{
|
||
m5data.io_on2off = IO_OFF;
|
||
}
|
||
else
|
||
{
|
||
m5data.io_on2off = IO_ON;
|
||
}
|
||
|
||
io_on2off_status(); //更新ON/OFF/IN/OUT状态指示
|
||
}
|
||
break;
|
||
|
||
case KEY_RIGHT:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
if(m5data.io_mode == IO_INPUT)
|
||
{
|
||
return;
|
||
}
|
||
|
||
#if NIXIE_CUBE_ENABLE
|
||
m5data.twk_flag = 1; // 上、下、左、右 任意一个键按下后,闪烁开始
|
||
m5data.twk_cnt = 0; //每次按下后闪烁计数清零
|
||
#endif
|
||
|
||
//避免游标移动的瞬间,前一刻的数值处于闪烁熄灭的状态,移动游标前重新显示一次当前数值
|
||
set_nixie_cube(IO_OUTPUT, m5data.io_cursor, m5data.o_numbers[m5data.io_cursor]);
|
||
|
||
m5data.io_cursor_prv = m5data.io_cursor;
|
||
m5data.io_cursor = (m5data.io_cursor >= 6)?(0):(m5data.io_cursor + 1);
|
||
set_cursor_position();
|
||
}
|
||
break;
|
||
|
||
case KEY_SWITCH:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
|
||
switch (m5data.io_mode) //输入、输出模式切换
|
||
{
|
||
case IO_OUTPUT:
|
||
{
|
||
switch (m5data.output_mode) //功能切换
|
||
{
|
||
case SIG_CURRENT:
|
||
{
|
||
m5data.output_mode_type = CURRENT_MA;
|
||
set_working_mode(m5data.output_mode, m5data.output_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_RESISTANT: //电阻
|
||
{
|
||
m5data.output_mode_type = RESISTANT_OHM;
|
||
set_working_mode(m5data.output_mode, m5data.output_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_VOLTAGE:
|
||
{
|
||
cursor_temp = (uint8_t)m5data.output_mode_type;
|
||
cursor_temp = (cursor_temp == 1)?(2):(1);
|
||
m5data.output_mode_type = (SIG_FUNCTIONS_TYPE)cursor_temp;
|
||
|
||
set_working_mode(m5data.output_mode, m5data.output_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_FREQUENCE: //频率
|
||
{
|
||
m5data.output_mode_type = FREQUENCE_KHZ;
|
||
set_working_mode(m5data.output_mode, m5data.output_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_TC: //热电偶
|
||
{
|
||
cursor_temp = (uint8_t)m5data.output_mode_type;
|
||
cursor_temp = (cursor_temp >= 12)?(5):(cursor_temp + 1);
|
||
m5data.output_mode_type = (SIG_FUNCTIONS_TYPE)cursor_temp;
|
||
|
||
set_working_mode(m5data.output_mode, m5data.output_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_RTD: //热电阻
|
||
{
|
||
m5data.output_mode_type = RTD_DC;
|
||
set_working_mode(m5data.output_mode, m5data.output_mode_type);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case IO_INPUT:
|
||
{
|
||
switch (m5data.input_mode)
|
||
{
|
||
case SIG_CURRENT:
|
||
{
|
||
m5data.input_mode_type = CURRENT_MA;
|
||
set_working_mode(m5data.input_mode, m5data.input_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_VOLTAGE:
|
||
{
|
||
cursor_temp = (uint8_t)m5data.output_mode_type;
|
||
cursor_temp = (cursor_temp == 1)?(2):(1);
|
||
m5data.output_mode_type = (SIG_FUNCTIONS_TYPE)cursor_temp;
|
||
|
||
set_working_mode(m5data.input_mode, m5data.input_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_RESISTANT: //电阻
|
||
{
|
||
m5data.input_mode_type = RESISTANT_OHM;
|
||
set_working_mode(m5data.input_mode, m5data.input_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_FREQUENCE: //频率
|
||
{
|
||
m5data.input_mode_type = FREQUENCE_KHZ;
|
||
set_working_mode(m5data.input_mode, m5data.input_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_TC: //热电偶
|
||
{
|
||
cursor_temp = (uint8_t)m5data.input_mode_type;
|
||
cursor_temp = (cursor_temp >= 12)?(5):(cursor_temp + 1);
|
||
m5data.input_mode_type = (SIG_FUNCTIONS_TYPE)cursor_temp;
|
||
|
||
set_working_mode(m5data.input_mode, m5data.input_mode_type);
|
||
}
|
||
break;
|
||
|
||
case SIG_RTD: //热电阻
|
||
{
|
||
m5data.input_mode_type = RTD_DC;
|
||
set_working_mode(m5data.input_mode, m5data.input_mode_type);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case KEY_SOURCE:
|
||
{
|
||
//电源开关靠硬件电路实现,此处可做预留
|
||
key = 0;
|
||
key_char2struct();
|
||
}
|
||
break;
|
||
|
||
case KEY_DOWN:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
if(m5data.io_mode == IO_INPUT)
|
||
{
|
||
return;
|
||
}
|
||
|
||
#if NIXIE_CUBE_ENABLE
|
||
m5data.twk_flag = 1; // 上、下、左、右 任意一个键按下后,闪烁开始
|
||
m5data.twk_cnt = 0; //每次按下后闪烁计数清零
|
||
#endif
|
||
|
||
keyset_output(-1);
|
||
}
|
||
break;
|
||
|
||
case KEY_BACK: //闲置,预留
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
}
|
||
break;
|
||
|
||
case KEY_ALL: //闲置,预留
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
}
|
||
break;
|
||
|
||
case KEY_NONE: //闲置,预留
|
||
{
|
||
}
|
||
break;
|
||
|
||
default:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
//KEY_SETTING
|
||
uint8_t log_page = 1;
|
||
void key_functions_setting(void)
|
||
{
|
||
if( key_pv.status == KEY_STATUS_DISABLE ) return;
|
||
|
||
//临时游标,替代枚举变量进行加减运算
|
||
uint8_t cursor_temp = 0;
|
||
uint8_t cursor_start = 0;
|
||
uint8_t cursor_end = 0;
|
||
|
||
switch (key_pv.tag)
|
||
{
|
||
case KEY_BACK:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
|
||
switch (current_operation)
|
||
{
|
||
case SET_ITEM_CHOOSE:
|
||
{
|
||
//加载主界面
|
||
lv_scr_load(guider_ui.screen_main);
|
||
scr_main_recover();
|
||
lv_obj_clear_flag(guider_ui.screen_main, LV_OBJ_FLAG_HIDDEN);
|
||
|
||
//隐藏设置界面对象
|
||
lv_obj_add_flag(guider_ui.screen_setting, LV_OBJ_FLAG_HIDDEN);
|
||
|
||
m5data.scr_now = SCREEN_MAIN;
|
||
|
||
//当前操作从“选项卡选择” 返回 至“主要功能”,按键配置同步更新
|
||
current_operation = MAIN_FUNCTION;
|
||
key_config_update(current_operation);
|
||
}
|
||
break;
|
||
|
||
case SET_CONTENT_CHOOSE:
|
||
{
|
||
//熄灭当前选中的内容
|
||
setting_contents_check(99, tabdata.content_cursor);
|
||
|
||
//取消内容选中与焦点
|
||
tabdata.content_cursor = 0;
|
||
tabdata.content_cursor_prv = 99;
|
||
tabdata.item_page = 1;
|
||
tabdata.item_page_prv = 1;
|
||
tabdata.content_focus = 0;
|
||
|
||
//当前操作从“内容选择” 返回 至“选项卡选择”,按键配置同步更新
|
||
current_operation = SET_ITEM_CHOOSE;
|
||
key_config_update(current_operation);
|
||
}
|
||
break;
|
||
|
||
case SET_CONTENT_MODIFY:
|
||
{
|
||
//当存在焦点时,取消焦点,返回内容选择
|
||
tabdata.content_focus = 0;
|
||
setting_contents_check(tabdata.content_cursor, CONTENT_EMPTY);
|
||
|
||
//更新当前游标所在内容的文本(焦点前后不一致)
|
||
tabdata.current_content = content_cur_char2enum(tabdata.item_cursor ,tabdata.content_cursor);
|
||
|
||
switch (tabdata.item_cursor)
|
||
{
|
||
case ITEM_0:
|
||
{
|
||
set_item0_text(tabdata.current_content);
|
||
|
||
if(tabdata.current_content == VOL_UNIT_SET)
|
||
{
|
||
set_item0_text(VOL_UP_SET);
|
||
set_item0_text(VOL_LOW_SET);
|
||
}
|
||
|
||
if(tabdata.current_content == TC_TYPE_SET)
|
||
{
|
||
set_item0_text(TC_UP_SET);
|
||
set_item0_text(TC_LOW_SET);
|
||
}
|
||
}
|
||
break;
|
||
|
||
case ITEM_1:
|
||
{
|
||
set_item1_text(tabdata.current_content);
|
||
}
|
||
break;
|
||
|
||
case ITEM_2:
|
||
{
|
||
set_item2_text(tabdata.current_content);
|
||
}
|
||
break;
|
||
|
||
case ITEM_3:
|
||
{
|
||
set_item3_text(tabdata.current_content);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
tabdata.current_content = CONTENT_EMPTY;
|
||
|
||
//当前操作从“内容修改” 返回 至“内容选择”,按键配置同步更新
|
||
current_operation = SET_CONTENT_CHOOSE;
|
||
key_config_update(current_operation);
|
||
}
|
||
break;
|
||
|
||
case SET_SHOW_LOG:
|
||
{
|
||
//恢复至原本页面
|
||
setting_items_page(ITEM_2, 1);
|
||
tabdata.content_focus = 0;
|
||
setting_contents_check(tabdata.content_cursor, tabdata.content_cursor_prv);
|
||
|
||
//当前操作从“查看记录” 返回 至“内容选择”,按键配置同步更新
|
||
current_operation = SET_CONTENT_CHOOSE;
|
||
key_config_update(current_operation);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
}
|
||
break;
|
||
|
||
case KEY_UP:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
|
||
switch (current_operation)
|
||
{
|
||
case SET_ITEM_CHOOSE:
|
||
{
|
||
cursor_start = (uint8_t)ITEM_0;
|
||
cursor_end = (uint8_t)ITEM_3;
|
||
cursor_temp = (uint8_t)tabdata.item_cursor;
|
||
cursor_temp = (cursor_temp <= cursor_start)?(cursor_end):(cursor_temp - 1);
|
||
|
||
tabdata.item_cursor_prv = tabdata.item_cursor;
|
||
tabdata.item_cursor = (ITEMS)cursor_temp;
|
||
|
||
setting_items_check(tabdata.item_cursor, tabdata.item_cursor_prv);
|
||
}
|
||
break;
|
||
|
||
case SET_CONTENT_CHOOSE:
|
||
{
|
||
switch (tabdata.item_cursor)
|
||
{
|
||
case ITEM_0:
|
||
{
|
||
cursor_start = 0;
|
||
cursor_end = 5;
|
||
}
|
||
break;
|
||
|
||
case ITEM_1:
|
||
{
|
||
cursor_start = 0;
|
||
cursor_end = 3;
|
||
}
|
||
break;
|
||
|
||
case ITEM_2:
|
||
{
|
||
cursor_start = 0;
|
||
cursor_end = 3;
|
||
}
|
||
break;
|
||
|
||
case ITEM_3:
|
||
{
|
||
cursor_start = 0;
|
||
cursor_end = 3;
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
cursor_temp = tabdata.content_cursor;
|
||
cursor_temp = ( cursor_temp <= cursor_start)?(cursor_end):(cursor_temp - 1);
|
||
|
||
tabdata.content_cursor_prv = tabdata.content_cursor;
|
||
tabdata.content_cursor = cursor_temp;
|
||
|
||
setting_contents_check(tabdata.content_cursor, tabdata.content_cursor_prv);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case KEY_DOWN:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
|
||
switch (current_operation)
|
||
{
|
||
case SET_ITEM_CHOOSE:
|
||
{
|
||
cursor_start = (uint8_t)ITEM_0;
|
||
cursor_end = (uint8_t)ITEM_3;
|
||
cursor_temp = (uint8_t)tabdata.item_cursor;
|
||
cursor_temp = (cursor_temp >= cursor_end)?(cursor_start):(cursor_temp + 1);
|
||
|
||
tabdata.item_cursor_prv = tabdata.item_cursor;
|
||
tabdata.item_cursor = (ITEMS)cursor_temp;
|
||
|
||
setting_items_check(tabdata.item_cursor, tabdata.item_cursor_prv);
|
||
}
|
||
break;
|
||
|
||
case SET_CONTENT_CHOOSE:
|
||
{
|
||
switch (tabdata.item_cursor)
|
||
{
|
||
case ITEM_0:
|
||
{
|
||
cursor_start = 0;
|
||
cursor_end = 5;
|
||
}
|
||
break;
|
||
|
||
case ITEM_1:
|
||
{
|
||
cursor_start = 0;
|
||
cursor_end = 3;
|
||
}
|
||
break;
|
||
|
||
case ITEM_2:
|
||
{
|
||
cursor_start = 0;
|
||
cursor_end = 3;
|
||
}
|
||
break;
|
||
|
||
case ITEM_3:
|
||
{
|
||
cursor_start = 0;
|
||
cursor_end = 3;
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
cursor_temp = tabdata.content_cursor;
|
||
cursor_temp = ( cursor_temp >= cursor_end)?(cursor_start):(cursor_temp + 1);
|
||
|
||
tabdata.content_cursor_prv = tabdata.content_cursor;
|
||
tabdata.content_cursor = cursor_temp;
|
||
|
||
setting_contents_check(tabdata.content_cursor, tabdata.content_cursor_prv);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case KEY_OK:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
|
||
switch (current_operation)
|
||
{
|
||
case SET_ITEM_CHOOSE:
|
||
{
|
||
//选中某个选项卡后,点亮该选项卡内的第一个内容
|
||
tabdata.content_cursor = 0;
|
||
tabdata.content_cursor_prv = 99;
|
||
setting_contents_check(tabdata.content_cursor, tabdata.content_cursor_prv);
|
||
|
||
//当前操作从“选项卡选择” 切换 至“内容选择”,按键配置同步更新
|
||
current_operation = SET_CONTENT_CHOOSE;
|
||
key_config_update(current_operation);
|
||
}
|
||
break;
|
||
|
||
case SET_CONTENT_CHOOSE:
|
||
{
|
||
//选中选项卡内的某个内容后,焦点当前选中内容
|
||
tabdata.content_focus = 1;
|
||
setting_contents_check(tabdata.content_cursor, tabdata.content_cursor_prv);
|
||
|
||
//焦点后更新所选内容的文本
|
||
tabdata.current_content = content_cur_char2enum(tabdata.item_cursor, tabdata.content_cursor);
|
||
|
||
switch (tabdata.item_cursor)
|
||
{
|
||
case ITEM_0:
|
||
{
|
||
set_item0_text(tabdata.current_content);
|
||
|
||
//当前操作从“内容选择” 切换 至“内容修改”,按键配置同步更新
|
||
current_operation = SET_CONTENT_MODIFY;
|
||
key_config_update(current_operation);
|
||
}
|
||
break;
|
||
|
||
case ITEM_1:
|
||
{
|
||
set_item1_text(tabdata.current_content);
|
||
|
||
//当前操作从“内容选择” 切换 至“内容修改”,按键配置同步更新
|
||
current_operation = SET_CONTENT_MODIFY;
|
||
key_config_update(current_operation);
|
||
}
|
||
break;
|
||
|
||
case ITEM_2:
|
||
{
|
||
if( (tabdata.current_content != INPUT_LOG)&&(tabdata.current_content != OUTPUT_LOG) )
|
||
{
|
||
set_item2_text(tabdata.current_content);
|
||
|
||
//当前操作从“内容选择” 切换 至“内容修改”,按键配置同步更新
|
||
current_operation = SET_CONTENT_MODIFY;
|
||
key_config_update(current_operation);
|
||
}
|
||
else
|
||
{
|
||
if(tabdata.current_content == INPUT_LOG)
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_01, lv_color_hex(COLOR_ITEMS_UNCHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
show_IO_log(IO_INPUT, 1);
|
||
}
|
||
|
||
if(tabdata.current_content == OUTPUT_LOG)
|
||
{
|
||
lv_obj_set_style_bg_color(guider_ui.screen_setting_label_11, lv_color_hex(COLOR_ITEMS_UNCHECKED), LV_PART_MAIN|LV_STATE_DEFAULT);
|
||
show_IO_log(IO_OUTPUT, 1);
|
||
}
|
||
|
||
//当前操作从“内容选择” 切换 至“查看记录”,按键配置同步更新
|
||
current_operation = SET_SHOW_LOG;
|
||
key_config_update(current_operation);
|
||
}
|
||
}
|
||
break;
|
||
|
||
case ITEM_3:
|
||
{
|
||
set_item3_text(tabdata.current_content);
|
||
|
||
//当前操作从“内容选择” 切换 至“内容修改”,按键配置同步更新
|
||
current_operation = SET_CONTENT_MODIFY;
|
||
key_config_update(current_operation);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case KEY_LEFT:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
|
||
switch (current_operation)
|
||
{
|
||
case SET_CONTENT_CHOOSE:
|
||
{
|
||
//不存在焦点时,执行翻页操作
|
||
switch (tabdata.item_cursor)
|
||
{
|
||
case ITEM_0:
|
||
{
|
||
tabdata.item_page_prv = tabdata.item_page;
|
||
tabdata.item_page = ( tabdata.item_page <= 1)?(I0_PAGE_MAX):(tabdata.item_page - 1);
|
||
|
||
setting_items_page(ITEM_0, tabdata.item_page);
|
||
|
||
//翻页后熄灭原本的游标
|
||
setting_contents_check(99, tabdata.content_cursor);
|
||
|
||
//翻页后点亮新的一页的第一个内容
|
||
tabdata.content_cursor = 0;
|
||
tabdata.content_cursor_prv = 99;
|
||
setting_contents_check(tabdata.content_cursor, tabdata.content_cursor_prv);
|
||
}
|
||
break;
|
||
|
||
case ITEM_1:
|
||
{}
|
||
break;
|
||
|
||
case ITEM_2:
|
||
{}
|
||
break;
|
||
|
||
case ITEM_3:
|
||
{}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case SET_CONTENT_MODIFY:
|
||
{
|
||
//存在焦点后,修改内容
|
||
tabdata.current_content = content_cur_char2enum(tabdata.item_cursor, tabdata.content_cursor);
|
||
|
||
setting_contents_modify(tabdata.item_cursor, tabdata.current_content, -1);
|
||
}
|
||
break;
|
||
|
||
case SET_SHOW_LOG:
|
||
{
|
||
//查看记录
|
||
if( tabdata.current_content == INPUT_LOG )
|
||
{
|
||
log_page--;
|
||
if(log_page > 10) log_page = 1;
|
||
if(log_page < 1) log_page = 10;
|
||
|
||
show_IO_log(IO_INPUT, log_page);
|
||
|
||
return;
|
||
}
|
||
|
||
if (tabdata.current_content == OUTPUT_LOG)
|
||
{
|
||
log_page--;
|
||
if(log_page > 10) log_page = 1;
|
||
if(log_page < 1) log_page = 10;
|
||
|
||
show_IO_log(IO_OUTPUT, log_page);
|
||
|
||
return;
|
||
}
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case KEY_RIGHT:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
|
||
switch (current_operation)
|
||
{
|
||
case SET_CONTENT_CHOOSE:
|
||
{
|
||
//翻页
|
||
switch (tabdata.item_cursor)
|
||
{
|
||
case ITEM_0:
|
||
{
|
||
tabdata.item_page_prv = tabdata.item_page;
|
||
tabdata.item_page = ( tabdata.item_page >= I0_PAGE_MAX)?(1):(tabdata.item_page + 1);
|
||
|
||
setting_items_page(ITEM_0, tabdata.item_page);
|
||
|
||
//翻页后熄灭原本的游标
|
||
setting_contents_check(99, tabdata.content_cursor);
|
||
|
||
//翻页后点亮新的一页的第一个内容
|
||
tabdata.content_cursor = 0;
|
||
tabdata.content_cursor_prv = 99;
|
||
setting_contents_check(tabdata.content_cursor, tabdata.content_cursor_prv);
|
||
}
|
||
break;
|
||
|
||
case ITEM_1:
|
||
{}
|
||
break;
|
||
|
||
case ITEM_2:
|
||
{}
|
||
break;
|
||
|
||
case ITEM_3:
|
||
{}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case SET_CONTENT_MODIFY:
|
||
{
|
||
//存在焦点后,修改内容
|
||
tabdata.current_content = content_cur_char2enum(tabdata.item_cursor, tabdata.content_cursor);
|
||
|
||
setting_contents_modify(tabdata.item_cursor, tabdata.current_content, 1);
|
||
}
|
||
break;
|
||
|
||
case SET_SHOW_LOG:
|
||
{
|
||
//查看记录
|
||
if( tabdata.current_content == INPUT_LOG )
|
||
{
|
||
log_page++;
|
||
if(log_page > 10) log_page = 1;
|
||
if(log_page < 1) log_page = 10;
|
||
|
||
show_IO_log(IO_INPUT, log_page);
|
||
|
||
return;
|
||
}
|
||
|
||
if (tabdata.current_content == OUTPUT_LOG)
|
||
{
|
||
log_page++;
|
||
if(log_page > 10) log_page = 1;
|
||
if(log_page < 1) log_page = 10;
|
||
|
||
show_IO_log(IO_OUTPUT, log_page);
|
||
|
||
return;
|
||
}
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case KEY_NONE:
|
||
{
|
||
}
|
||
|
||
default:
|
||
{
|
||
key = 0;
|
||
key_char2struct();
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
|