diff --git a/README.md b/README.md index 8668249..de3d595 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ https://randomnerdtutorials.com/raspberry-pi-pico-vs-code-micropython/ ## install LT +install primitives lib +`$ mpremote mip install "github:peterhinch/micropython-async/v3/primitives"` install lib folder on device `$ mpremote connect /dev/ttyACM0 cp -r ./lib :` diff --git a/lib/olt_lib/rx/__init__.py b/lib/olt_lib/ir_rx/__init__.py similarity index 100% rename from lib/olt_lib/rx/__init__.py rename to lib/olt_lib/ir_rx/__init__.py diff --git a/lib/olt_lib/rx/acquire.py b/lib/olt_lib/ir_rx/acquire.py similarity index 100% rename from lib/olt_lib/rx/acquire.py rename to lib/olt_lib/ir_rx/acquire.py diff --git a/lib/olt_lib/rx/print_error.py b/lib/olt_lib/ir_rx/print_error.py similarity index 100% rename from lib/olt_lib/rx/print_error.py rename to lib/olt_lib/ir_rx/print_error.py diff --git a/lib/olt_lib/rx/sony.py b/lib/olt_lib/ir_rx/sony.py similarity index 100% rename from lib/olt_lib/rx/sony.py rename to lib/olt_lib/ir_rx/sony.py diff --git a/lib/olt_lib/rx/test.py b/lib/olt_lib/ir_rx/test.py similarity index 100% rename from lib/olt_lib/rx/test.py rename to lib/olt_lib/ir_rx/test.py diff --git a/lib/olt_lib/tx/__init__.py b/lib/olt_lib/ir_tx/__init__.py similarity index 100% rename from lib/olt_lib/tx/__init__.py rename to lib/olt_lib/ir_tx/__init__.py diff --git a/lib/olt_lib/tx/sony.py b/lib/olt_lib/ir_tx/olt.py similarity index 98% rename from lib/olt_lib/tx/sony.py rename to lib/olt_lib/ir_tx/olt.py index 2734c17..116df5f 100644 --- a/lib/olt_lib/tx/sony.py +++ b/lib/olt_lib/ir_tx/olt.py @@ -5,7 +5,7 @@ # Copyright Peter Hinch 2020 Released under the MIT license from micropython import const -from ir_tx import IR +from olt_lib.ir_tx import IR class SONY_ABC(IR): diff --git a/lib/olt_lib/tx/rp2_rmt.py b/lib/olt_lib/ir_tx/rp2_rmt.py similarity index 100% rename from lib/olt_lib/tx/rp2_rmt.py rename to lib/olt_lib/ir_tx/rp2_rmt.py diff --git a/lib/olt_lib/tx/test.py b/lib/olt_lib/ir_tx/test.py similarity index 85% rename from lib/olt_lib/tx/test.py rename to lib/olt_lib/ir_tx/test.py index 244b98a..e17a0b1 100644 --- a/lib/olt_lib/tx/test.py +++ b/lib/olt_lib/ir_tx/test.py @@ -17,7 +17,7 @@ import uasyncio as asyncio from primitives.switch import Switch from primitives.delay_ms import Delay_ms # Import all implemented classes -from ir_tx.sony import SONY_12, SONY_15, SONY_20, LT_24 +from olt_lib.ir_tx.olt import LT_24, SONY_12, SONY_15, SONY_20 loop = asyncio.get_event_loop() @@ -38,7 +38,7 @@ class Rbutton: self.tim = Delay_ms(self.repeat) def cfunc(self): # Button push: send data - tog = 0 if self.proto < 3 else Rbutton.toggle # NEC, sony 12, 15: toggle==0 + tog = 0 # NEC, sony 12, 15: toggle==0 self.irb.transmit(self.addr, self.data, tog, True) # Test validation # Auto repeat. The Sony protocol specifies 45ms but this is tight. # In 20 bit mode a data burst can be upto 39ms long. @@ -52,11 +52,8 @@ class Rbutton: await asyncio.sleep(0) # Let timer stop before retriggering if not self.sw(): # Button is still pressed: retrigger self.tim.trigger(108) - if self.proto == 0: - self.irb.repeat() # NEC special case: send REPEAT code - else: - tog = 0 if self.proto < 3 else Rbutton.toggle # NEC, sony 12, 15: toggle==0 - self.irb.transmit(self.addr, self.data, tog, True) # Test validation + tog = 0 # NEC, sony 12, 15: toggle==0 + self.irb.transmit(self.addr, self.data, tog, True) # Test validation async def main(proto): # Test uses a 56KHz carrier. @@ -66,7 +63,7 @@ async def main(proto): pin = Pin(17, Pin.OUT, value = 0) else: pin = Pin('X1') - classes = (SONY_12, SONY_15, SONY_20, LT_24) + classes = (LT_24, SONY_12, SONY_15, SONY_20) irb = classes[proto](pin, 56000) # My decoder chip is 56KHz # Uncomment the following to print transmit timing irb.timeit = True @@ -94,12 +91,10 @@ async def main(proto): # Greeting strings. Common: s = '''Test for IR transmitter. Run: from ir_tx.test import test -test() for NEC protocol +test() for LT-24 protocol test(1) for Sony SIRC 12 bit test(2) for Sony SIRC 15 bit test(3) for Sony SIRC 20 bit -test(4) for Philips RC-5 protocol -test(5) for Philips RC-6 mode 0. ''' # Pyboard: