Infrared4Arduino 1.2.3
Loading...
Searching...
No Matches
IrReceiver.h
Go to the documentation of this file.
1#pragma once
2
3#include <Arduino.h>
4#include "InfraredTypes.h"
5#include "IrReader.h"
6#include "IrSignal.h"
7#include "Board.h"
8
12class IrReceiver : public IrReader {
13private:
15 pin_t pin;
16
17public:
18 // Default values
19 static constexpr pin_t defaultPin = 5;
20 static constexpr microseconds_t defaultMarkExcess = 50U;
21
23 static constexpr bool invertingSensor = true;
24
33 IrReceiver(size_t bufSize, pin_t pin, bool pullup = false,
35
36 virtual ~IrReceiver() {
37 };
38
39 virtual frequency_t getFrequency() const {
41 };
42
43 virtual void receive();
44
45 pin_t getPin() const {
46 return pin;
47 }
48
52 enum irdata_t {
55 };
56
57 // Needs to be public since used in ISP. Therefore hide it from Doxygen
59 irdata_t readIr() {
60 return (Board::getInstance()->readDigital(getPin()) ^ invertingSensor) ? IR_MARK : IR_SPACE;
61 }
63};
This file defines some general data types that are used in the library.
uint16_t microseconds_t
Type for durations in micro seconds.
Definition: InfraredTypes.h:15
uint32_t frequency_t
Type for modulation frequency in Hz.
Definition: InfraredTypes.h:31
uint8_t pin_t
Type for GPIO pin, compatible with Arduino libs.
Definition: InfraredTypes.h:41
static Board * getInstance()
Definition: Board.h:53
Abstract base class for all IR readers, capturing or receiving.
Definition: IrReader.h:30
int16_t markExcess
Microseconds subtracted from pulses and added to gaps.
Definition: IrReader.h:44
Abstract base class for demodulating IR receivers.
Definition: IrReceiver.h:12
static constexpr bool invertingSensor
Are we using inverting sensor, like most TSOPs?
Definition: IrReceiver.h:23
static constexpr microseconds_t defaultMarkExcess
Definition: IrReceiver.h:20
virtual frequency_t getFrequency() const
Returns frequency of received signal.
Definition: IrReceiver.h:39
pin_t getPin() const
Definition: IrReceiver.h:45
virtual void receive()
Convenience function: enable, wait until data is collected or timeout has occured,...
Definition: IrReceiver.cpp:9
irdata_t
Enum for the duration types.
Definition: IrReceiver.h:52
@ IR_SPACE
off-period, also called gap
Definition: IrReceiver.h:54
@ IR_MARK
on-period, also called flash
Definition: IrReceiver.h:53
virtual ~IrReceiver()
Definition: IrReceiver.h:36
static constexpr pin_t defaultPin
Definition: IrReceiver.h:19
static constexpr frequency_t defaultFrequency
Definition: IrSignal.h:13