int DaewooProtocol::generateStandardCommand( const PIRKeyBits &pkb, PIRInfraredLED &led) { int duration = 0; // First, the "header" pulse: led.addPair(headerPulse, headerSpace); duration += (headerPulse + headerSpace); // The address data: duration += pushReverseBits(preData, led); // The Daewoo mid-train marker: led.addPair(midPulse, midSpace); duration += (midPulse + midSpace); // The command data: duration += pushReverseBits(pkb.firstCode, led); // Finally add the "trail": led.addSingle(trailerPulse); duration += trailerPulse; return duration; }
int KathreinProtocol::generateStandardCommand( const PIRKeyBits &pkb, PIRInfraredLED &led) { int duration = 0; // First, the "header" pulse: led.addPair(headerPulse, headerSpace); duration += (headerPulse + headerSpace); // Kathrein protocol has four bits of address and eight bits of command. // As in NEC protocol, the address and command are complemented. // - "preData" should contain the 4-bit address // - "firstCode" should contain the 8-bit command duration += pushReverseBits(preData, led); duration += pushInvertedReverseBits(preData, led); duration += pushReverseBits(pkb.firstCode, led); duration += pushInvertedReverseBits(pkb.firstCode, led); // Finally add the "trail": led.addSingle(trailerPulse); duration += trailerPulse; return duration; }
int AiwaProtocol::generateStandardCommand( const PIRKeyBits &pkb, PIRInfraredLED &led) { int duration = 0; // First, the "header" pulse: led.addPair(headerPulse, headerSpace); duration += (headerPulse + headerSpace); // From the information I've got, the "address" portion of the Aiwa protocol // might be split into 8-bit device and 5-bit subdevice subsections, but // for now, I'm just lumping both into a single 13-bit address value. // The command is an 8-bit value. // As with NEC, the address is sent LSB first, then inverted LSB first, // then the command is sent LSB first, then inverted LSB first. duration += pushReverseBits(preData, led); duration += pushInvertedReverseBits(preData, led); duration += pushReverseBits(pkb.firstCode, led); duration += pushInvertedReverseBits(pkb.firstCode, led); // Finally add the "trail": led.addSingle(trailerPulse); duration += trailerPulse; return duration; }
int ProtonProtocol::generateStandardCommand( const PIRKeyBits &pkb, PIRInfraredLED &led) { int duration = 0; // First, the "header" pulse: led.addPair(headerPulse, headerSpace); duration += (headerPulse + headerSpace); // The Proton protocol contains an 8 bit address and an 8 bit command, // in LSB order. Between these two is a gap made up of a 500 usec pulse // and a 4000 usec space. // - "preData" should contain the address. // - "firstCode" should contain the command. duration += pushReverseBits(preData, led); led.addPair(500, 4000); duration += 4500; duration += pushReverseBits(pkb.firstCode, led); // Finally add the "trail": led.addSingle(trailerPulse); duration += trailerPulse; return duration; }
int DenonProtocol::generateRepeatCommand( const PIRKeyBits &pkb, PIRInfraredLED &led) { int duration = 0; // The address should be 5 bits long, and the control data 8 bits. // For the repeat, the control data is inverted. // Both are sent in LSB order. duration += pushReverseBits(pkb.firstCode, led); duration += pushInvertedReverseBits(pkb.secondCode, led); // Next, two One bits are sent (the inverse of the normal command): led.addPair(onePulse, oneSpace); duration += onePulse + oneSpace; led.addPair(onePulse, oneSpace); duration += onePulse + oneSpace; // Finally add the "trail": led.addSingle(trailerPulse); duration += trailerPulse; return duration; }
int MitsubishiProtocol::generateCommand( const PIRKeyBits &pkb, PIRInfraredLED &led) { int duration = 0; // For this protocol, the device code and command code are both 8 bits, // and sent in LSB order: duration += pushReverseBits(preData, led); duration += pushReverseBits(pkb.firstCode, led); // Finally add the "trail" bit: led.addSingle(trailerPulse); duration += trailerPulse; return duration; }
int NECProtocol::generateStandardCommand( const PIRKeyBits &pkb, PIRInfraredLED &led) { int duration = 0; // First, the "header" pulse: led.addPair(headerPulse, headerSpace); duration += (headerPulse + headerSpace); // Now, check the encoding format: if (isExtendedNEC) { // In extended NEC, the address has been extended to 16 bits, and is only // sent once. The command portion stays the same. // - "preData" should contain 16-bit value // - "bits" should contain 8-bit value duration += pushReverseBits(preData, led); duration += pushReverseBits(pkb.firstCode, led); duration += pushInvertedReverseBits(pkb.firstCode, led); } else { // Standard NEC is made up of an eight-bit "address" and an eight-bit // "command". First the address bits are sent (in reverse order), then // the address bits are inverted and sent again (in reverse order). // Next, we do the same to the command bits. // - "preData" should contain 8-bit value // - "bits" should contain 8-bit value duration += pushReverseBits(preData, led); duration += pushInvertedReverseBits(preData, led); duration += pushReverseBits(pkb.firstCode, led); duration += pushInvertedReverseBits(pkb.firstCode, led); } // Finally add the "trail": led.addSingle(trailerPulse); duration += trailerPulse; return duration; }
int PanasonicProtocol::generateStandardCommand( const PIRKeyBits &pkb, PIRInfraredLED &led) { int duration = 0; // First, the header pulse: led.addPair(headerPulse, headerSpace); duration += (headerPulse + headerSpace); // Similar to the "Kaseikyo" protocol, this protocol is 48 bits long. // In this case, the first 16 bits are a fixed value (defining the // manufacturer?). Next comes eight bits for the "device", eight more // bits for the "subdevice", and then eight bits for the "command". // Finally, the last eight bits are a checksum generated by x-oring the // device, subdevice, and command bytes. // The 16 manufacturer code bits: duration += pushReverseBits(preData, led); // The eight device bits: duration += pushReverseBits(pkb.firstCode, led); // The eight subdevice bits: duration += pushReverseBits(pkb.secondCode, led); // The eight command bits: duration += pushReverseBits(pkb.thirdCode, led); // Finally, the checksum: CommandSequence checksum; generateChecksum(pkb.firstCode, pkb.secondCode, pkb.thirdCode, checksum); duration += pushReverseBits(checksum, led); // Add the trailer pulse: led.addSingle(trailerPulse); duration += trailerPulse; return duration; }
int F12Protocol::generateRepeatableCommand( const PIRKeyBits &pkb, PIRInfraredLED &led) { int duration = 0; // In the F12 protocol, the device code has 3 bits, and the command has 8 // (sort of). In reality, bits 4, 5, and 6 are "mode" bits, but it seems // 5 and 6 get pushed into the two least significant bits of the command // by the sources I've got (the command being sent in LSB mode). This // method is only for "repeatable" commands, so bit 4 is always going to // be "1". // // - "preData" contains 3-bit device code. // - "pkb.firstCode" contains 8-bit command code. duration += pushReverseBits(preData, led); led.addPair(onePulse, oneSpace); duration += (onePulse + oneSpace); duration += pushReverseBits(pkb.firstCode, led); return duration; }
int NECXProtocol::generateStandardCommand( const PIRKeyBits &pkb, PIRInfraredLED &led) { int duration = 0; // First, the "header" pulse: led.addPair(headerPulse, headerSpace); duration += (headerPulse + headerSpace); // In NECX, the address is 16 bits, and is only sent once. The command // portion is 8 bits, and an inverted copy is sent. // - "preData" should contain 16-bit value // - "bits" should contain 8-bit value duration += pushReverseBits(preData, led); duration += pushReverseBits(pkb.firstCode, led); duration += pushInvertedReverseBits(pkb.firstCode, led); // Finally add the "trail": led.addSingle(trailerPulse); duration += trailerPulse; return duration; }
int DenonProtocol::generateCommand( const PIRKeyBits &pkb, PIRInfraredLED &led) { int duration = 0; // The address should be 5 bits long, and the control data 8 bits. // Both are sent in LSB order. duration += pushReverseBits(pkb.firstCode, led); duration += pushReverseBits(pkb.secondCode, led); // Next, two Zero bits are sent: led.addPair(zeroPulse, zeroSpace); duration += zeroPulse + zeroSpace; led.addPair(zeroPulse, zeroSpace); duration += zeroPulse + zeroSpace; // Finally add the "trail": led.addSingle(trailerPulse); duration += trailerPulse; return duration; }
void SamsungACProtocol::generateTimerCommand( PIRInfraredLED &led) { // First, the "header" pulse: led.addPair(headerPulse, headerSpace); // Next, the "address" information (12 bits): pushReverseBits(preData, led); // The checksum (4 bits): CommandSequence checksum; calculateTimerChecksum(checksum); pushReverseBits(checksum, led); // Push an 0xF to indicate this is a timer command. pushBits(timerHeader, led); // if this is an off timer, push the time, otherwise 0: if (timerCommandType == 0x4) { pushReverseBits(timerMinutes, led); pushReverseBits(timerHours, led); } else { pushBits(emptyTimer, led); } // if this is an on timer, push the time, otherwise 0: if (timerCommandType == 0x2) { pushReverseBits(timerMinutes, led); pushReverseBits(timerHours, led); } else { pushBits(emptyTimer, led); } // This is a hack to add in 4 bits of 0: pushBits(fourBitZero, led); // Push the timer command type: pushReverseBits(timerOption, led); // Finish off the command: pushBits(timerFooter, led); // Add the "trail": led.addSingle(trailerPulse); }
void SamsungACProtocol::generateCommand( PIRInfraredLED &led) { // First, the "header" pulse: led.addPair(headerPulse, headerSpace); // Next, the "address" information (12 bits): pushReverseBits(preData, led); // Now, the fun part. We'll need to construct a massive command, containing // all the state information for the air conditioner. // First, calculate and push the checksum (4 bits): CommandSequence checksum; calculateChecksum(checksum); pushReverseBits(checksum, led); // Next, push the swing mode (8 bits): pushReverseBits(swing, led); // Next, the turbo mode (8 bits): pushReverseBits(turbo, led); // Next, the temperature (8 bits): pushReverseBits(temperature, led); // Next, the fan (4 bits): pushReverseBits(fan, led); // Next, the mode (4 bits): pushReverseBits(mode, led); // Next, "air clean" (4 bits): pushReverseBits(airclean, led); // Next, power (4 bits): pushReverseBits(power, led); // Finally add the "trail": led.addSingle(trailerPulse); }
int KathreinProtocol::generateRepeatCommand( const PIRKeyBits &pkb, PIRInfraredLED &led) { int duration = 0; // First, the "header" pulse: led.addPair(headerPulse, headerSpace); duration += (headerPulse + headerSpace); // The Kathrein repeat block contains the 8-bit command and nothing else: duration += pushReverseBits(pkb.firstCode, led); // Finally add the "trail": led.addSingle(trailerPulse); duration += trailerPulse; return duration; }
int BoseProtocol::generateStandardCommand( const PIRKeyBits &pkb, PIRInfraredLED &led) { int duration = 0; // First, the "header" pulse: led.addPair(headerPulse, headerSpace); duration += (headerPulse + headerSpace); // The Bose protocol uses 1/2 of the NEC protocol; it has the command // portion, but no device address portion. So, we only need to reverse // the command, then invert and reverse the command: duration += pushReverseBits(pkb.firstCode, led); duration += pushInvertedReverseBits(pkb.firstCode, led); // Finally add the "trail": led.addSingle(trailerPulse); duration += trailerPulse; return duration; }
int GIProtocol::generateStandardCommand( const PIRKeyBits &pkb, PIRInfraredLED &led) { int duration = 0; // First, the "header" pulse: led.addPair(headerPulse, headerSpace); duration += (headerPulse + headerSpace); // The GI protocol consists of a 4-bit device code and an 8-bit command. // These are sent in reverse order. Finally, a checksum is added at the // end. I am lacking enough information to calculate the checksum right // now, so I'm going to dump all 16 bits into the "firstCode" in MSB // order, and reverse them here: duration += pushReverseBits(pkb.firstCode, led); // Finally add the "trail": led.addSingle(trailerPulse); duration += trailerPulse; return duration; }