фикс бага с повторным взводом RisingEdge при отпускании кнопки
This commit is contained in:
+16
-18
@@ -1,24 +1,22 @@
|
|||||||
#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;
|
Button->PressedLong = false;
|
||||||
Button->PressedLong = false;
|
Button->PressedLongLong = false;
|
||||||
Button->PressedLongLong = false;
|
Button->Released = false;
|
||||||
Button->Released = false;
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user