Files
menu/internal/menu_def.h
2025-12-18 21:24:20 +08:00

69 lines
1.6 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_def.h
* @brief 菜单组件内部宏定义和辅助函数(用户无需关心)
*/
#ifndef MENU_DEF_H
#define MENU_DEF_H
#include "menu_config.h"
#include "menu.h"
#include <stdint.h>
#include <string.h>
/************************** 内部宏定义 **************************/
/**
* @brief 断言宏(工业级:调试时检查,发布时忽略)
*/
#if MENU_CONFIG_ENABLE_ASSERT
#define MENU_ASSERT(condition) \
do { \
if (!(condition)) { \
menu_utils_assert_failed(__FILE__, __LINE__); \
while (1); \
} \
} while (0)
#else
#define MENU_ASSERT(condition) ((void)0)
#endif
/**
* @brief 调试打印宏(工业级:集中控制调试输出)
*/
#if MENU_CONFIG_ENABLE_DEBUG
#define MENU_DEBUG(fmt, ...) menu_utils_printf("[MENU DEBUG] " fmt "\r\n", ##__VA_ARGS__)
#else
#define MENU_DEBUG(fmt, ...) ((void)0)
#endif
/**
* @brief 内存清零宏
*/
#define MENU_MEM_SET_ZERO(ptr, size) memset((ptr), 0, (size))
/**
* @brief 无效ID定义
*/
#define MENU_INVALID_ID ((MenuNodeId)0xFFFF)
/************************** 内部辅助函数声明 **************************/
/**
* @brief 断言失败处理函数
* @param file 文件名
* @param line 行号
*/
void menu_utils_assert_failed(const char* file, uint32_t line);
/**
* @brief 调试打印函数对接port层的硬件打印接口
* @param fmt 格式化字符串
* @param ... 可变参数
*/
void menu_utils_printf(const char* fmt, ...);
/**
* @brief 获取系统滴答时间ms对接port层
* @return 当前滴答时间
*/
uint32_t menu_utils_get_tick(void);
#endif // MENU_DEF_H