Send:
void IRsend::sendPHOENIX_LTX(unsigned long data, int nbits) {
enableIROut(36);
//HEAD
mark(PHOENIX_HDR_MARK);
space(PHOENIX_HDR_SPACE);
mark(PHOENIX_HDR_MARK);
int i = 0;
for (i = 0; i < 7; i++) {
if (i % 2 == 0) {
space(PHOENIX_LTX_SPACE);
} else {
mark(PHOENIX_LTX_ZERO_MARK);
}
}
//DATA
if ((data >> 2) & 1 == 1) {
mark(PHOENIX_LTX_ONE_MARK);
} else {
mark(PHOENIX_LTX_ZERO_MARK);
}
space(PHOENIX_LTX_SPACE);
if ((data >> 0) & 1 == 1) {
mark(PHOENIX_LTX_ONE_MARK);
} else {
mark(PHOENIX_LTX_ZERO_MARK);
}
//TAIL
for (i = 0; i < 4; i++) {
if (i % 2 == 0) {
space(PHOENIX_LTX_SPACE);
} else {
mark(PHOENIX_LTX_ZERO_MARK);
}
}
space(PHOENIX_LTX_SPACE);
}
Receive:
long IRrecv::decodePHOENIX_LTX(decode_results *results) {
long data = 0;
int offset = 1;
int i = 0;
//HEAD
if (results->rawlen != 18) {
return ERR;
}
if (!MATCH_MARK(results->rawbuf[offset], PHOENIX_HDR_MARK)) {
return ERR;
}
offset++;
if (!MATCH_SPACE(results->rawbuf[offset], PHOENIX_HDR_SPACE)) {
return ERR;
}
offset++;
if (!MATCH_MARK(results->rawbuf[offset], PHOENIX_HDR_MARK)) {
return ERR;
}
offset++;
for (i = 0; i < 7; i++) {
if (i % 2 == 0) {
if (!MATCH_SPACE(results->rawbuf[offset], 2000)) {
Serial.println(i, DEC);
return ERR;
}
} else {
if (!MATCH_MARK(results->rawbuf[offset], 1000)) {
Serial.println(i, DEC);
return ERR;
}
}
offset++;
}
Serial.println("Data");
//DATA
for (i = 0; i < 3; i++) {
if (MATCH_MARK(results->rawbuf[offset], PHOENIX_LTX_ONE_MARK)) {
data << 1;
data |= 1;
} else if (MATCH_MARK(results->rawbuf[offset], PHOENIX_LTX_ZERO_MARK)) {
data << 1;
data |= 0;
} else {
Serial.println(i, DEC);
return ERR;
}
offset++;
}
Serial.println("Tail");
//TAIL
for (i = 0; i < 2; i++) {
if (!MATCH_SPACE(results->rawbuf[offset], 2000)) {
return ERR;
}
offset++;
if (!MATCH_MARK(results->rawbuf[offset], 1000)) {
return ERR;
}
offset++;
}
// Success
results->bits = 3;
results->value = data;
results->decode_type = PHOENIX_LTX;
return DECODED;
}
Defines:
#define PHOENIX_HDR_MARK 3000
#define PHOENIX_HDR_SPACE 6000
#define PHOENIX_LTX_ONE_MARK 2000
#define PHOENIX_LTX_ZERO_MARK 1000
#define PHOENIX_LTX_SPACE 2000