]> vault307.fbx.one Git - micorpython_ir.git/blobdiff - ir_tx/philips.py
Merge branch 'peterhinch:master' into master
[micorpython_ir.git] / ir_tx / philips.py
index b0693611a8d2ab6c8e63301b293e3fc284a41348..90b9de941f4d7bc17729fab3e195e9ba1f2a53ef 100644 (file)
@@ -5,22 +5,20 @@
 # Copyright Peter Hinch 2020 Released under the MIT license
 
 from micropython import const
-from sys import platform
-ESP32 = platform == 'esp32' or platform == 'esp32_LoBo'
 from ir_tx import IR
 
 # Philips RC5 protocol
 _T_RC5 = const(889)  # Time for pulse of carrier
-ermsg = 'ESP32 does not support Philips protocols'
+
+
 class RC5(IR):
+    valid = (0x1f, 0x3f, 1)  # Max addr, data, toggle
 
     def __init__(self, pin, freq=36000, verbose=False):
-        if ESP32:
-            raise RuntimeError(ermsg)
         super().__init__(pin, freq, 28, 30, verbose)
 
-    def tx(self, addr, data, toggle):
-        d = (data & 0x3f) | ((addr & 0x1f) << 6) | ((data & 0x40) << 6) | ((toggle & 1) << 11)
+    def tx(self, addr, data, toggle):  # Fix RC5X S2 bit polarity
+        d = (data & 0x3f) | ((addr & 0x1f) << 6) | (((data & 0x40) ^ 0x40) << 6) | ((toggle & 1) << 11)
         self.verbose and print(bin(d))
         mask = 0x2000
         while mask:
@@ -40,10 +38,9 @@ _T_RC6 = const(444)
 _T2_RC6 = const(889)
 
 class RC6_M0(IR):
+    valid = (0xff, 0xff, 1)  # Max addr, data, toggle
 
     def __init__(self, pin, freq=36000, verbose=False):
-        if ESP32:
-            raise RuntimeError(ermsg)
         super().__init__(pin, freq, 44, 30, verbose)
 
     def tx(self, addr, data, toggle):