фикс бага с повторным взводом RisingEdge при отпускании кнопки
This commit is contained in:
+4
-6
@@ -1,7 +1,6 @@
|
||||
#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->Pin = Pin;
|
||||
Button->Pressed = false;
|
||||
@@ -11,14 +10,13 @@ void DS_ButtonInit(DS_Button* Button, GPIO_TypeDef *Port, uint16_t Pin)
|
||||
Button->PrevTick = 0;
|
||||
Button->PressStartTick = 0;
|
||||
Button->PressStartTickLong = 0;
|
||||
Button->Storage = 5;
|
||||
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;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user