更新注释

This commit is contained in:
不吃油炸鸡
2025-12-02 19:40:48 +08:00
parent 037e14c0cc
commit 2f29bd11ed
2 changed files with 4 additions and 5 deletions

View File

@@ -134,6 +134,8 @@ static inline uint8_t read_pressed(GPIO_TypeDef* port, uint16_t pin, uint8_t act
* @brief 扫描一次,若有事件则通过 out_evt 返回
* @param out_evt 指向事件对象的指针(非空)
* @return true 有事件false 无事件
* @note 每次调用仅返回一个事件优先级顺序DOWN/UP -> CLICK -> LONG -> REPEAT,
* @note 返回事件后可以检测掩码查看是否同时按下键用于组合逻辑Key_GetPressedMask();
*/
bool Key_Scan(key_event_t* out_evt)
{
@@ -205,10 +207,7 @@ bool Key_Scan(key_event_t* out_evt)
for(uint8_t i=0; i<KEY_ID_MAX; ++i){
key_slot_t* k = &g_key.slot[i];
if(!k->registered || !k->stable_pressed) continue;
uint32_t bit = KEY_BIT(i);
bool long_allowed = (g_key.long_enable_mask & bit) != 0;
if(!long_allowed) continue;
if(!(g_key.long_enable_mask & KEY_BIT(i))) continue;
uint32_t held = TICK_DIFF(now, k->press_tick);