Conversation
Why: 原设计将内部状态机状态(bits_btn_state_t)直接暴露给用户, 导致 API 边界不清晰,且测试代码使用魔法数字访问内部状态, 一旦内部实现变更容易引发问题。 What: as follows: 1. 将 bits_btn_state_t 枚举移至 bits_button.c 内部,不再对外暴露; 2. 在 bits_button.h 中新增 bits_btn_event_t 用户事件枚举: - BTN_EVENT_PRESSED (1): 按键按下(消抖后) - BTN_EVENT_LONG_PRESS (2): 长按检测或保持中 - BTN_EVENT_RELEASE (3): 按键释放 - BTN_EVENT_FINISH (5): 按键序列完成(时间窗口结束后) 3. 新增 state_to_event() 内部映射函数,添加显式类型转换以支持 C++ 编译; 4. 更新所有测试文件,将 BTN_STATE_xxx 替换为 BTN_EVENT_xxx; 5. 将 test_combo_button_reset 改写为黑盒测试,通过正常按键操作验证 重置功能,消除对内部状态的直接访问; 6. 更新 C++ 兼容性测试,使用 bits_btn_event_t 替代原有类型; 7. 更新 API 文档及使用指南,同步事件枚举说明 TEST: 48 Tests 0 Failures 0 Ignored - C++ 兼容性测试: 全部通过
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: 原设计将内部状态机状态(bits_btn_state_t)直接暴露给用户,
导致 API 边界不清晰,且测试代码使用魔法数字访问内部状态,
一旦内部实现变更容易引发问题。
What: as follows:
TEST: 48 Tests 0 Failures 0 Ignored