#ifndef MENU_PAINT_H_ #define MENU_PAINT_H_ #include 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_