|
@@ -1,84 +0,0 @@
|
1
|
|
-/*
|
2
|
|
-Streaming.h - Arduino library for supporting the << streaming operator
|
3
|
|
-Copyright (c) 2010 Mikal Hart. All rights reserved.
|
4
|
|
-
|
5
|
|
-This library is free software; you can redistribute it and/or
|
6
|
|
-modify it under the terms of the GNU Lesser General Public
|
7
|
|
-License as published by the Free Software Foundation; either
|
8
|
|
-version 2.1 of the License, or (at your option) any later version.
|
9
|
|
-
|
10
|
|
-This library is distributed in the hope that it will be useful,
|
11
|
|
-but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
|
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
|
-Lesser General Public License for more details.
|
14
|
|
-
|
15
|
|
-You should have received a copy of the GNU Lesser General Public
|
16
|
|
-License along with this library; if not, write to the Free Software
|
17
|
|
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
|
-*/
|
19
|
|
-
|
20
|
|
-#ifndef ARDUINO_STREAMING
|
21
|
|
-#define ARDUINO_STREAMING
|
22
|
|
-
|
23
|
|
-//#include <WProgram.h>
|
24
|
|
-
|
25
|
|
-#define STREAMING_LIBRARY_VERSION 4
|
26
|
|
-
|
27
|
|
-// Generic template
|
28
|
|
-template<class T>
|
29
|
|
-inline Print &operator <<(Print &stream, T arg)
|
30
|
|
-{ stream.print(arg); return stream; }
|
31
|
|
-
|
32
|
|
-struct _BASED
|
33
|
|
-{
|
34
|
|
- long val;
|
35
|
|
- int base;
|
36
|
|
- _BASED(long v, int b): val(v), base(b)
|
37
|
|
- {}
|
38
|
|
-};
|
39
|
|
-
|
40
|
|
-#define _HEX(a) _BASED(a, HEX)
|
41
|
|
-#define _DEC(a) _BASED(a, DEC)
|
42
|
|
-#define _OCT(a) _BASED(a, OCT)
|
43
|
|
-#define _BIN(a) _BASED(a, BIN)
|
44
|
|
-#define _BYTE(a) _BASED(a, BYTE)
|
45
|
|
-
|
46
|
|
-// Specialization for class _BASED
|
47
|
|
-// Thanks to Arduino forum user Ben Combee who suggested this
|
48
|
|
-// clever technique to allow for expressions like
|
49
|
|
-// Serial << _HEX(a);
|
50
|
|
-
|
51
|
|
-inline Print &operator <<(Print &obj, const _BASED &arg)
|
52
|
|
-{ obj.print(arg.val, arg.base); return obj; }
|
53
|
|
-
|
54
|
|
-#if ARDUINO >= 18
|
55
|
|
-// Specialization for class _FLOAT
|
56
|
|
-// Thanks to Michael Margolis for suggesting a way
|
57
|
|
-// to accommodate Arduino 0018's floating point precision
|
58
|
|
-// feature like this:
|
59
|
|
-// Serial << _FLOAT(gps_latitude, 6); // 6 digits of precision
|
60
|
|
-
|
61
|
|
-struct _FLOAT
|
62
|
|
-{
|
63
|
|
- float val;
|
64
|
|
- int digits;
|
65
|
|
- _FLOAT(double v, int d): val(v), digits(d)
|
66
|
|
- {}
|
67
|
|
-};
|
68
|
|
-
|
69
|
|
-inline Print &operator <<(Print &obj, const _FLOAT &arg)
|
70
|
|
-{ obj.print(arg.val, arg.digits); return obj; }
|
71
|
|
-#endif
|
72
|
|
-
|
73
|
|
-// Specialization for enum _EndLineCode
|
74
|
|
-// Thanks to Arduino forum user Paul V. who suggested this
|
75
|
|
-// clever technique to allow for expressions like
|
76
|
|
-// Serial << "Hello!" << endl;
|
77
|
|
-
|
78
|
|
-enum _EndLineCode { endl };
|
79
|
|
-
|
80
|
|
-inline Print &operator <<(Print &obj, _EndLineCode arg)
|
81
|
|
-{ obj.println(); return obj; }
|
82
|
|
-
|
83
|
|
-#endif
|
84
|
|
-
|