case KEY_CODE_UP: next_index = index > SET_ID_VOLUME ? (index - 1) : (SET_ID_VOICE_ASSISTANT_SWITCH); next_list = lv_obj_get_child(p_setting_win, next_index); next_bg = lv_obj_get_child(next_list,0); ws01_setting_list_group[next_index].selected = true; ws01_setting_list_group[index].selected = false; lv_obj_remove_style(list, &style_btn_focus, 0); lv_obj_set_style_bg_color(bg, lv_color_hex(0x2e3033), 0); lv_obj_add_style(next_list, &style_btn_focus, 0); lv_obj_set_style_bg_color(next_bg, lv_color_hex(0x558dff), 0); lv_obj_scroll_to_view(next_list, LV_ANIM_OFF); break; case KEY_CODE_DOWN: next_index = index < SET_ID_VOICE_ASSISTANT_SWITCH ? (index + 1) : (SET_ID_VOLUME); next_list = lv_obj_get_child(p_setting_win, next_index); next_bg = lv_obj_get_child(next_list,0); ws01_setting_list_group[next_index].selected = true; ws01_setting_list_group[index].selected = false; lv_obj_remove_style(list, &style_btn_focus, 0); lv_obj_set_style_bg_color(bg, lv_color_hex(0x2e3033), 0); lv_obj_add_style(next_list, &style_btn_focus, 0); lv_obj_set_style_bg_color(next_bg, lv_color_hex(0x558dff), 0); lv_obj_scroll_to_view(next_list, LV_ANIM_OFF); break;
时间: 2024-04-26 13:26:27 浏览: 202
SVM案例.rar_9K4_SVM_SVM:Case study_throatr78
这段代码是用来处理按键操作的。KEY_CODE_UP 表示上移按键,KEY_CODE_DOWN 表示下移按键。当按下上移按键时,会选择上一个选项,当按下下移按键时,会选择下一个选项。同时,还会修改选项的背景颜色,以表示当前选中的选项。其中,lv_obj_get_child 函数用来获取指定对象的指定子对象,lv_obj_remove_style 函数用来移除指定对象的指定样式,lv_obj_add_style 函数用来添加指定对象的指定样式,lv_obj_set_style_bg_color 函数用来设置指定对象的背景颜色,lv_obj_scroll_to_view 函数用来滚动对象到可见区域。
阅读全文