Skip to content

Commit

Permalink
fixed problem with dumpResults. Other fixes
Browse files Browse the repository at this point in the history
Fix problems with dumpResults. Other changes to facilitate integration
into Adafruit_CircuitPlayground library.
  • Loading branch information
cyborg5 committed May 5, 2017
1 parent a356ae2 commit cb7a2b6
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 93 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.txt
@@ -1,3 +1,7 @@
Version 2.07 May 5, 2017
Fixed problem with dumpResults related to CYKM.
Miscellaneous changes to facilitate integration into
Adafruit_CircuitPlayground library.
Version 2.06 May 5, 2017
Added protocol 12 CYKM. A protocol designed by me Chris Young
to facilitate transmission and reception of keyboard and
Expand Down
4 changes: 4 additions & 0 deletions IRLib2/CHANGELOG.txt
@@ -1,3 +1,7 @@
Version 2.07 May 5, 2017
Fixed problem with dumpResults related to CYKM.
Miscellaneous changes to facilitate integration into
Adafruit_CircuitPlayground library.
Version 2.06 May 5, 2017
Added protocol 12 CYKM. A protocol designed by me Chris Young
to facilitate transmission and reception of keyboard and
Expand Down
12 changes: 11 additions & 1 deletion IRLibProtocols/IRLibCombo.h
Expand Up @@ -186,7 +186,17 @@ class IRdecode:
IR_DECODE_PROTOCOL_92
IR_DECODE_HASH //Must be last one.
return false;
}
};
#ifdef IRLIB_PROTOCOL_12_H
void dumpResults(bool verbose=true) {
if(protocolNum==12) {
IRdecodeCYKM::dumpResults();
if(verbose)IRdecodeBase::dumpResults(true);
} else {
IRdecodeBase::dumpResults(verbose);
}
}
#endif
};
#endif //IRLIBDECODEBASE_H

Expand Down
2 changes: 1 addition & 1 deletion IRLibProtocols/IRLibSendBase.h
Expand Up @@ -13,7 +13,7 @@
#ifndef IRLIBSENDBASE_H
#define IRLIBSENDBASE_H

#include <IRLibProtocols.h>
#include "IRLibProtocols.h"

class IRsendBase {
public:
Expand Down
145 changes: 69 additions & 76 deletions IRLibProtocols/IRLib_P08_Samsung36.h
Expand Up @@ -34,94 +34,87 @@
#ifdef IRLIBSENDBASE_H
class IRsendSamsung36: public virtual IRsendBase {
public:
void send(uint32_t data, uint32_t address);
void send(uint32_t data, uint32_t address) {
data <<= 32-20;
address <<= 32-16;
enableIROut(38);
mark(500*9); space(500*9); //Send header
putBits (address, 16); //Send address 16 bits
mark (500); space (500*9); //Send break
putBits (data, 12); //Send 12 bits
space(68); //Send tiny break
data <<= 12;
putBits (data, 8);mark(500); //Final eight bits and one stop bit
space(118*500); //Lead out is 118 times the base time 500
};
private:
void putBits (uint32_t data, uint8_t nbits);
};

void IRsendSamsung36::send(uint32_t data, uint32_t address) {
data <<= 32-20;
address <<= 32-16;
enableIROut(38);
mark(500*9); space(500*9); //Send header
putBits (address, 16); //Send address 16 bits
mark (500); space (500*9); //Send break
putBits (data, 12); //Send 12 bits
space(68); //Send tiny break
data <<= 12;
putBits (data, 8);mark(500); //Final eight bits and one stop bit
space(118*500); //Lead out is 118 times the base time 500
/* Because not all of the data bits are contiguous in the stream,
* we created this little routine to be called multiple times to send a
* segment of the data.
*/
void putBits (uint32_t data, uint8_t nbits) {
for (uint8_t i = 0; i < nbits; i++) {
if (data & TOPBIT) {
mark(500); space(500*3);
} else {
mark(500); space(500);
};
data <<= 1;
}
}
};

/* Because not all of the data bits are contiguous in the stream,
* we created this little routine to be called multiple times to send a
* segment of the data.
*/
void IRsendSamsung36::putBits (uint32_t data, uint8_t nbits) {
for (uint8_t i = 0; i < nbits; i++) {
if (data & TOPBIT) {
mark(500); space(500*3);
} else {
mark(500); space(500);
};
data <<= 1;
}
}
#endif //IRLIBSENDBASE_H

#ifdef IRLIBDECODEBASE_H
class IRdecodeSamsung36: public virtual IRdecodeBase {
public:
bool decode(void);
bool decode(void) {
IRLIB_ATTEMPT_MESSAGE(F("Samsung36"));
if (recvGlobal.decodeLength != 78) return RAW_COUNT_ERROR;
if (!MATCH(recvGlobal.decodeBuffer[1],500*9)) return HEADER_MARK_ERROR(500*9);
if (!MATCH(recvGlobal.decodeBuffer[2],500*9)) return HEADER_SPACE_ERROR(500*9);
offset=3; data=0;
//Get first 16 bits
if(!getBits(16*2+2))return false;
//Skip middle header
if (!MATCH(recvGlobal.decodeBuffer[offset],500)) return DATA_MARK_ERROR(500);
offset++;
if (!MATCH(recvGlobal.decodeBuffer[offset],500*9)) return DATA_SPACE_ERROR(4400);
//save first 16 bits in "address" and reset data
offset++; address=data; data=0;
//12 bits into this second segment, the space is extended by 68us.
// so we adjust the value to its normal length without the extra 68us.
recvGlobal.decodeBuffer[62]-=68;
//Now get the remaining 20 bits
if(!getBits(77))return false;
bits =36; //set bit length
value = data; //put remaining 20 bits in value
protocolNum= SAMSUNG36;
return true;
};
private:
bool getBits(uint8_t last_offset);
/* Because not all of the data bits are contiguous in the stream
* we created this little routine to be called multiple times
* to decode a segment of the data. Parameter "last_offset" is when we
* stop decoding the segment.
*/
bool getBits(uint8_t last_offset) {
while (offset < last_offset) {
if (!MATCH(recvGlobal.decodeBuffer[offset],500)) return DATA_MARK_ERROR(500);
offset++;
if (MATCH(recvGlobal.decodeBuffer[offset],500*3))
data = (data << 1) | 1;
else if (MATCH(recvGlobal.decodeBuffer[offset],500))
data <<= 1;
else return DATA_SPACE_ERROR(500*3);
offset++;
};
return true;
};
uint8_t offset;
uint32_t data;
};

bool IRdecodeSamsung36::decode(void) {
IRLIB_ATTEMPT_MESSAGE(F("Samsung36"));
if (recvGlobal.decodeLength != 78) return RAW_COUNT_ERROR;
if (!MATCH(recvGlobal.decodeBuffer[1],500*9)) return HEADER_MARK_ERROR(500*9);
if (!MATCH(recvGlobal.decodeBuffer[2],500*9)) return HEADER_SPACE_ERROR(500*9);
offset=3; data=0;
//Get first 16 bits
if(!getBits(16*2+2))return false;
//Skip middle header
if (!MATCH(recvGlobal.decodeBuffer[offset],500)) return DATA_MARK_ERROR(500);
offset++;
if (!MATCH(recvGlobal.decodeBuffer[offset],500*9)) return DATA_SPACE_ERROR(4400);
//save first 16 bits in "address" and reset data
offset++; address=data; data=0;
//12 bits into this second segment, the space is extended by 68us.
// so we adjust the value to its normal length without the extra 68us.
recvGlobal.decodeBuffer[62]-=68;
//Now get the remaining 20 bits
if(!getBits(77))return false;
bits =36; //set bit length
value = data; //put remaining 20 bits in value
protocolNum= SAMSUNG36;
return true;
};

/* Because not all of the data bits are contiguous in the stream
* we created this little routine to be called multiple times
* to decode a segment of the data. Parameter "last_offset" is when we
* stop decoding the segment.
*/
bool IRdecodeSamsung36::getBits(uint8_t last_offset) {
while (offset < last_offset) {
if (!MATCH(recvGlobal.decodeBuffer[offset],500)) return DATA_MARK_ERROR(500);
offset++;
if (MATCH(recvGlobal.decodeBuffer[offset],500*3))
data = (data << 1) | 1;
else if (MATCH(recvGlobal.decodeBuffer[offset],500))
data <<= 1;
else return DATA_SPACE_ERROR(500*3);
offset++;
};
return true;
};
#endif //IRLIBDECODEBASE_H

#define IRLIB_HAVE_COMBO
Expand Down
28 changes: 13 additions & 15 deletions IRLibProtocols/IRLib_P10_DirecTV.h
Expand Up @@ -50,23 +50,21 @@
class IRsendDirecTV: public virtual IRsendBase {
public:
IRsendDirecTV(void):longLeadOut(true){};
void send(uint32_t data, bool first=true, uint8_t khz=38);
void send(uint32_t data, bool first=true, uint8_t khz=38) {
enableIROut(khz);
if(first) mark(6000); else mark(3000);
space(1200);//Send header
for (uint8_t i = 0; i < 8; i++) {
if (data & 0x8000) mark(1200); else mark(600);
data <<= 1;
if (data & 0x8000) space(1200); else space(600);
data <<= 1;
};
mark(600);
space(longLeadOut?50*600:15*600);
};
bool longLeadOut;
};

void IRsendDirecTV::send(uint32_t data, bool first, uint8_t khz) {
enableIROut(khz);
if(first) mark(6000); else mark(3000);
space(1200);//Send header
for (uint8_t i = 0; i < 8; i++) {
if (data & 0x8000) mark(1200); else mark(600);
data <<= 1;
if (data & 0x8000) space(1200); else space(600);
data <<= 1;
};
mark(600);
space(longLeadOut?50*600:15*600);
};
#endif //IRLIBSENDBASE_H

#ifdef IRLIBDECODEBASE_H
Expand Down
2 changes: 2 additions & 0 deletions IRLibRecvPCI/IRLibRecvPCI.h
Expand Up @@ -23,6 +23,8 @@

class IRrecvPCI: public IRrecvBase {
public:
IRrecvPCI(void){}; //Use only when receiver object is part of larger object.
// Still must initialize using constructor below.
IRrecvPCI(uint8_t pin);
void enableIRIn(void); //call to initialize or resume receiving
bool getResults(void); //returns true if new frame of data has been received
Expand Down

0 comments on commit cb7a2b6

Please sign in to comment.