diff --git a/IRLremote.h b/IRLremote.h index 8543af7..35c15fb 100644 --- a/IRLremote.h +++ b/IRLremote.h @@ -98,6 +98,7 @@ class CIRLremote{ static void decodeNec(const uint16_t duration) __attribute__((always_inline)); static void decodePanasonic(const uint16_t duration) __attribute__((always_inline)); static void decodeSony12(const uint16_t duration) __attribute__((always_inline)); + static void decodeSony20(const uint16_t duration) __attribute__((always_inline)); // multifunctional template for receiving template +inline void CIRLremote:: +decodeSony20(const uint16_t duration){ + // temporary buffer to hold bytes for decoding this protocol + static uint8_t data[SONY_BLOCKS_20]; + static uint8_t count = 0; + + // pass the duration to the decoding function + bool newInput; + // 1st extra accuracy solution + if (sizeof...(irProtocol) != 1) + newInput = IRLdecode // markTimeout, spaceTimeout + (duration, data, count); + else + newInput = IRLdecode // markTimeout, spaceTimeout + (duration, data, count); + + if (newInput){ + // protocol has no checksum + uint8_t upper5Bits = ((data[2] >> 2) & 0x3E); + uint8_t lsb = (data[0] >> 7) & 0x01; + uint16_t address = (upper5Bits << 8) | (data[1] << 1) | lsb; + uint32_t command = data[0] & 0x7F; + // 2nd extra accuracy solution + //if ((sizeof...(irProtocol) != 1) && (address || command)) + IREvent(IR_SONY20, address, command); + + // reset reading + count = 0; + } +} + + template template