Still fixing install, more keyset work
[pierogi] / rc5protocol.h
1 #ifndef RC5PROTOCOL_H
2 #define RC5PROTOCOL_H
3
4 #include "pirprotocol.h"
5 #include "pirrx51hardware.h"
6
7 //
8 // The RC5 protocol is not as widespread as the NEC protocol, but still
9 // somewhat popular.  Philips, the inventor, uses it extensively.
10 //
11
12 class RC5Protocol: public PIRProtocol
13 {
14 public:
15   RC5Protocol(
16     QObject *guiObject,
17     unsigned int index,
18     unsigned int bPulse,
19     unsigned int bSpace,
20     unsigned int lPulse,
21     unsigned int gSpace,
22     bool iclflag);
23
24   void setHeaderPair(
25     unsigned int pulse,
26     unsigned int space);
27
28   void setToggleBit(
29     unsigned int bit);
30
31 public slots:
32   void startSendingCommand(
33     unsigned int threadableID,
34     PIRKeyName command);
35
36 protected:
37   unsigned int biphasePulse;
38   unsigned int biphaseSpace;
39
40   unsigned int leadPulse;
41
42   unsigned int headerPulse;
43   unsigned int headerSpace;
44   bool hasHeaderPair;
45
46   // The original RC-5 specification marks a single bit as a "toggle bit",
47   // which should be inverted on each separate keypress.  This was originally
48   // the third bit, but apparently some remotes invert a different bit.
49   // If set to 0, then no bits are inverted.
50   int toggleBit;
51
52 private:
53   int pushBits(
54     const CommandSequence &bits,
55     PIRRX51Hardware &device);
56
57   unsigned int buffer;
58   int keypressCount;
59
60   // Only one of the following can be true, but both can be false:
61   bool bufferContainsSpace;
62   bool bufferContainsPulse;
63 };
64
65 #endif // RC5PROTOCOL_H