Improved to "half-way usable" (version 0.5)
[pierogi] / pirrx51hardware.h
1 #ifndef PIRRX51HARDWARE_H
2 #define PIRRX51HARDWARE_H
3
4 //
5 // Encapsulates communication with the N900's IR hardware, using the LIRC
6 // device that (hopefully) exists on all N900s.
7 //
8
9 // To my current knowledge, you can send a maximum of 256 integers to the 
10 // N900's IR device driver, so that's probably a good limit to set:
11 #define BUFFER_SIZE 256
12
13 class PIRRX51Hardware
14 {
15 public:
16   PIRRX51Hardware();
17
18   PIRRX51Hardware(
19     unsigned int frequency,
20     unsigned int dutyCycle);
21
22   ~PIRRX51Hardware();
23
24   // Most remotes will just want to append pairs of on/off times:
25   void addPair(
26     int pulse,
27     int space);
28
29   // Some remotes need to specify the switching values individually:
30   void addSingle(
31     int single);
32
33   // Send the buffered pulses to the IR device:
34   void sendCommandToDevice();
35
36   void setCarrierFrequency(
37     unsigned int frequency);
38
39   void setDutyCycle(
40     unsigned int dutyCycle);
41
42 private:
43   void openLircDevice();
44
45   int fileDescriptor;
46
47   int buffer[BUFFER_SIZE];
48   int index;
49 };
50
51 #endif // PIRRX51HARDWARE_H