version 1

This commit is contained in:
Your Name
2024-04-15 20:53:59 +03:00
parent fc727dfbfe
commit 23598a80db
8 changed files with 175 additions and 48 deletions

View File

@@ -21,7 +21,7 @@
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "DS_Button.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -54,7 +54,7 @@ static void MX_GPIO_Init(void);
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
uint8_t j;
GPIO_PinState ButtonState;
/* USER CODE END 0 */
/**
@@ -87,50 +87,30 @@ int main(void)
/* Initialize all configured peripherals */
MX_GPIO_Init();
/* USER CODE BEGIN 2 */
DS_Button Button;
DS_ButtonInit(&Button, Button_GPIO_Port, Button_Pin);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
////////
//2 раза красным
//2 раза синими
//желтый на 3 сек
//интервал моргания 100 миллисек
//////
//повторить 3 раза
//выключить всё на 10 сек
for (j = 0; j < 3; j++)
DS_ButtonUpdate(&Button);
if(DS_ButtonPressed(&Button))
{
HAL_GPIO_WritePin(Led1_GPIO_Port, Led1_Pin, GPIO_PIN_SET);
HAL_Delay(100);
HAL_GPIO_WritePin(Led1_GPIO_Port, Led1_Pin, GPIO_PIN_RESET);
HAL_Delay(100);
HAL_GPIO_WritePin(Led1_GPIO_Port, Led1_Pin, GPIO_PIN_SET);
HAL_Delay(100);
HAL_GPIO_WritePin(Led1_GPIO_Port, Led1_Pin, GPIO_PIN_RESET);
HAL_Delay(100);
for (uint8_t i = 0; i < 2; i++)
{
HAL_GPIO_WritePin(Led3_GPIO_Port, Led3_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(Led4_GPIO_Port, Led4_Pin, GPIO_PIN_SET);
HAL_Delay(100);
HAL_GPIO_WritePin(Led3_GPIO_Port, Led3_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(Led4_GPIO_Port, Led4_Pin, GPIO_PIN_RESET);
HAL_Delay(100);
}
HAL_GPIO_WritePin(Led2_GPIO_Port, Led2_Pin, GPIO_PIN_SET);
HAL_Delay(3000);
HAL_GPIO_WritePin(Led2_GPIO_Port, Led2_Pin, GPIO_PIN_RESET);
}
HAL_Delay(10000);
else
{
HAL_GPIO_WritePin(Led1_GPIO_Port, Led1_Pin, GPIO_PIN_RESET);
}
if(DS_Button_PressedLong(&Button))
{
HAL_GPIO_TogglePin(Led3_GPIO_Port, Led3_Pin);
HAL_GPIO_TogglePin(Led4_GPIO_Port, Led4_Pin);
}
/* USER CODE END WHILE */
@@ -199,6 +179,12 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pin : Button_Pin */
GPIO_InitStruct.Pin = Button_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
HAL_GPIO_Init(Button_GPIO_Port, &GPIO_InitStruct);
/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}