DevSlashLirc
LircT.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <linux/lirc.h>
4 #include <iostream>
5 
6 #include "InfraredTypes.h"
7 
9 class LircT {
10 private:
11  lirc_t data;
13  static const lirc_t MAXDURATION = 0xFFFFFFU;
14 
15 public:
16 
17  typedef enum {
18  SPACE = LIRC_MODE2_SPACE,
19  PULSE = LIRC_MODE2_PULSE,
20  FREQUENCY = LIRC_MODE2_FREQUENCY,
21  TIMEOUT = LIRC_MODE2_TIMEOUT
22  } LircTType;
23 
24  LircT(lirc_t data);
25  LircT(microseconds_t data, LircTType type);
26  LircT(const LircT& orig);
27  virtual ~LircT();
28 
30  return (microseconds_t) (data & LIRC_VALUE_MASK);
31  }
32 
33  bool isSpace() const {
34  return LIRC_IS_SPACE(data);
35  }
36 
37  bool isPulse() const {
38  return LIRC_IS_PULSE(data);
39  }
40 
41  bool isFrequency() const {
42  return LIRC_IS_FREQUENCY(data);
43  }
44 
45  bool isTimeout() const {
46  return LIRC_IS_TIMEOUT(data);
47  }
48 
49  bool isTerminal() const {
50  return isTimeout() || (lirc_t) getDuration() == MAXDURATION;
51  }
52 
53  void dump(std::ostream& stream = std::cout) const;
54 
55  // Static versions
56  static microseconds_t getDuration(lirc_t t) {
57  return (microseconds_t) (t & LIRC_VALUE_MASK);
58  }
59 
60  static bool isSpace(lirc_t t) {
61  return LIRC_IS_SPACE(t);
62  }
63 
64  static bool isPulse(lirc_t t) {
65  return LIRC_IS_PULSE(t);
66  }
67 
68  static bool isFrequency(lirc_t t) {
69  return LIRC_IS_FREQUENCY(t);
70  }
71 
72  static bool isTimeout(lirc_t t) {
73  return LIRC_IS_TIMEOUT(t);
74  }
75 
76  static bool isTerminal(lirc_t t) {
77  return isTimeout(t) || (lirc_t) getDuration(t) == MAXDURATION;
78  }
79 
80  static void dump(lirc_t t, std::ostream& stream = std::cout) {
81  (new LircT(t))->dump(stream);
82  }
83 };
void dump(std::ostream &stream=std::cout) const
Definition: LircT.cpp:19
static bool isFrequency(lirc_t t)
Definition: LircT.h:68
bool isPulse() const
Definition: LircT.h:37
This is the class version of lirc_t, defined in lirc.h.
Definition: LircT.h:9
microseconds_t getDuration() const
Definition: LircT.h:29
static bool isTimeout(lirc_t t)
Definition: LircT.h:72
virtual ~LircT()
Definition: LircT.cpp:16
bool isTimeout() const
Definition: LircT.h:45
bool isTerminal() const
Definition: LircT.h:49
uint32_t microseconds_t
Type for durations in micro seconds.
Definition: InfraredTypes.h:20
static bool isSpace(lirc_t t)
Definition: LircT.h:60
static bool isTerminal(lirc_t t)
Definition: LircT.h:76
LircT(lirc_t data)
Definition: LircT.cpp:3
This file defines some general data types that are used in the library.
static void dump(lirc_t t, std::ostream &stream=std::cout)
Definition: LircT.h:80
static bool isPulse(lirc_t t)
Definition: LircT.h:64
static microseconds_t getDuration(lirc_t t)
Definition: LircT.h:56
bool isSpace() const
Definition: LircT.h:33
bool isFrequency() const
Definition: LircT.h:41
LircTType
Definition: LircT.h:17