фикс бага с повторным взводом RisingEdge при отпускании кнопки

This commit is contained in:
2026-06-27 23:20:07 +03:00
parent 206a710b0d
commit 3e3ce74c9a
+15 -17
View File
@@ -1,24 +1,22 @@
#include "../inc/DS_Button.h"
void DS_ButtonInit(DS_Button* Button, GPIO_TypeDef *Port, uint16_t Pin)
{
Button->Port = Port;
Button->Pin = Pin;
Button->Pressed = false;
Button->PressedLong = false;
Button->PressedLongLong = false;
Button->Released = false;
Button->PrevTick = 0;
Button->PressStartTick = 0;
Button->PressStartTickLong = 0;
Button->Storage = 5;
void DS_ButtonInit(DS_Button *Button, GPIO_TypeDef *Port, uint16_t Pin) {
Button->Port = Port;
Button->Pin = Pin;
Button->Pressed = false;
Button->PressedLong = false;
Button->PressedLongLong = false;
Button->Released = false;
Button->PrevTick = 0;
Button->PressStartTick = 0;
Button->PressStartTickLong = 0;
Button->Storage = 5; // Начальное среднее положение для стабилизации
Button->FallingEdge = false;
Button->RisingEdge = false;
Button->FallingEdge = false;
Button->RisingEdge = false;
}
void DS_ButtonUpdate(DS_Button *Button)
{
void DS_ButtonUpdate(DS_Button * Button) {
uint32_t CurrentTick = HAL_GetTick();
if ((CurrentTick - Button->PrevTick) < 10)
return;
@@ -31,7 +29,7 @@ void DS_ButtonUpdate(DS_Button *Button)
{
if (Button->Storage == 0)
Button->Storage +=5;
else if (Button->Storage <= 10)
else if (Button->Storage < 10)
Button->Storage +=1;