增加modbus绑定

This commit is contained in:
冯佳
2025-12-18 22:24:25 +08:00
parent 9773cb5a0a
commit e5eaf2172f
13 changed files with 1443 additions and 216 deletions

View File

@ -105,4 +105,6 @@ MenuErrCode menu_core_handle_event(const MenuEvent* event);
*/
void menu_core_refresh_display(void);
#endif // MENU_CORE_H

View File

@ -6,6 +6,7 @@
#define MENU_DATA_H
#include "menu_core.h"
#include "menu_modbus.h"
/************************** 共享全局变量(声明,内部可见) **************************/
/**
@ -61,4 +62,11 @@ extern MenuLangStr s_menu_lang_strs[MENU_CONFIG_MAX_NODES * MENU_CONFIG_MAX_LANG
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

23
internal/menu_modbus.h Normal file
View File

@ -0,0 +1,23 @@
/**
* @file menu_modbus.h
* @brief 菜单Modbus映射内部头文件用户无需关心
* @note 工业级嵌入式菜单组件 - Modbus映射内部定义
*/
#ifndef MENU_MODBUS_H
#define MENU_MODBUS_H
#include "menu.h"
#include "menu_def.h"
/************************** 内部类型定义 **************************/
/**
* @brief Modbus映射内部结构体扩展对外结构体增加内部状态
*/
typedef struct {
ModbusMap pub; ///< 对外暴露的映射信息(只读)
MenuParamType param_type; ///< 参数类型(缓存,避免重复查找)
uint16_t reg_addr_offset; ///< 寄存器偏移地址(转换后的实际偏移)
bool is_registered; ///< 是否已注册
} ModbusMapInternal;
#endif // MENU_MODBUS_H