Infrared4Arduino
IrReceiver.h
Go to the documentation of this file.
1 #ifndef IRRECEIVER_H
2 #define IRRECEIVER_H
3 
4 #include <Arduino.h>
5 #include "InfraredTypes.h"
6 #include "IrReader.h"
7 
11 class IrReceiver : public IrReader {
12 private:
14  pin_t pin;
15 
16 public:
17  // Default values
18  static const pin_t defaultPin = 5;
19  static const microseconds_t defaultMarkExcess = 50U;
20 
22  static const boolean invertingSensor = true;
23 
32  IrReceiver(size_t bufSize, pin_t pin, boolean pullup = false,
33  microseconds_t markExcess = defaultMarkExcess);
34 
35  virtual ~IrReceiver() {
36  };
37 
38  virtual void receive();
39 
40  pin_t getPin() const {
41  return pin;
42  }
43 
47  enum irdata_t {
50  };
51 
52  // Needs to be public since used in ISP. Therefore hide it from Doxygen
54  irdata_t readIr() {
55  return ((digitalRead(getPin()) == HIGH) ^ invertingSensor) ? IR_MARK : IR_SPACE;
56  }
58 };
59 
60 #endif /* IRRECEIVER_H */
off-period, also called gap
Definition: IrReceiver.h:49
virtual ~IrReceiver()
Definition: IrReceiver.h:35
pin_t getPin() const
Definition: IrReceiver.h:40
uint16_t microseconds_t
Type for durations in micro seconds.
Definition: InfraredTypes.h:16
static const microseconds_t defaultMarkExcess
Definition: IrReceiver.h:19
uint8_t pin_t
Type for GPIO pin, compatible with Arduino libs.
Definition: InfraredTypes.h:40
virtual void receive()
Convenience function: enable, wait until data is collected or timeout has occured, disable.
Definition: IrReceiver.cpp:9
irdata_t
Enum for the duration types.
Definition: IrReceiver.h:47
Abstract base class for demodulating IR receivers.
Definition: IrReceiver.h:11
Abstract base class for all IR readers, capturing or receiving.
Definition: IrReader.h:30
on-period, also called flash
Definition: IrReceiver.h:48
static const pin_t defaultPin
Definition: IrReceiver.h:18
This file defines some general data types that are used in the library.
static const boolean invertingSensor
Are we using inverting sensor, like most TSOPs?
Definition: IrReceiver.h:22
int16_t markExcess
Microseconds subtracted from pulses and added to gaps.
Definition: IrReader.h:44
IrReceiver(size_t bufSize, pin_t pin, boolean pullup=false, microseconds_t markExcess=defaultMarkExcess)
Constructor.
Definition: IrReceiver.cpp:3