up test RX
This commit is contained in:
parent
e4ce25e930
commit
9bc670b2b9
@ -45,7 +45,17 @@ class SONY_ABC(IR_RX): # Abstract base class
|
||||
if ticks_diff(self._times[x + 1], self._times[x]) > 900:
|
||||
val |= bit
|
||||
bit <<= 1
|
||||
x += 2
|
||||
x += 2
|
||||
|
||||
#ba = int.to_bytes(val)
|
||||
#ba = bytearray(val)
|
||||
#ba.reverse()
|
||||
|
||||
|
||||
#bytes = b'\xAA\x00\x00\x00'
|
||||
#val = int.from_bytes(ba, byteorder='little', signed=False)
|
||||
#print(integer)
|
||||
|
||||
packet = val
|
||||
byte1 = val & 0xff # 8 bit command
|
||||
val >>= 8
|
||||
|
@ -5,7 +5,7 @@
|
||||
# Copyright Peter Hinch 2020-2022 Released under the MIT license
|
||||
|
||||
# Run this to characterise a remote.
|
||||
|
||||
import ustruct
|
||||
from sys import platform
|
||||
import time
|
||||
import gc
|
||||
@ -26,12 +26,53 @@ elif platform == "esp32" or platform == "esp32_LoBo":
|
||||
elif platform == "rp2":
|
||||
p = Pin(16, Pin.IN)
|
||||
|
||||
def reverse(s):
|
||||
str = ""
|
||||
for i in s:
|
||||
str = i + str
|
||||
return str
|
||||
|
||||
# Bit reverse a 32 bit value
|
||||
def rbit32(v):
|
||||
v = (v & 0x0000ffff) << 16 | (v & 0xffff0000) >> 16
|
||||
v = (v & 0x00ff00ff) << 8 | (v & 0xff00ff00) >> 8
|
||||
v = (v & 0x0f0f0f0f) << 4 | (v & 0xf0f0f0f0) >> 4
|
||||
v = (v & 0x33333333) << 2 | (v & 0xcccccccc) >> 2
|
||||
return (v & 0x55555555) << 1 | (v & 0xaaaaaaaa) >> 1
|
||||
|
||||
# User callback
|
||||
def cb(byte1, byte2, byte3, packet):
|
||||
# print("TEST")
|
||||
# print(f"packet {packet}")
|
||||
print(f"byte1 0x{byte1:04x} byte2 0x{byte2:04x} byte3 0x{byte3:04x} packet 0x{packet:08x}")
|
||||
print(f"byte1 0x{byte1:02x} byte2 0x{byte2:02x} byte3 0x{byte3:02x} packet 0x{packet:08x}")
|
||||
#packet.reverse()
|
||||
#print(packet)
|
||||
#reversed
|
||||
#print(f" XXX {ustruct.unpack(">I", packet)[0]}")
|
||||
#print(data)
|
||||
#ba = int.to_bits(packet, 1, 'big')
|
||||
#ba[0].reverse()
|
||||
test = bin(packet)
|
||||
print(test)
|
||||
test2 = reverse(test)
|
||||
print(test2)
|
||||
#test.__reversed__()
|
||||
test3 = rbit32(packet)
|
||||
print(f"{test3:08x}")
|
||||
#print(test)
|
||||
|
||||
# print(f"test: {(int.to_bytes(packet, 4, 'big'))}")
|
||||
#ba = ba.reversed()
|
||||
|
||||
#print(ba)
|
||||
#ba = int.to_bytes(packet, 4, 'little')
|
||||
#print(f"packet {ba:08x}")
|
||||
#ba = bytearray(val)
|
||||
#ba.reverse()
|
||||
#bytes = b'\xAA\x00\x00\x00'
|
||||
#packet = int.from_bytes(ba, byteorder='little', signed=False)
|
||||
#print(integer)
|
||||
#print(f"packet {packet:08x}")
|
||||
|
||||
def test(proto=0):
|
||||
classes = (LT_24, SONY_12, SONY_15, SONY_20)
|
||||
|
Loading…
Reference in New Issue
Block a user