Files
menu/internal/menu_data.h
2025-12-18 22:24:25 +08:00

72 lines
2.1 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.

/**
* @file menu_data.h
* @brief 菜单组件共享全局变量(用户无需关心,内部仅通过接口访问)
*/
#ifndef MENU_DATA_H
#define MENU_DATA_H
#include "menu_core.h"
#include "menu_modbus.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
/**
* @brief Modbus映射上下文启用Modbus映射时有效全局
*/
#if MENU_CONFIG_ENABLE_MODBUS_MAP
extern ModbusMapInternal s_menu_modbus_maps[MENU_CONFIG_MAX_MODBUS_MAPS];
#endif // MENU_CONFIG_ENABLE_MODBUS_MAP
#endif // MENU_DATA_H