Boen_Shi 8be2866433 feat(base): 初始化 MSPM0 开发环境
- 添加头文件和配置文件支持
- 更新.gitignore忽略编译和IDE相关文件
- 添加基础的bsp代码
2026-07-16 14:45:26 +08:00

45 lines
1.3 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.

#ifndef MENU_PAINT_H_
#define MENU_PAINT_H_
#include <stdint.h>
class MenuPaint {
public:
enum MenuType {
MENU_TYPE_FOLDER,
MENU_TYPE_SWITCH,
MENU_TYPE_INFO
};
struct Menu {
const char *name;
MenuType type;
const Menu *subMenus;
uint8_t subMenuCount;
uint8_t switchId; // 新增字段开关ID (仅在type为SWITCH时有效)
};
static void Init(); // 初始化菜单
static void Paint(); // 渲染菜单
static void ScrollUp(); // 向上移动
static void ScrollDown(); // 向下移动
static void Enter(); // 进入子菜单/切换开关
static void Exit(); // 返回上级菜单
static bool GetSwitchState(uint8_t switchId); // 新增接口:获取开关状态
private:
static const Menu *currentMenu; // 当前菜单指针
static uint8_t currentMenuSize; // 当前菜单项数量
static int8_t selectIndex; // 当前选中项索引
static int8_t scrollOffset; // 滚动偏移
static bool switchStates[20]; // 开关状态按switchId匹配
static const Menu *menuStack[5]; // 菜单返回栈
static uint8_t stackIndex;
static void RenderItem(int y, const char *text, bool selected, bool checked);
};
#endif // MENU_PAINT_H_