-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpirprotocol.h
230 lines (182 loc) · 5.57 KB
/
pirprotocol.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
//
// pirprotocol.h
//
// Copyright 2012 - 2015 by John Pietrzak ([email protected])
//
// This file is part of Pierogi.
//
// Pierogi is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// Pierogi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#ifndef PIRPROTOCOL_H
#define PIRPROTOCOL_H
// The generic remote controller.
#include <iostream>
//#include <QObject>
#include "pirkeynames.h"
//#include "piracstateinfo.h"
#include <map>
#include <deque>
// We'll define a maximum number of repetitions, regardless of how long the
// user presses the button. (This is just in case we miss the point at which
// he stops pressing it...) 500 should be plenty.
//#define MAX_REPEAT_COUNT 500
#define MAX_REPEAT_COUNT 1
//class QString;
typedef std::deque<bool> CommandSequence;
// As I've learned more about IR protocols, the concept of what a specific
// key is gets more and more complex. To deal with this, I'm going to allow
// a key to have more than one command sequence associated with it. (I need
// up to three codes for Sony keys, and as many as four to define an
// individual Pioneer key.)
class PIRKeyBits
{
public:
CommandSequence firstCode;
CommandSequence secondCode;
CommandSequence thirdCode;
CommandSequence fourthCode;
};
// I'll go ahead and use associative arrays to build up lists of keycodes.
typedef std::map<int, PIRKeyBits> KeycodeCollection;
// Right now, the only reason for this object to inherit from QObject is
// so it can participate in Qt-style threading. Note that it has no
// event loop, and no access to the GUI, so don't go trying to communicate
// with the user here...
//class PIRProtocol: public QObject
class PIRProtocol
{
// Q_OBJECT
public:
PIRProtocol(
// QObject *guiObject,
unsigned int index,
unsigned int gSpace,
bool iclflag);
unsigned int getCarrierFrequency() const;
void setCarrierFrequency(
unsigned int cf);
unsigned int getDutyCycle() const;
void setDutyCycle(
unsigned int dc);
void addKey(
PIRKeyName key,
unsigned long data,
unsigned int size);
// A special addKey used for Sony's SIRC protocol:
void addSIRCKey(
PIRKeyName key,
unsigned int addressData,
unsigned int size,
unsigned int commandData);
void addSIRC20Key(
PIRKeyName key,
unsigned int secondaryAddressData,
unsigned int primaryAddressData,
unsigned int commandData);
void addSharpKey(
PIRKeyName key,
unsigned int addressData,
unsigned int commandData);
void addNECKey(
PIRKeyName key,
unsigned int addressData,
unsigned int commandData);
void addPanOldKey(
PIRKeyName key,
unsigned int addressData,
unsigned int commandData);
void addPioneerKey(
PIRKeyName key,
unsigned int firstAddress,
unsigned int firstCommand,
unsigned int secondAddress,
unsigned int secondCommand);
/*
void addRCAKey(
PIRKeyName key,
unsigned int addressData,
unsigned int commandData);
*/
void addKaseikyoKey(
PIRKeyName key,
unsigned int addressData,
unsigned int commandData);
void addPanasonicKey(
PIRKeyName key,
unsigned int deviceData,
unsigned int subdeviceData,
unsigned int commandData);
void addDishKey(
PIRKeyName key,
unsigned int firstCommand,
unsigned int secondCommand);
void addXMPKey(
PIRKeyName key,
unsigned int firstCommand,
unsigned int secondCommand);
void setMinimumRepetitions(
unsigned int minrep);
void setPreData(
unsigned long data,
unsigned int bits);
void setPostData(
unsigned long data,
unsigned int bits);
//public slots:
virtual void startSendingCommand(
unsigned int threadableID,
PIRKeyName command) = 0;
// This slot can be ignored by most non-ac protocols:
// virtual void startSendingStateInfo(
// PIRACStateInfo state,
// unsigned int threadableID,
// PIRKeyName command);
//signals:
// void errorMessage(
// QString errStr);
protected:
bool isCommandSupported(
PIRKeyName command);
void clearRepeatFlag();
bool checkRepeatFlag();
unsigned int carrierFrequency;
unsigned int dutyCycle;
void appendToBitSeq(
CommandSequence &bits,
unsigned int code,
int size);
KeycodeCollection keycodes;
// A sleep function for all protocols:
void sleepUntilRepeat(
int commandDuration);
// The "gap" parameter from LIRC. If the commands are "variable-length",
// this indicates the amount of time between the last pulse of one
// command and the first pulse of the next. If "constant-length", it is
// the time between the _first_ pulse of one command and the first pulse
// of the next.
void setGapSize(
int gapSize,
bool iclFlag);
bool isConstantLength;
int gap;
// More administrative data wrapped around the actual command:
CommandSequence preData;
CommandSequence postData;
// Some remotes require a minimum number of repetitions:
// Note: thinking about removing this -- don't know if it is needed
int minimumRepetitions;
unsigned int id;
};
#endif // PIRPROTOCOL_H