Files
STM32F4-Base/Drivers/BSP/UI/ui_menu_tab.h
T
2026-09-10 11:36:33 +08:00

38 lines
2.0 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* 本文件由 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 等于本下标的所有行(按表序);有子项=菜单,无=叶子 */
/* 字段序 parent/pwd 在前:32 位下两项 8 位合并 + 4 位指针 = 8 B/项 */
typedef struct {
uint8_t parent; /* 父节点下标(0..254);根为 MENU_ROOT(0xFF) */
uint8_t pwd; /* 1 = 需密码(密码页按所输密码授权);0 = 直接进(只读) */
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_has_pwd(uint8_t node); /* 需密码(密码页按所输密码授权);false = 直接进(只读) */
bool ui_menu_tab_valid(void); /* 启动自检:非根 parent 下标均有效、pwd 为 0/1 */
#endif