Dev #2
+15
-17
@@ -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;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user