在初始化时结构体中的button_level变量直接由读取电平接口赋值,可能会导致上电瞬间误读电平,从而导致误触发事件

This commit is contained in:
pony 2024-01-24 23:12:04 +08:00
parent 6bd1c6a451
commit 31ff772aaf

View File

@ -26,7 +26,7 @@ void button_init(struct Button* handle, uint8_t(*pin_level)(uint8_t), uint8_t ac
memset(handle, 0, sizeof(struct Button));
handle->event = (uint8_t)NONE_PRESS;
handle->hal_button_Level = pin_level;
handle->button_level = handle->hal_button_Level(button_id);
handle->button_level = !active_level;
handle->active_level = active_level;
handle->button_id = button_id;
}