Skip to content

Commit

Permalink
Added Sony 20 support
Browse files Browse the repository at this point in the history
Still not usable with Sony 12 together
  • Loading branch information
Nico committed May 1, 2015
1 parent af9c91e commit 4fbd88b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions IRLremote.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <uint8_t irLength, uint16_t timeoutThreshold, uint16_t markLeadThreshold, uint16_t spaceLeadThreshold,
Expand Down
45 changes: 44 additions & 1 deletion IRLremoteReceive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ decode(uint16_t duration){

else if (ir == IR_SONY12)
decodeSony12(duration);

else if (ir == IR_SONY20)
decodeSony20(duration);
}


Expand All @@ -265,7 +268,6 @@ decodeNec(const uint16_t duration){
(duration, data, count);
//else


if (newInput){
// check for button holding
if (count == 2)
Expand Down Expand Up @@ -378,6 +380,47 @@ decodeSony12(const uint16_t duration){
}


template <uint32_t debounce, IRType ...irProtocol>
inline void CIRLremote<debounce, irProtocol...>::
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 <SONY_LENGTH_20, (SONY_TIMEOUT + SONY_MARK_LEAD) / 2, // irLength, timeoutThreshold
(SONY_MARK_LEAD + SONY_MARK_ONE) / 2, 0, // markLeadThreshold, spaceLeadThreshold
0, (SONY_MARK_ONE + SONY_MARK_ZERO) / 2, // spaceLeadHoldingThreshold, markThreshold
0, // spaceThreshold
(SONY_MARK_LEAD + SONY_MARK_ONE) / 2, SONY_MARK_ONE>// markTimeout, spaceTimeout
(duration, data, count);
else
newInput = IRLdecode <SONY_LENGTH_20, (SONY_TIMEOUT + SONY_MARK_LEAD) / 2, // irLength, timeoutThreshold
(SONY_MARK_LEAD + SONY_MARK_ONE) / 2, 0, // markLeadThreshold, spaceLeadThreshold
0, (SONY_MARK_ONE + SONY_MARK_ZERO) / 2, // spaceLeadHoldingThreshold, markThreshold
0, // spaceThreshold
0, 0>// 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 <uint32_t debounce, IRType ...irProtocol>
template <uint8_t irLength, uint16_t timeoutThreshold, uint16_t markLeadThreshold, uint16_t spaceLeadThreshold,
uint16_t spaceLeadHoldingThreshold, uint16_t markThreshold, uint16_t spaceThreshold,
Expand Down

0 comments on commit 4fbd88b

Please sign in to comment.