初始化版本

This commit is contained in:
冯佳
2025-12-18 21:24:08 +08:00
parent 7e8a6d1ce3
commit 9773cb5a0a
15 changed files with 4355 additions and 0 deletions

64
internal/menu_data.h Normal file
View File

@ -0,0 +1,64 @@
/**
* @file menu_data.h
* @brief 菜单组件共享全局变量(用户无需关心,内部仅通过接口访问)
*/
#ifndef MENU_DATA_H
#define MENU_DATA_H
#include "menu_core.h"
/************************** 共享全局变量(声明,内部可见) **************************/
/**
* @brief 菜单核心上下文(全局,仅内部访问)
*/
extern MenuCoreCtx s_menu_core_ctx;
/**
* @brief 参数管理上下文(启用参数时有效,全局)
*/
#if MENU_CONFIG_ENABLE_PARAM
typedef struct {
uint16_t id; ///< 参数ID
MenuParamType type; ///< 参数类型
float min_val; ///< 最小值
float max_val; ///< 最大值
float scale; ///< 缩放因子
union { ///< 共用体:减少内存占用
int8_t i8;
uint8_t u8;
int16_t i16;
uint16_t u16;
int32_t i32;
uint32_t u32;
float f;
} value; ///< 当前值
union { ///< 默认值
int8_t i8;
uint8_t u8;
int16_t i16;
uint16_t u16;
int32_t i32;
uint32_t u32;
float f;
} default_val;
bool is_registered; ///< 是否已注册
} MenuParam;
extern MenuParam s_menu_params[MENU_CONFIG_MAX_PARAMS];
#endif // MENU_CONFIG_ENABLE_PARAM
/**
* @brief 多语言上下文(启用多语言时有效,全局)
*/
#if MENU_CONFIG_ENABLE_LANG
typedef struct {
const char* str; ///< 语言字符串
uint16_t str_id; ///< 字符串ID
uint8_t lang_id; ///< 语言ID
} MenuLangStr;
extern MenuLangStr s_menu_lang_strs[MENU_CONFIG_MAX_NODES * MENU_CONFIG_MAX_LANGS];
extern uint8_t s_current_lang_id;
#endif // MENU_CONFIG_ENABLE_LANG
#endif // MENU_DATA_H