-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpirinfraredled.h
84 lines (65 loc) · 1.98 KB
/
pirinfraredled.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
//
// pirinfraredled.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 PIRINFRAREDLED_H
#define PIRINFRAREDLED_H
#include <iostream>
//#include <QObject>
//
// Encapsulates communication with the N900's IR hardware, using the LIRC
// device that (hopefully) exists on all N900s.
//
// To my current knowledge, you can send a maximum of 256 integers to the
// N900's IR device driver, so that's probably a good limit to set:
#define BUFFER_SIZE 256
//class PIRInfraredLED: public QObject
class PIRInfraredLED
{
// Q_OBJECT
public:
PIRInfraredLED();
PIRInfraredLED(
unsigned int frequency,
unsigned int dutyCycle);
~PIRInfraredLED();
// Most remotes will just want to append pairs of on/off times:
bool addPair(
int pulse,
int space);
// Some remotes need to specify the switching values individually:
bool addSingle(
int single);
// Send the buffered pulses to the IR device:
bool sendCommandToDevice();
bool setCarrierFrequency(
unsigned int frequency);
bool setDutyCycle(
unsigned int dutyCycle);
//signals:
// void errorMessage(
// QString errStr);
private:
bool openLircDevice();
int fileDescriptor;
int buffer[BUFFER_SIZE];
int index;
};
#endif // PIRINFRAREDLED_H