We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
void Button_Cycle_Process(Button_t *btn) { uint8_t current_level = (uint8_t)btn->Read_Button_Level();//获取当前按键电平 if((current_level != btn->Button_Last_Level)&&(++(btn->Debounce_Time) >= BUTTON_DEBOUNCE_TIME)) //按键电平发生变化,消抖 { btn->Button_Last_Level = current_level; //更新当前按键电平 btn->Debounce_Time = 0; //确定了是按下 ...... } ...... }
btn->Debounce_Time仅在if内清零,如果发生多次抖动,btn->Debounce_Time依然会累加,并最终被认为是一次有效按键。应该修改为:
void Button_Cycle_Process(Button_t *btn) { uint8_t current_level = (uint8_t)btn->Read_Button_Level();//获取当前按键电平 if((current_level != btn->Button_Last_Level)&&(++(btn->Debounce_Time) >= BUTTON_DEBOUNCE_TIME)) //按键电平发生变化,消抖 { btn->Button_Last_Level = current_level; //更新当前按键电平 btn->Debounce_Time = 0; //确定了是按下 ...... } else if(current_level == btn->Button_Last_Level) { btn->Debounce_Time = 0; } ...... }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
btn->Debounce_Time仅在if内清零,如果发生多次抖动,btn->Debounce_Time依然会累加,并最终被认为是一次有效按键。应该修改为:
The text was updated successfully, but these errors were encountered: