Improved to "half-way usable" (version 0.5)
[pierogi] / sircprotocol.h
1 #ifndef SIRCPROTOCOL_H
2 #define SIRCPROTOCOL_H
3
4 #include "pirprotocol.h"
5 #include "pirrx51hardware.h"
6
7 //
8 // The SIRC protocol is Sony's system for transmitting information via
9 // infrared light.  As with the very popular "NEC" protocol, binary data is
10 // encoded by varying the amount of time each bit is held: a zero is held for
11 // a short span of time, a one lasts a little bit longer.
12 //
13 // Currently, there seem to be three types of SIRC commands; 12 bit, 15 bit,
14 // and 20 bit.  In each type, it appears the last seven bits specify the
15 // command, and the rest specify the device being addressed.  (The bits are
16 // passed in reverse order in the actual IR stream.)
17 //
18 // The marvelous thing about the Sony Infrared Remote Control protocol is just
19 // how simple and easy it is; just a header pulse, the command, the address,
20 // and a trailer pulse.  The terrible thing about the protocol is that Sony
21 // has given up on following their own rules.  Sony devices today regularly
22 // support commands from a variety of addresses, making the whole concept of
23 // the "address" kind of meaningless. :(  I can see why the LIRC guys would
24 // give up and just encode the raw IR bits, rather than wade into this mess...
25 //
26
27 class SIRCProtocol: public PIRProtocol
28 {
29 public:
30   SIRCProtocol(
31     QObject *guiObject,
32     unsigned int index);
33
34 public slots:
35   void startSendingCommand(
36     unsigned int threadableID,
37     PIRKeyName command);
38
39 private:
40   unsigned int zeroPulse;
41   unsigned int zeroSpace;
42   unsigned int onePulse;
43   unsigned int oneSpace;
44
45   unsigned int headerPulse;
46   unsigned int headerSpace;
47
48   int generateStandardCommand(
49     const CommandSequence &bits,
50     PIRRX51Hardware &device);
51
52   int pushReverseBits(
53     const CommandSequence &bits,
54     PIRRX51Hardware &device);
55 };
56
57 #endif // SIRCPROTOCOL_H