Still fixing install, more keyset work
[pierogi] / necprotocol.h
1 #ifndef NECPROTOCOL_H
2 #define NECPROTOCOL_H
3
4 #include "pirprotocol.h"
5 #include "pirrx51hardware.h"
6
7 //
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.
11 //
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...
15 //
16
17 class NECProtocol: public PIRProtocol
18 {
19 public:
20   // An NEC protocol will always have differing times for "zero" and "one".
21   // Also, all protocols have some space set between commands.  However,
22   // some protocols specify a fixed delay between the end of one
23   // command and the start of the next, and others specify each command be
24   // started at a precise interval (so the spacing between the end of one
25   // and the start of another may vary).
26
27   // Constructor for standard NEC:
28   NECProtocol(
29     QObject *guiObject,
30     unsigned int index);
31
32   // Constructor for non-standard NEC:
33   NECProtocol(
34     QObject *guiObject,
35     unsigned int index,
36     unsigned int zPulse,
37     unsigned int zSpace,
38     unsigned int oPulse,
39     unsigned int oSpace,
40     unsigned int gapSpace,
41     bool iclflag);
42
43   void setHeaderPair(
44     unsigned int pulse,
45     unsigned int space);
46
47   void setTrailerPulse(
48     unsigned int pulse);
49
50   void setRepeatPair(
51     unsigned int pulse,
52     unsigned int space);
53
54   void setRepeatNeedsHeader(
55     bool flag);
56
57   void setFullHeadlessRepeat(
58     bool flag);
59
60   void setElevenBitToggle(
61     bool flag);
62
63 public slots:
64   void startSendingCommand(
65     unsigned int threadableID,
66     PIRKeyName command);
67
68 private:
69   // First, define what is used to represent 0 and 1:
70   unsigned int zeroPulse;
71   unsigned int zeroSpace;
72   unsigned int onePulse;
73   unsigned int oneSpace;
74
75   // Some administrative data that most NEC Protocol remotes have:
76   unsigned int headerPulse;
77   unsigned int headerSpace;
78   bool hasHeaderPair;
79
80   // A tailing on-request, not followed by a specific off time:
81   unsigned int trailerPulse;
82   bool hasTrailerPulse;
83
84   // Each remote key has a unique command sequence:
85 //  KeyCommandMap commands;
86
87   // A pulse that means "repeat the last command":
88   unsigned int repeatPulse;
89   unsigned int repeatSpace;
90   bool hasRepeatPair;
91   bool repeatNeedsHeader; // Put the header ahead of the repeat pulse
92   bool fullHeadlessRepeat; // Repeat full command but without header
93   bool elevenBitToggle; // A few remotes toggle the last eleven bits on repeat
94
95   int generateStandardCommand(
96     const CommandSequence &bits,
97     PIRRX51Hardware &device);
98
99   int generateHeadlessCommand(
100     const CommandSequence &bits,
101     PIRRX51Hardware &device);
102
103   int generateRepeatCommand(
104     PIRRX51Hardware &device);
105
106   int generateToggledCommand(
107     const CommandSequence &bits,
108     PIRRX51Hardware &device);
109
110   int pushBits(
111     const CommandSequence &bits,
112     PIRRX51Hardware &device);
113 };
114
115 #endif // NECPROTOCOL_H