Просмотр исходного кода

call disable and enable only if previous state is different

MX 1 год назад
Родитель
Сommit
8006ce55a4
1 измененных файлов с 9 добавлено и 4 удалено
  1. 9 4
      actions/action_ir.c

+ 9 - 4
actions/action_ir.c

@@ -78,8 +78,13 @@ void action_ir_power_otg(bool enable) {
 
     if(tx_pin_detected == FuriHalInfraredTxPinInternal) return;
 
-    if(enable)
-        furi_hal_power_enable_otg();
-    else
-        furi_hal_power_disable_otg();
+    if(enable) {
+        if(!furi_hal_power_is_otg_enabled()) {
+            furi_hal_power_enable_otg();
+        }
+    } else {
+        if(furi_hal_power_is_otg_enabled()) {
+            furi_hal_power_disable_otg();
+        }
+    }
 }