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 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 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 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 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; }