Dev #2

Merged
Mikhail merged 2 commits from Dev into main 2026-06-27 16:21:17 -04:00
Showing only changes of commit 3e3ce74c9a - Show all commits
+4 -6
View File
@@ -1,7 +1,6 @@
#include "../inc/DS_Button.h" #include "../inc/DS_Button.h"
void DS_ButtonInit(DS_Button* Button, GPIO_TypeDef *Port, uint16_t Pin) void DS_ButtonInit(DS_Button *Button, GPIO_TypeDef *Port, uint16_t Pin) {
{
Button->Port = Port; Button->Port = Port;
Button->Pin = Pin; Button->Pin = Pin;
Button->Pressed = false; Button->Pressed = false;
@@ -11,14 +10,13 @@ void DS_ButtonInit(DS_Button* Button, GPIO_TypeDef *Port, uint16_t Pin)
Button->PrevTick = 0; Button->PrevTick = 0;
Button->PressStartTick = 0; Button->PressStartTick = 0;
Button->PressStartTickLong = 0; Button->PressStartTickLong = 0;
Button->Storage = 5; Button->Storage = 5; // Начальное среднее положение для стабилизации
Button->FallingEdge = false; Button->FallingEdge = false;
Button->RisingEdge = false; Button->RisingEdge = false;
} }
void DS_ButtonUpdate(DS_Button *Button) void DS_ButtonUpdate(DS_Button * Button) {
{
uint32_t CurrentTick = HAL_GetTick(); uint32_t CurrentTick = HAL_GetTick();
if ((CurrentTick - Button->PrevTick) < 10) if ((CurrentTick - Button->PrevTick) < 10)
return; return;
@@ -31,7 +29,7 @@ void DS_ButtonUpdate(DS_Button *Button)
{ {
if (Button->Storage == 0) if (Button->Storage == 0)
Button->Storage +=5; Button->Storage +=5;
else if (Button->Storage <= 10) else if (Button->Storage < 10)
Button->Storage +=1; Button->Storage +=1;