]> vault307.fbx.one Git - micorpython_ir.git/blobdiff - ir_rx_test.py
README.md Warn about ESP8266 and ESP32 issue.
[micorpython_ir.git] / ir_rx_test.py
index 908d23f83cb229e29f2610bba9971a2ec417b0ac..2785398cefbccb39537156312947b2590e5ae786 100644 (file)
@@ -9,7 +9,7 @@
 from sys import platform
 import time
 from machine import Pin, freq
 from sys import platform
 import time
 from machine import Pin, freq
-from arem import *
+from ir_rx import *
 
 ESP32 = platform == 'esp32' or platform == 'esp32_LoBo'
 
 
 ESP32 = platform == 'esp32' or platform == 'esp32_LoBo'
 
@@ -31,13 +31,17 @@ def cb(data, addr, ctrl):
     elif data >= 0:
         print('Data {:03x} Addr {:03x} Ctrl {:01x}'.format(data, addr, ctrl))
     else:
     elif data >= 0:
         print('Data {:03x} Addr {:03x} Ctrl {:01x}'.format(data, addr, ctrl))
     else:
-        print('{} Address: {}'.format(errors[data], hex(addr)))
+        print(errors[data])  # Application would ignore errors
 
 
 s = '''Test for IR receiver. Run:
 
 
 s = '''Test for IR receiver. Run:
-ir_tx_test.test() for NEC protocol,
-ir_tx_test.test(5) for Philips RC-5 protocol,
-ir_tx_test.test(6) for RC6 mode 0.
+from ir_rx_test import test
+test() for NEC protocol,
+test(1) for Sony SIRC 12 bit,
+test(2) for Sony SIRC 15 bit,
+test(3) for Sony SIRC 20 bit,
+test(5) for Philips RC-5 protocol,
+test(6) for RC6 mode 0.
 
 Background processing means REPL prompt reappears.
 Hit ctrl-D to stop (soft reset).'''
 
 Background processing means REPL prompt reappears.
 Hit ctrl-D to stop (soft reset).'''
@@ -46,11 +50,16 @@ print(s)
 
 def test(proto=0):
     if proto == 0:
 
 def test(proto=0):
     if proto == 0:
-        ir = NEC_IR(p, cb, True, 0)  # Extended mode, dummy ctrl arg for callback
+        ir = NEC_IR(p, cb)  # Extended mode
+    elif proto < 4:
+        bits = (12, 15, 20)[proto - 1]
+        ir = SONY_IR(p, cb, bits)
+        ir.verbose = True
     elif proto == 5:
         ir = RC5_IR(p, cb)
     elif proto == 6:
         ir = RC6_M0(p, cb)
     elif proto == 5:
         ir = RC5_IR(p, cb)
     elif proto == 6:
         ir = RC6_M0(p, cb)
+        ir.verbose = True
     # A real application would do something here...
     #while True:
         #time.sleep(5)
     # A real application would do something here...
     #while True:
         #time.sleep(5)