Improved to "half-way usable" (version 0.5)
[pierogi] / sharpprotocol.h
1 #ifndef SHARPPROTOCOL_H
2 #define SHARPPROTOCOL_H
3
4 #include "pirprotocol.h"
5 #include "pirrx51hardware.h"
6
7 //
8 // Sharp has its own protocol.  It is "space-encoded", like the popular NEC
9 // protocol (i.e., a 1 takes longer to transmit than a 0), but differs in
10 // several ways.  Most notably, the entire command section of the pulse
11 // train is inverted for each odd-numbered repetition.  Also, there is no
12 // header pulse.
13 //
14
15 class SharpProtocol: public PIRProtocol
16 {
17 public:
18   SharpProtocol(
19     QObject *guiObject,
20     unsigned int index,
21     bool expBit);
22
23 public slots:
24   void startSendingCommand(
25     unsigned int threadableID,
26     PIRKeyName command);
27
28 private:
29   // First, define what is used to represent 0 and 1:
30   unsigned int zeroPulse;
31   unsigned int zeroSpace;
32   unsigned int onePulse;
33   unsigned int oneSpace;
34
35   // A tailing on-request, not followed by a specific off time:
36   unsigned int trailerPulse;
37
38   // An "expansion bit".  Not sure what this is, but Sharp seems to leave it
39   // at 1, and Denon usually sets it to 0.
40   bool expansionBit;
41
42   int generateStandardCommand(
43     const CommandSequence &bits,
44     PIRRX51Hardware &device);
45
46   int generateToggledCommand(
47     const CommandSequence &bits,
48     PIRRX51Hardware &device);
49
50   int pushBits(
51     CommandSequence::const_reverse_iterator i,
52     CommandSequence::const_reverse_iterator end,
53     PIRRX51Hardware &device);
54
55   int pushInvertedBits(
56     CommandSequence::const_reverse_iterator i,
57     CommandSequence::const_reverse_iterator end,
58     PIRRX51Hardware &device);
59 };
60
61 #endif // SHARPPROTOCOL_H