Infrared4Arduino
IrSender.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2015 Bengt Martensson.
3 
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at
7 your option) any later version.
8 
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along with
15 this program. If not, see http://www.gnu.org/licenses/.
16 */
17 
18 #pragma once
19 
20 #include "InfraredTypes.h"
21 #include "IrSignal.h"
22 
26 class IrSender {
27 private:
28  pin_t outputPin;
29 
30 protected:
31  pin_t getOutputPin() const {
32  return outputPin;
33  }
34  void delayUSecs(microseconds_t T);
35  IrSender();
36  IrSender(pin_t pin);
37 
38 public:
39  virtual ~IrSender();
40 
46  virtual void send(const IrSequence& irSequence, frequency_t frequency = IrSignal::defaultFrequency) = 0;
47 
56  void sendIrSignal(const IrSignal& irSignal, unsigned int noSends = 1);
57 
63  void sendWhile(const IrSignal& irSignal, bool(*trigger)());
64 
65 // TODO:
66 // /**
67 // * Send an IrSignal, when and as long as buttonPin is LOW.
68 // * @param irSignal
69 // * @param buttonPin
70 // */
71 // void sendWhilePinLow(const IrSignal& irSignal, pin_t buttonPin);
72 
74  virtual void mute();
75 };
static const frequency_t defaultFrequency
Definition: IrSignal.h:12
void sendWhile(const IrSignal &irSignal, bool(*trigger)())
Send an IrSignal, when and as long as trigger() returns true.
Definition: IrSender.cpp:62
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:32
uint8_t pin_t
Type for GPIO pin, compatible with Arduino libs.
Definition: InfraredTypes.h:37
This class models an IR signal with intro-, repeat-, and ending sequences.
Definition: IrSignal.h:10
Abstract base class for all sending classes.
Definition: IrSender.h:26
void delayUSecs(microseconds_t T)
Definition: IrSender.cpp:25
pin_t getOutputPin() const
Definition: IrSender.h:31
virtual void send(const IrSequence &irSequence, frequency_t frequency=IrSignal::defaultFrequency)=0
Sends an IrSequence with the prescribed frequency.
This class consists of a vector of durations.
Definition: IrSequence.h:11
This file defines some general data types that are used in the library.
virtual void mute()
Send an IrSignal, when and as long as buttonPin is LOW.
Definition: IrSender.cpp:49
virtual ~IrSender()
Definition: IrSender.cpp:45
IrSender()
Definition: IrSender.cpp:35
void sendIrSignal(const IrSignal &irSignal, unsigned int noSends=1)
Sends the IrSignal given as argument the prescribed number of times.
Definition: IrSender.cpp:53