Parcourir la source

按下就关机

xuxinyi il y a 2 mois
Parent
commit
94319086f8
1 fichiers modifiés avec 13 ajouts et 8 suppressions
  1. 13 8
      Core/Src/stm32f1xx_it.c

+ 13 - 8
Core/Src/stm32f1xx_it.c

@@ -445,18 +445,23 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
       // 松开(上升沿)
       printf("JUGE_KEY 松开\r\n");
 
-      int pressedSeconds = (currentTime.Hours * 3600 + currentTime.Minutes * 60 + currentTime.Seconds)
-                         - (JUGE_key_struct.Hours * 3600 + JUGE_key_struct.Minutes * 60 + JUGE_key_struct.Seconds);
-      if (pressedSeconds < 0) {
-        pressedSeconds += 24 * 3600;
-      }
-
-      printf("JUGE_KEY 按下持续时间: %d 秒\r\n", pressedSeconds);
+      // int pressedSeconds = (currentTime.Hours * 3600 + currentTime.Minutes * 60 + currentTime.Seconds)
+      //                    - (JUGE_key_struct.Hours * 3600 + JUGE_key_struct.Minutes * 60 + JUGE_key_struct.Seconds);
+      // if (pressedSeconds < 0) {
+      //   pressedSeconds += 24 * 3600;
+      // }
+      //
+      // printf("JUGE_KEY 按下持续时间: %d 秒\r\n", pressedSeconds);
+      // if (pressedSeconds > 1) {
+      //   // HAL_GPIO_WritePin(PowerLED_GPIO_Port, PowerLED_Pin, GPIO_PIN_RESET);
+      //   HAL_GPIO_WritePin(POWER_ON_GPIO_Port, POWER_ON_Pin, GPIO_PIN_RESET);
+      // }
 
     } else {
       // 按下(下降沿)
       printf("JUGE_KEY 按下\r\n");
-      JUGE_key_struct = currentTime;
+      // JUGE_key_struct = currentTime;
+      HAL_GPIO_WritePin(POWER_ON_GPIO_Port, POWER_ON_Pin, GPIO_PIN_RESET);
     }
   }
 }