]> vault307.fbx.one Git - micorpython_ir.git/commitdiff
Fix issue 14 NEC transmit error on RP2.
authorPeter Hinch <peter@hinch.me.uk>
Sun, 5 Jun 2022 16:51:45 +0000 (17:51 +0100)
committerPeter Hinch <peter@hinch.me.uk>
Sun, 5 Jun 2022 16:51:45 +0000 (17:51 +0100)
ir_tx/__init__.py
ir_tx/rp2_rmt.py

index a774badceefcb288b8963900b18e81ee87848f6d..e791b4a961810d773a68300def1489d70110f68c 100644 (file)
@@ -46,6 +46,7 @@ class IR:
             # 1μs resolution
         elif RP2:  # PIO-based RMT-like device
             self._rmt = RP2_RMT(pin_pulse=None, carrier=(pin, cfreq, duty))  # 1μs resolution
+            asize += 1  # Allow for possible extra space pulse
         else:  # Pyboard
             if not IR._active_high:
                 duty = 100 - duty
index 7b42fa8c3137512b68dfd2e3b9a1de8ef20cbc9f..2848419ddc8993ba66ce0094ca150ac3dd17b83e 100644 (file)
@@ -82,10 +82,13 @@ class RP2_RMT:
             if d == 0:
                 break
         if check:
-            # Discard any trailing mark which would leave carrier on.
+            # Pulse train must end with a space otherwise we leave carrier on.
+            # So, if it ends with a mark, append a space. Note __init__.py
+            # ensures that there is room in array.
             if (x & 1):
-                x -= 1
-                ar[x] = 0
+                ar[x] = 1  # space. Duration doesn't matter.
+                x += 1
+                ar[x] = 0  # STOP
         self.icm = x  # index of 1st STOP
         mv = memoryview(ar)
         n = min(x, 4)  # Fill FIFO if there are enough data points.