Sfoglia il codice sorgente

AtomicDiceRoller: 5v fixes

Willy-JL 2 anni fa
parent
commit
61a416ccbe
1 ha cambiato i file con 9 aggiunte e 3 eliminazioni
  1. 9 3
      atomicdiceroller/flipper_atomicdiceroller.c

+ 9 - 3
atomicdiceroller/flipper_atomicdiceroller.c

@@ -139,8 +139,11 @@ int32_t flipper_atomicdiceroller_app()
     FuriTimer* timerPause = furi_timer_alloc(clock_tick_pause, FuriTimerTypePeriodic, event_queue);
 
     // ENABLE 5V pin
-    furi_hal_power_enable_otg();
-
+    uint8_t attempts = 0;
+    while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
+        furi_hal_power_enable_otg();
+        furi_delay_ms(10);
+    }
     uint8_t diceBuffer[64];
     for (uint8_t i=0;i<64;i++) diceBuffer[i] = 0;
 
@@ -351,7 +354,10 @@ int32_t flipper_atomicdiceroller_app()
         
     furi_record_close(RECORD_NOTIFICATION);
 
-    furi_hal_power_disable_otg();
+    // Disable 5v power
+    if(furi_hal_power_is_otg_enabled()) {
+        furi_hal_power_disable_otg();
+    }
 
     furi_hal_gpio_disable_int_callback(&gpio_ext_pa7);
     furi_hal_gpio_remove_int_callback(&gpio_ext_pa7);