Files
STM32F4-Base/Drivers/BSP/UI/ui_menu_tab.c
T
wandering1 515db819ab feat(ui): fold board inputs and outputs into the telemetry page
The 12 board-level rows now live at the end of the 遥信量 page instead of
a separate 开入开出 page: 8 opto inputs (DI_A..DI_H) and 4 relay outputs
(KO6/TRIP/ERT/CLZ). 33 rows become 45, five pages become six. The
standalone page, its menu entry, its golden references and both build
registrations are removed.

Folding the display is not folding the point table. The board rows
render from dio_di_* / dio_do_* and stay out of yx_bits / yx_valid /
yx_dp: any change to those carriers is provably absent from this diff.
IEC 104 mapping and YX_VALID_MASK are untouched, so nothing new is
reported to a master station.

Input polarity was wrong and is fixed here. On this board a 24 V input
drives the opto, which pulls the 74HC165 pin LOW, so the raw mask is
inverted relative to "has signal". The bit assembly only reordered bits;
nothing converted the level. The screen showed 分 on every channel no
matter what the operator drove in. Polarity now converts once, in the
driver, behind IOBOARD_DI_LEVEL_ACTIVE (0 = active low), so callers see
1 = has signal for both inputs and outputs.

Verified on the board: page 5 shows YX33 followed immediately by DI_A,
crossing the 33-point boundary with no drift; DI_C reads 合 because the
operator's signal is on channel C, the other seven read 分; page 6 shows
DI_H then all four outputs 释放. Page rows end at y=134, the footer
starts at y=144.

Input bit order is only partly verified: channel C was confirmed against
a real signal, the other seven have not been exercised channel by
channel. The board detects the presence of 24 V, not contact closure,
and the output rows show the shadow register (our intent) rather than
mechanical contact feedback. All three limits are recorded in the page
header and in the IOBOARD README.

Also adds a polarity guard to the host tests: the input polarity was
flipped once already, and until now no assertion would have caught a
silent re-flip, since only the DO side was pinned.
2026-11-16 23:30:35 +08:00

139 lines
6.0 KiB
C

/*
* 模块名称: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"
const ui_menu_node_t g_menu_tab[UI_MENU_TAB_COUNT] = {
{ MENU_ROOT, 0u, "主界面" }, /* 0 主界面 */
{ 0, 0u, "装置信息" }, /* 1 一级菜单 */
{ 0, 0u, "实时数据" }, /* 2 一级菜单 */
{ 2, 0u, "交流量" }, /* 3 二级菜单 */
{ 2, 0u, "直流量" }, /* 4 二级菜单 */
{ 2, 0u, "遥信量" }, /* 5 二级菜单 */
{ 0, 0u, "参数定值" }, /* 6 一级菜单 */
{ 6, 0u, "整定" }, /* 7 二级菜单 */
{ 7, 1u, "参数" }, /* 8 三级菜单 */
{ 7, 1u, "定值" }, /* 9 三级菜单 */
{ 7, 1u, "控制字" }, /* 10 三级菜单 */
{ 7, 1u, "软压板" }, /* 11 三级菜单 */
{ 6, 0u, "查看" }, /* 12 二级菜单 */
{ 12, 0u, "参数" }, /* 13 三级菜单 */
{ 12, 0u, "定值" }, /* 14 三级菜单 */
{ 12, 0u, "控制字" }, /* 15 三级菜单 */
{ 12, 0u, "软压板" }, /* 16 三级菜单 */
{ 0, 0u, "三遥设置" }, /* 17 一级菜单 */
{ 17, 1u, "遥测死区" }, /* 18 二级菜单 */
{ 17, 1u, "遥测系数" }, /* 19 二级菜单 */
{ 17, 1u, "遥信类型" }, /* 20 二级菜单 */
{ 17, 1u, "遥信防抖" }, /* 21 二级菜单 */
{ 17, 1u, "双点遥信" }, /* 22 二级菜单 */
{ 0, 0u, "装置维护" }, /* 23 一级菜单 */
{ 23, 1u, "时钟设置" }, /* 24 二级菜单 */
{ 23, 1u, "强制复归" }, /* 25 二级菜单 */
{ 23, 1u, "手动录波" }, /* 26 二级菜单 */
{ 23, 1u, "清除记录" }, /* 27 二级菜单 */
{ 0, 0u, "通讯参数" }, /* 28 一级菜单 */
{ 28, 1u, "通讯设置" }, /* 29 二级菜单 */
{ 28, 1u, "网口设置" }, /* 30 二级菜单 */
{ 28, 1u, "SNTP设置" }, /* 31 二级菜单 */
{ 0, 0u, "记录查询" }, /* 32 一级菜单 */
{ 32, 0u, "SOE记录" }, /* 33 二级菜单 */
{ 32, 0u, "事故记录" }, /* 34 二级菜单 */
{ 32, 0u, "操作记录" }, /* 35 二级菜单 */
{ 32, 0u, "保护告警" }, /* 36 二级菜单 */
{ 32, 0u, "保护启动" }, /* 37 二级菜单 */
{ 32, 0u, "遥控记录" }, /* 38 二级菜单 */
{ 32, 0u, "自检记录" }, /* 39 二级菜单 */
{ 32, 0u, "运行记录" }, /* 40 二级菜单 */
{ 32, 0u, "运行报告" }, /* 41 二级菜单 */
{ 32, 0u, "录波回放" }, /* 42 二级菜单 */
};
/*
* 函数功能:取 node 的直接子项(按表序),最多 max 个
* 入口参数:node - 节点下标 uint8_t
* out - 子节点下标输出缓冲 uint8_t *
* max - 缓冲容量 uint8_t
* 返回值:实际子项个数 uint8_t
* 限定条件:node < UI_MENU_TAB_COUNT
* 函数说明:子项 = 表中所有 parent == 本下标的行(表序即显示序);建页核心查询
*/
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) {
out[n++] = i;
}
}
return n;
}
/*
* 函数功能:判断 node 有无子项
* 入口参数:node - 节点下标 uint8_t
* 返回值:有子项返回 true(=菜单、行带▶);无子项返回 false(=叶子)
* 限定条件:node < UI_MENU_TAB_COUNT
* 函数说明:菜单/叶子由"是否有子项"自动推导,无单独类型字段
*/
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;
}
}
return false;
}
/*
* 函数功能:取节点显示名
* 入口参数:node - 节点下标 uint8_t
* 返回值:显示文本(Flash 字面量) const char *
* 限定条件:node < UI_MENU_TAB_COUNT
* 函数说明:行文本一律经此取静态字符串,不 strdup
*/
const char *ui_menu_tab_name(uint8_t node) {
return g_menu_tab[node].name;
}
/*
* 函数功能:判断节点是否需密码(叶子密码保护)
* 入口参数:node - 节点下标 uint8_t
* 返回值:true - 需密码页(按所输密码授权查看/修改权限);false - 直接进(只读)
* 限定条件:无
* 说明:表 pwd 列取自源 ui_menu_tree.txt 行尾 #P 注记;导航逻辑层据此决定是否先经密码页
*/
bool ui_menu_tab_has_pwd(uint8_t node) {
return (g_menu_tab[node].pwd != 0u);
}
/*
* 函数功能:菜单表启动自检
* 入口参数:无
* 返回值:true - 表有效;false - 存在越界 parent(表内笔误)
* 限定条件:无
* 函数说明:每个非根节点的 parent 必须为 MENU_ROOT 或有效下标;在 ui_menu_init 调用
*/
bool ui_menu_tab_valid(void) {
for (uint8_t i = 0u; i < UI_MENU_TAB_COUNT; i++) {
if (i == 0u) {
continue; /* 根 */
}
uint8_t p = g_menu_tab[i].parent;
if (p != MENU_ROOT && p >= UI_MENU_TAB_COUNT) {
return false;
}
if (g_menu_tab[i].pwd > 1u) {
return false; /* pwd 只取 0/1(行尾注记笔误捕获) */
}
}
return true;
}