35 lines
1.6 KiB
C
35 lines
1.6 KiB
C
/* 本文件由 tools/menu_gen/gen_menu.py 从 ui_menu_tree.txt 自动生成,请勿手改。
|
||
* 修改菜单:编辑 ui_menu_tree.txt 后重跑 `python tools/menu_gen/gen_menu.py`。
|
||
*/
|
||
#ifndef UI_MENU_TAB_H
|
||
#define UI_MENU_TAB_H
|
||
|
||
#include <stdint.h>
|
||
#include <stdbool.h>
|
||
|
||
#define MENU_ROOT 0xFFu /* 根哨兵:仅根节点(主界面)的 parent 取此值;8 位,上限 255 项 */
|
||
|
||
/* 菜单节点:子项 = parent 等于本下标的所有行(按表序);有子项=菜单,无=叶子 */
|
||
typedef struct {
|
||
uint8_t parent; /* 父节点下标(0..254);根为 MENU_ROOT(0xFF) */
|
||
const char *name; /* 显示文本(字面量,存 Flash) */
|
||
} ui_menu_node_t;
|
||
|
||
#define UI_MENU_TAB_COUNT 42
|
||
|
||
/* 护栏:8 位索引上限 255 项(哨兵 0xFF 占用 255);超界则编译失败(C99 写法,兼容 ARMCC v5) */
|
||
typedef char menu_tab_count_check[(UI_MENU_TAB_COUNT <= 255) ? 1 : -1];
|
||
|
||
extern const ui_menu_node_t g_menu_tab[];
|
||
|
||
/*
|
||
* 表查询 API(导航逻辑层 ui_menu.c 与显示层 ui_menu_view.c 共用):
|
||
* 实现随表生成,改菜单(ui_menu_tree.txt)调用方零代码改动。
|
||
*/
|
||
uint8_t ui_menu_tab_children(uint8_t node, uint8_t out[], uint8_t max); /* 取 node 直接子项(按表序),最多 max 个;返回实际个数 */
|
||
bool ui_menu_tab_has_children(uint8_t node); /* 有子项=菜单(带▶);无=叶子 */
|
||
const char *ui_menu_tab_name(uint8_t node); /* 显示名 */
|
||
bool ui_menu_tab_valid(void); /* 启动自检:非根 parent 下标均有效 */
|
||
|
||
#endif
|