feat: 添加第三屏幕及其音量控制功能
- 在 CMakeLists.txt 中添加 ui_Screen3.c 源文件以支持新屏幕 - 新增 ui_events.c 和 ui_events.h,定义音量控制按钮的点击事件处理函数 - 实现 ui_Screen3.c,构建第三屏幕的 UI 组件和事件回调 - 更新 ui.c 以初始化和加载第三屏幕 - 修改 ble_hid.c 和 ble_hid.h,添加消费者控制功能以支持音量调节 - 更新相关头文件,确保新屏幕与现有结构兼容
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
// This file was generated by SquareLine Studio
|
||||
// SquareLine Studio version: SquareLine Studio 1.6.1
|
||||
// LVGL version: 9.2.2
|
||||
// Project name: HeavenlyHeroStar
|
||||
|
||||
#include "../ui.h"
|
||||
|
||||
lv_obj_t * ui_Screen3 = NULL;
|
||||
lv_obj_t * ui_BtnVolDown = NULL;
|
||||
lv_obj_t * ui_BtnVolUp = NULL;
|
||||
lv_obj_t * ui_BtnMute = NULL;
|
||||
lv_obj_t * ui_BtnPlayPause = NULL;
|
||||
lv_obj_t * ui_BtnPrev = NULL;
|
||||
lv_obj_t * ui_BtnNext = NULL;
|
||||
lv_obj_t * ui_LabelVolDown = NULL;
|
||||
lv_obj_t * ui_LabelVolUp = NULL;
|
||||
lv_obj_t * ui_LabelMute = NULL;
|
||||
lv_obj_t * ui_LabelPlayPause = NULL;
|
||||
lv_obj_t * ui_LabelPrev = NULL;
|
||||
lv_obj_t * ui_LabelNext = NULL;
|
||||
|
||||
static void ui_screen3_create_button(lv_obj_t **btn, lv_obj_t **label, int32_t x, int32_t y,
|
||||
const char *text)
|
||||
{
|
||||
*btn = lv_button_create(ui_Screen3);
|
||||
lv_obj_set_width(*btn, 75);
|
||||
lv_obj_set_height(*btn, 90);
|
||||
lv_obj_set_x(*btn, x);
|
||||
lv_obj_set_y(*btn, y);
|
||||
lv_obj_set_align(*btn, LV_ALIGN_CENTER);
|
||||
lv_obj_add_flag(*btn, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
|
||||
lv_obj_remove_flag(*btn, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
*label = lv_label_create(ui_Screen3);
|
||||
lv_obj_set_width(*label, LV_SIZE_CONTENT);
|
||||
lv_obj_set_height(*label, LV_SIZE_CONTENT);
|
||||
lv_obj_set_x(*label, x);
|
||||
lv_obj_set_y(*label, y);
|
||||
lv_obj_set_align(*label, LV_ALIGN_CENTER);
|
||||
lv_label_set_text(*label, text);
|
||||
}
|
||||
|
||||
// event funtions
|
||||
void ui_event_BtnVolDown(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t event_code = lv_event_get_code(e);
|
||||
|
||||
if(event_code == LV_EVENT_CLICKED) {
|
||||
click_consumer_vol_down(e);
|
||||
}
|
||||
}
|
||||
|
||||
void ui_event_BtnVolUp(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t event_code = lv_event_get_code(e);
|
||||
|
||||
if(event_code == LV_EVENT_CLICKED) {
|
||||
click_consumer_vol_up(e);
|
||||
}
|
||||
}
|
||||
|
||||
void ui_event_BtnMute(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t event_code = lv_event_get_code(e);
|
||||
|
||||
if(event_code == LV_EVENT_CLICKED) {
|
||||
click_consumer_mute(e);
|
||||
}
|
||||
}
|
||||
|
||||
void ui_event_BtnPlayPause(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t event_code = lv_event_get_code(e);
|
||||
|
||||
if(event_code == LV_EVENT_CLICKED) {
|
||||
click_consumer_play_pause(e);
|
||||
}
|
||||
}
|
||||
|
||||
void ui_event_BtnPrev(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t event_code = lv_event_get_code(e);
|
||||
|
||||
if(event_code == LV_EVENT_CLICKED) {
|
||||
click_consumer_prev(e);
|
||||
}
|
||||
}
|
||||
|
||||
void ui_event_BtnNext(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t event_code = lv_event_get_code(e);
|
||||
|
||||
if(event_code == LV_EVENT_CLICKED) {
|
||||
click_consumer_next(e);
|
||||
}
|
||||
}
|
||||
|
||||
// build funtions
|
||||
|
||||
void ui_Screen3_screen_init(void)
|
||||
{
|
||||
ui_Screen3 = lv_obj_create(NULL);
|
||||
lv_obj_remove_flag(ui_Screen3, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
ui_screen3_create_button(&ui_BtnVolDown, &ui_LabelVolDown, -42, -107, "Vol-");
|
||||
ui_screen3_create_button(&ui_BtnVolUp, &ui_LabelVolUp, 42, -107, "Vol+");
|
||||
ui_screen3_create_button(&ui_BtnMute, &ui_LabelMute, -42, 0, "Mute");
|
||||
ui_screen3_create_button(&ui_BtnPlayPause, &ui_LabelPlayPause, 42, 0, "Play");
|
||||
ui_screen3_create_button(&ui_BtnPrev, &ui_LabelPrev, -42, 107, "Prev");
|
||||
ui_screen3_create_button(&ui_BtnNext, &ui_LabelNext, 42, 107, "Next");
|
||||
|
||||
lv_obj_add_event_cb(ui_BtnVolDown, ui_event_BtnVolDown, LV_EVENT_ALL, NULL);
|
||||
lv_obj_add_event_cb(ui_BtnVolUp, ui_event_BtnVolUp, LV_EVENT_ALL, NULL);
|
||||
lv_obj_add_event_cb(ui_BtnMute, ui_event_BtnMute, LV_EVENT_ALL, NULL);
|
||||
lv_obj_add_event_cb(ui_BtnPlayPause, ui_event_BtnPlayPause, LV_EVENT_ALL, NULL);
|
||||
lv_obj_add_event_cb(ui_BtnPrev, ui_event_BtnPrev, LV_EVENT_ALL, NULL);
|
||||
lv_obj_add_event_cb(ui_BtnNext, ui_event_BtnNext, LV_EVENT_ALL, NULL);
|
||||
}
|
||||
|
||||
void ui_Screen3_screen_destroy(void)
|
||||
{
|
||||
if(ui_Screen3) lv_obj_del(ui_Screen3);
|
||||
|
||||
ui_Screen3 = NULL;
|
||||
ui_BtnVolDown = NULL;
|
||||
ui_BtnVolUp = NULL;
|
||||
ui_BtnMute = NULL;
|
||||
ui_BtnPlayPause = NULL;
|
||||
ui_BtnPrev = NULL;
|
||||
ui_BtnNext = NULL;
|
||||
ui_LabelVolDown = NULL;
|
||||
ui_LabelVolUp = NULL;
|
||||
ui_LabelMute = NULL;
|
||||
ui_LabelPlayPause = NULL;
|
||||
ui_LabelPrev = NULL;
|
||||
ui_LabelNext = NULL;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// This file was generated by SquareLine Studio
|
||||
// SquareLine Studio version: SquareLine Studio 1.6.1
|
||||
// LVGL version: 9.2.2
|
||||
// Project name: HeavenlyHeroStar
|
||||
|
||||
#ifndef UI_SCREEN3_H
|
||||
#define UI_SCREEN3_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// SCREEN: ui_Screen3
|
||||
extern void ui_Screen3_screen_init(void);
|
||||
extern void ui_Screen3_screen_destroy(void);
|
||||
extern lv_obj_t * ui_Screen3;
|
||||
extern void ui_event_BtnVolDown(lv_event_t * e);
|
||||
extern lv_obj_t * ui_BtnVolDown;
|
||||
extern void ui_event_BtnVolUp(lv_event_t * e);
|
||||
extern lv_obj_t * ui_BtnVolUp;
|
||||
extern void ui_event_BtnMute(lv_event_t * e);
|
||||
extern lv_obj_t * ui_BtnMute;
|
||||
extern void ui_event_BtnPlayPause(lv_event_t * e);
|
||||
extern lv_obj_t * ui_BtnPlayPause;
|
||||
extern void ui_event_BtnPrev(lv_event_t * e);
|
||||
extern lv_obj_t * ui_BtnPrev;
|
||||
extern void ui_event_BtnNext(lv_event_t * e);
|
||||
extern lv_obj_t * ui_BtnNext;
|
||||
extern lv_obj_t * ui_LabelVolDown;
|
||||
extern lv_obj_t * ui_LabelVolUp;
|
||||
extern lv_obj_t * ui_LabelMute;
|
||||
extern lv_obj_t * ui_LabelPlayPause;
|
||||
extern lv_obj_t * ui_LabelPrev;
|
||||
extern lv_obj_t * ui_LabelNext;
|
||||
// CUSTOM VARIABLES
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user