Infrared4Arduino 1.2.3
Loading...
Searching...
No Matches
IrReader.cpp
Go to the documentation of this file.
1/*
2Copyright (C) 2015 Bengt Martensson.
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation; either version 2 of the License, or (at
7your option) any later version.
8
9This program is distributed in the hope that it will be useful, but
10WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12General Public License for more details.
13
14You should have received a copy of the GNU General Public License along with
15this program. If not, see http://www.gnu.org/licenses/.
16*/
17
18#include "IrReader.h"
19
20// Cannot use IrSequence.dump directly!
21void IrReader::dump(Stream &stream) const {
22 size_t count = getDataLength();
23 for (unsigned int i = 0U; i < count; i++) {
24 if (i > 0U)
25 stream.print(" ");
26 stream.print((i & 1U) ? '-' : '+');
27 stream.print(getDuration(i), DEC);
28 }
29}
30
33 for (unsigned int i = 0; i < getDataLength(); i++)
34 durations[i] = getDuration(i);
35 return new IrSequence(durations, getDataLength());
36}
uint16_t microseconds_t
Type for durations in micro seconds.
Definition: InfraredTypes.h:15
virtual size_t getDataLength() const =0
Returns the number of collected durations.
IrSequence * toIrSequence() const
Generates an IrSequence from the IrReader.
Definition: IrReader.cpp:31
virtual void dump(Stream &stream) const
Prints a textual representation of the received data to the Stream supplied.
Definition: IrReader.cpp:21
virtual microseconds_t getDuration(unsigned int index) const =0
Returns the index-th duration, if possible.
This class consists of a vector of durations.
Definition: IrSequence.h:11