Fixed installation and nasty exit bug
[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 apparently quite a bit older than the NEC protocol, but
9 // not as widespread.  Still, it continues to be in use, as I've seen
10 // by my Elgato "Eye TV" remote control.
11 //
12
13 class RC5Protocol: public PIRProtocol
14 {
15 public:
16   RC5Protocol(
17     QObject *guiObject,
18     unsigned int index,
19     unsigned int bPulse,
20     unsigned int bSpace,
21     unsigned int lPulse,
22     unsigned int gSpace,
23     bool iclflag);
24
25   void setHeaderPair(
26     unsigned int pulse,
27     unsigned int space);
28
29   void setPreData(
30     unsigned long data,
31     unsigned int bits);
32
33   void setToggleBit(
34     unsigned int bit);
35
36 public slots:
37   void startSendingCommand(
38     unsigned int threadableID,
39     PIRKeyName command);
40
41 protected:
42   unsigned int biphasePulse;
43   unsigned int biphaseSpace;
44
45   unsigned int leadPulse;
46
47   unsigned int headerPulse;
48   unsigned int headerSpace;
49   bool hasHeaderPair;
50
51   CommandSequence preData;
52 //  CommandSequence postData;
53
54 //  int trail;
55
56   // The original RC-5 specification marks a single bit as a "toggle bit",
57   // which should be inverted on each separate keypress.  This was originally
58   // the third bit, but apparently some remotes invert a different bit.
59   // If set to 0, then no bits are inverted.
60   int toggleBit;
61
62 private:
63   int pushBits(
64     const CommandSequence &bits,
65     PIRRX51Hardware &device);
66
67   unsigned int buffer;
68   int keypressCount;
69
70   // Only one of the following can be true, but both can be false:
71   bool bufferContainsSpace;
72   bool bufferContainsPulse;
73 };
74
75 #endif // RC5PROTOCOL_H