4 #include "pirprotocol.h"
5 #include "pirrx51hardware.h"
8 // The "NEC" Protocol is, more or less, followed by the majority of
9 // remotes defined in the LIRC config files, which means it is probably
10 // followed by most of the remotes out there.
12 // Remotes using this protocol seem to use a frequency of 38000 Hz, lead off
13 // each command with a signal that should be unique to the manufacturer,
14 // and mostly define 0s and 1s by the length of time between pulses...
18 // There exist two well-defined NEC protocols: "standard" and "extended".
19 // Some remotes might not fit into either format; LIRC has given up and
20 // simply recorded the exact set of IR pulses as bits, rather than attempt
21 // to follow the standard encodings. I'll use the following enum to
22 // describe which mechanism the key data follows:
32 class NECProtocol: public PIRProtocol
35 // An NEC protocol will always have differing times for "zero" and "one".
36 // Also, all protocols have some space set between commands. However,
37 // some protocols specify a fixed delay between the end of one
38 // command and the start of the next, and others specify each command be
39 // started at a precise interval (so the spacing between the end of one
40 // and the start of another may vary).
42 // Constructor for standard NEC:
48 // Constructor for non-standard NEC:
56 unsigned int gapSpace,
71 void setRepeatNeedsHeader(
74 void setFullHeadlessRepeat(
77 void setElevenBitToggle(
81 void startSendingCommand(
82 unsigned int threadableID,
86 // First, define what is used to represent 0 and 1:
87 unsigned int zeroPulse;
88 unsigned int zeroSpace;
89 unsigned int onePulse;
90 unsigned int oneSpace;
92 // Some administrative data that most NEC Protocol remotes have:
93 unsigned int headerPulse;
94 unsigned int headerSpace;
97 // A tailing on-request, not followed by a specific off time:
98 unsigned int trailerPulse;
101 // A pulse that means "repeat the last command":
102 unsigned int repeatPulse;
103 unsigned int repeatSpace;
105 bool repeatNeedsHeader; // Put the header ahead of the repeat pulse
106 bool fullHeadlessRepeat; // Repeat full command but without header
107 bool elevenBitToggle; // A few remotes toggle the last eleven bits on repeat
109 // A flag used to determine how to encode the bits:
110 NECKeyFormat encodingFormat;
112 int generateStandardCommand(
113 const CommandSequence &bits,
114 PIRRX51Hardware &device);
116 int generateHeadlessCommand(
117 const CommandSequence &bits,
118 PIRRX51Hardware &device);
120 int generateRepeatCommand(
121 PIRRX51Hardware &device);
123 int generateToggledCommand(
124 const CommandSequence &bits,
125 PIRRX51Hardware &device);
128 const CommandSequence &bits,
129 PIRRX51Hardware &device);
132 const CommandSequence &bits,
133 PIRRX51Hardware &device);
135 int pushInvertedReverseBits(
136 const CommandSequence &bits,
137 PIRRX51Hardware &device);
140 #endif // NECPROTOCOL_H