ir tx test run

This commit is contained in:
Tomas Krejci 2024-05-16 14:39:51 +02:00
parent c01b88a030
commit 78a4c2ac32
10 changed files with 9 additions and 12 deletions

View File

@ -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 :`

View File

@ -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):

View File

@ -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: