---vl6180dr

This commit is contained in:
Mysteo91
2023-08-01 11:24:26 +03:00
parent 0934ae33ff
commit d1bcf7e360
2 changed files with 9 additions and 9 deletions

View File

@@ -75,7 +75,7 @@ void AppInit(void)
uint8_t temp[2];
uint32_t controlPinMs = 0;
uint8_t controlPinFlag = 0;
uint8_t controlPinHighStart = 0;
uint32_t controlPinDetectedMs = 0;
uint8_t updateMode = 0;
void zummerOff (void)
@@ -153,15 +153,15 @@ void AppTask(void)
lightStartMs = 0;
lightingOff();
}
if (HAL_GPIO_ReadPin(CONTROL_PIN_GPIO_Port, CONTROL_PIN_Pin) == GPIO_PIN_SET) {
if (controlPinFlag == 0)
{
controlPinHighStart = HAL_GetTick();
if (HAL_GPIO_ReadPin(CONTROL_PIN_GPIO_Port, CONTROL_PIN_Pin) == GPIO_PIN_RESET && controlPinFlag == 0) {
controlPinDetectedMs = HAL_GetTick();
controlPinFlag = 1;
}
} else if (controlPinFlag == 1) {
} else if (controlPinFlag == 1 && HAL_GPIO_ReadPin(CONTROL_PIN_GPIO_Port, CONTROL_PIN_Pin) == GPIO_PIN_SET ) {
controlPinFlag = 0;
uint32_t ms = HAL_GetTick() - controlPinHighStart;
uint32_t ms = 0;
if (controlPinDetectedMs != 0)
ms = HAL_GetTick() - controlPinDetectedMs;
controlPinDetectedMs = 0;
if (ms >= 5000 && ms < 5200) {
////////Update mode
HAL_UART_DeInit(&huart1);