From 3e3ce74c9a72c3cd8874d92e9c2b691beb787e0e Mon Sep 17 00:00:00 2001 From: Mikhail Date: Sat, 27 Jun 2026 23:20:07 +0300 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=20=D0=B1=D0=B0=D0=B3?= =?UTF-8?q?=D0=B0=20=D1=81=20=D0=BF=D0=BE=D0=B2=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D1=8B=D0=BC=20=D0=B2=D0=B7=D0=B2=D0=BE=D0=B4=D0=BE=D0=BC=20Ris?= =?UTF-8?q?ingEdge=20=D0=BF=D1=80=D0=B8=20=D0=BE=D1=82=D0=BF=D1=83=D1=81?= =?UTF-8?q?=D0=BA=D0=B0=D0=BD=D0=B8=D0=B8=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/DS_Button.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/Src/DS_Button.c b/Src/DS_Button.c index 395dc37..9180b23 100644 --- a/Src/DS_Button.c +++ b/Src/DS_Button.c @@ -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; - - Button->FallingEdge = false; - Button->RisingEdge = false; +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; } -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;