Initial commit - sync AliceRC to Gitea
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* @file menu.c
|
||||
* @brief Menu system implementation
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "menu.h"
|
||||
|
||||
/* Menu item callbacks - forward declarations */
|
||||
static void menu_cb_model(void);
|
||||
static void menu_cb_rf(void);
|
||||
static void menu_cb_channel(void);
|
||||
static void menu_cb_mixer(void);
|
||||
static void menu_cb_usb(void);
|
||||
static void menu_cb_audio(void);
|
||||
static void menu_cb_other(void);
|
||||
|
||||
/* Sub-menu definitions */
|
||||
|
||||
static const menu_item_t menu_items_main[] = {
|
||||
{"模型选择", menu_cb_model, NULL},
|
||||
{"高频头配置", menu_cb_rf, NULL},
|
||||
{"通道映射", menu_cb_channel, NULL},
|
||||
{"混控设置", menu_cb_mixer, NULL},
|
||||
{"USB设置", menu_cb_usb, NULL},
|
||||
{"音频配置", menu_cb_audio, NULL},
|
||||
{"其他", menu_cb_other, NULL},
|
||||
{"返回", menu_back, NULL},
|
||||
};
|
||||
|
||||
static menu_t menu_main = {
|
||||
.title = "主菜单",
|
||||
.items = menu_items_main,
|
||||
.item_count = 8,
|
||||
.current = 0,
|
||||
};
|
||||
|
||||
/* Menu stack for navigation */
|
||||
#define MENU_STACK_DEPTH 8
|
||||
static menu_t *menu_stack[MENU_STACK_DEPTH];
|
||||
static uint8_t menu_stack_depth = 0;
|
||||
|
||||
static menu_t *current_menu = &menu_main;
|
||||
|
||||
void menu_init(void)
|
||||
{
|
||||
current_menu = &menu_main;
|
||||
current_menu->current = 0;
|
||||
menu_stack_depth = 0;
|
||||
}
|
||||
|
||||
void menu_up(void)
|
||||
{
|
||||
if (current_menu->current > 0) {
|
||||
current_menu->current--;
|
||||
}
|
||||
}
|
||||
|
||||
void menu_down(void)
|
||||
{
|
||||
if (current_menu->current < current_menu->item_count - 1) {
|
||||
current_menu->current++;
|
||||
}
|
||||
}
|
||||
|
||||
void menu_select(void)
|
||||
{
|
||||
const menu_item_t *item = ¤t_menu->items[current_menu->current];
|
||||
|
||||
if (item->submenu) {
|
||||
/* Push to sub-menu */
|
||||
if (menu_stack_depth < MENU_STACK_DEPTH) {
|
||||
menu_stack[menu_stack_depth++] = current_menu;
|
||||
}
|
||||
current_menu = item->submenu;
|
||||
current_menu->current = 0;
|
||||
} else if (item->callback) {
|
||||
item->callback();
|
||||
}
|
||||
}
|
||||
|
||||
void menu_back(void)
|
||||
{
|
||||
if (menu_stack_depth > 0) {
|
||||
current_menu = menu_stack[--menu_stack_depth];
|
||||
}
|
||||
}
|
||||
|
||||
const menu_t* menu_get_current(void)
|
||||
{
|
||||
return current_menu;
|
||||
}
|
||||
|
||||
const char* menu_get_current_item_name(void)
|
||||
{
|
||||
return current_menu->items[current_menu->current].name;
|
||||
}
|
||||
|
||||
void menu_draw(void)
|
||||
{
|
||||
/* TODO: Implement OLED drawing */
|
||||
/* Will display:
|
||||
- Top bar: menu title
|
||||
- Up to 5 visible items with cursor indicator
|
||||
- Scroll indicator if more items
|
||||
*/
|
||||
}
|
||||
|
||||
/* Callback stubs */
|
||||
static void menu_cb_model(void) { }
|
||||
static void menu_cb_rf(void) { }
|
||||
static void menu_cb_channel(void) { }
|
||||
static void menu_cb_mixer(void) { }
|
||||
static void menu_cb_usb(void) { }
|
||||
static void menu_cb_audio(void) { }
|
||||
static void menu_cb_other(void) { }
|
||||
Reference in New Issue
Block a user