UI 生成文件按工程约定产出:生成器补文件头、K&R 大括号与版本守卫压平

- gen_menu.py:ui_menu_tab.h/.c 输出工程标准文件头,5 个函数定义改 K&R 大括号
- make_font.py:新增 normalize_project_conventions 后处理——工程文件头
  (替换内嵌绝对路径的 lv_font_conv 头注释)、包含收敛为 #include "lvgl.h"、
  LVGL 9.3.0 版本守卫静态压平(含守卫宏定义清理)
- 重生成 ui_font_cn_12.c / ui_menu_tab.c / ui_menu_tab.h:仅头部/大括号/守卫
  行变化,字形数据与菜单表逐字节不变
- 两文件随之满足规范检查,pre-commit 中无需再排除(配合上一提交生效)

验证:pre-commit 全钩子通过、模拟器 0 警、菜单/内容页像素回归 PASS、Keil 0 错 0 警
This commit is contained in:
2026-09-13 19:38:30 +08:00
parent 34528a9798
commit 508577bbf0
5 changed files with 237 additions and 66 deletions
+15 -12
View File
@@ -1,5 +1,13 @@
/* 本文件由 tools/menu_gen/gen_menu.py 从 ui_menu_tree.txt 自动生成,请勿手改。
* 修改菜单:编辑 ui_menu_tree.txt 后重跑 `python tools/menu_gen/gen_menu.py`。
/*
* 模块名称:UI 菜单节点表(自动生成)
* 模块功能:菜单节点扁平父子索引表 + 5 个表查询 API(导航逻辑层与显示层共用)
* 适用平台:STM32F407ZGTx / PC 模拟器(共用源码)
* 作者:王建锋
* 创建日期:2026-09-07
* 修改记录:
* 2026-09-13 王建锋 工程约定规范化(文件头 / K&R 大括号),内容由生成器自动更新
* 自动生成:本文件由 tools/menu_gen/gen_menu.py 从 ui_menu_tree.txt 自动生成,请勿手改。
* 修改菜单:编辑 ui_menu_tree.txt 后重跑 `python tools/menu_gen/gen_menu.py`。
*/
#include "ui_menu_tab.h"
@@ -57,8 +65,7 @@ const ui_menu_node_t g_menu_tab[UI_MENU_TAB_COUNT] = {
* 限定条件:node < UI_MENU_TAB_COUNT
* 函数说明:子项 = 表中所有 parent == 本下标的行(表序即显示序);建页核心查询
*/
uint8_t ui_menu_tab_children(uint8_t node, uint8_t out[], uint8_t max)
{
uint8_t ui_menu_tab_children(uint8_t node, uint8_t out[], uint8_t max) {
uint8_t n = 0u;
for (uint8_t i = 0u; i < UI_MENU_TAB_COUNT && n < max; i++) {
if (g_menu_tab[i].parent == node) {
@@ -75,8 +82,7 @@ uint8_t ui_menu_tab_children(uint8_t node, uint8_t out[], uint8_t max)
* 限定条件:node < UI_MENU_TAB_COUNT
* 函数说明:菜单/叶子由"是否有子项"自动推导,无单独类型字段
*/
bool ui_menu_tab_has_children(uint8_t node)
{
bool ui_menu_tab_has_children(uint8_t node) {
for (uint8_t i = 0u; i < UI_MENU_TAB_COUNT; i++) {
if (g_menu_tab[i].parent == node) {
return true;
@@ -92,8 +98,7 @@ bool ui_menu_tab_has_children(uint8_t node)
* 限定条件:node < UI_MENU_TAB_COUNT
* 函数说明:行文本一律经此取静态字符串,不 strdup
*/
const char *ui_menu_tab_name(uint8_t node)
{
const char *ui_menu_tab_name(uint8_t node) {
return g_menu_tab[node].name;
}
@@ -104,8 +109,7 @@ const char *ui_menu_tab_name(uint8_t node)
* 限定条件:无
* 说明:表 pwd 列取自源 ui_menu_tree.txt 行尾 #P 注记;导航逻辑层据此决定是否先经密码页
*/
bool ui_menu_tab_has_pwd(uint8_t node)
{
bool ui_menu_tab_has_pwd(uint8_t node) {
return (g_menu_tab[node].pwd != 0u);
}
@@ -116,8 +120,7 @@ bool ui_menu_tab_has_pwd(uint8_t node)
* 限定条件:无
* 函数说明:每个非根节点的 parent 必须为 MENU_ROOT 或有效下标;在 ui_menu_init 调用
*/
bool ui_menu_tab_valid(void)
{
bool ui_menu_tab_valid(void) {
for (uint8_t i = 0u; i < UI_MENU_TAB_COUNT; i++) {
if (i == 0u) {
continue; /* 根 */