Browse Source

make ir receive more consistent

Oliver Fabel 1 năm trước cách đây
mục cha
commit
930a914df1
1 tập tin đã thay đổi với 7 bổ sung5 xóa
  1. 7 5
      lib/micropython-port/mp_flipper_modflipperzero_infrared.c

+ 7 - 5
lib/micropython-port/mp_flipper_modflipperzero_infrared.c

@@ -52,10 +52,10 @@ inline uint32_t* mp_flipper_infrared_receive(uint32_t timeout, size_t* length) {
 
     mp_flipper_infrared_rx_t* session = ctx->infrared_rx;
 
-    session->pointer = 0;
-    session->running = true;
-
     if(!furi_hal_infrared_is_busy()) {
+        session->pointer = 0;
+        session->running = true;
+
         furi_hal_infrared_async_rx_set_capture_isr_callback(on_rx, session);
         furi_hal_infrared_async_rx_set_timeout_isr_callback(on_rx_timeout, session);
 
@@ -68,9 +68,11 @@ inline uint32_t* mp_flipper_infrared_receive(uint32_t timeout, size_t* length) {
         }
 
         furi_hal_infrared_async_rx_stop();
-    }
 
-    *length = session->pointer;
+        *length = session->pointer;
+    } else {
+        *length = 0;
+    }
 
     return session->buffer;
 }