Skip to content

Commit bd59bc2

Browse files
committed
Formatted to Arduino IDE 1.5 library specification.
1 parent 7111da7 commit bd59bc2

File tree

6 files changed

+164
-140
lines changed

6 files changed

+164
-140
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,12 @@
2626
*.exe
2727
*.out
2828
*.app
29+
30+
.DS_Store
31+
/.idea
32+
/build
33+
/bin
34+
/lib
35+
/sftp-config.json
36+
.tags
37+
.tags_sorted_by_file

README.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

README.org

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#+TITLE: Streaming
2+
#+AUTHOR: Mikal Hart
3+
4+
5+
* Library Information
6+
- Name :: Streaming
7+
- Version :: 5.0.0
8+
- License :: GNU LGPL
9+
- URL :: https://github.com/janelia-arduino/Streaming
10+
- Author :: Mikal Hart
11+
- Maintainer :: Peter Polidoro
12+
- Email :: [email protected]
13+
14+
** Description
15+
16+
Streaming C++-style Output with Operator <<
17+
18+
* Source
19+
20+
[[http://arduiniana.org/libraries/streaming/]]
Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
#include "Streaming.h"
2-
3-
void setup()
4-
{
5-
Serial.begin(9600);
6-
int lettera = 'A';
7-
int month = 4, day = 17, year = 2009;
8-
9-
Serial << "This is an example of the new streaming" << endl;
10-
Serial << "library. This allows you to print variables" << endl;
11-
Serial << "and strings without having to type line after" << endl;
12-
Serial << "line of Serial.print() calls. Examples: " << endl;
13-
14-
Serial << "A is " << lettera << "." << endl;
15-
Serial << "The current date is " << day << "-" << month << "-" << year << "." << endl;
16-
17-
Serial << "You can use modifiers too, for example:" << endl;
18-
Serial << _BYTE(lettera) << " is " << _HEX(lettera) << " in hex. " << endl;
19-
}
20-
21-
void loop()
22-
{}
1+
#include "Streaming.h"
2+
3+
void setup()
4+
{
5+
Serial.begin(9600);
6+
int lettera = 'A';
7+
int month = 4, day = 17, year = 2009;
8+
9+
Serial << "This is an example of the new streaming" << endl;
10+
Serial << "library. This allows you to print variables" << endl;
11+
Serial << "and strings without having to type line after" << endl;
12+
Serial << "line of Serial.print() calls. Examples: " << endl;
13+
14+
Serial << "A is " << lettera << "." << endl;
15+
Serial << "The current date is " << day << "-" << month << "-" << year << "." << endl;
16+
17+
Serial << "You can use modifiers too, for example:" << endl;
18+
Serial << _BYTE(lettera) << " is " << _HEX(lettera) << " in hex. " << endl;
19+
}
20+
21+
void loop()
22+
{
23+
}

library.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name=Streaming
2+
version=5.0.0
3+
author=Mikal Hart <[email protected]>
4+
maintainer=Peter Polidoro <[email protected]>
5+
sentence=Streaming C++-style Output with Operator <<
6+
paragraph=Like this project? Please star it on GitHub!
7+
url=https://github.com/janelia-arduino/Streaming
8+
architectures=*
Lines changed: 104 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,105 @@
1-
/*
2-
Streaming.h - Arduino library for supporting the << streaming operator
3-
Copyright (c) 2010-2012 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-
1+
/*
2+
Streaming.h - Arduino library for supporting the << streaming operator
3+
Copyright (c) 2010-2012 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+
2323
#if defined(ARDUINO) && ARDUINO >= 100
24-
#include "Arduino.h"
25-
#else
26-
#include "WProgram.h"
27-
#endif
28-
29-
#define STREAMING_LIBRARY_VERSION 5
30-
31-
// Generic template
32-
template<class T>
33-
inline Print &operator <<(Print &stream, T arg)
34-
{ stream.print(arg); return stream; }
35-
36-
struct _BASED
37-
{
38-
long val;
39-
int base;
40-
_BASED(long v, int b): val(v), base(b)
41-
{}
42-
};
43-
44-
#if ARDUINO >= 100
45-
46-
struct _BYTE_CODE
47-
{
48-
byte val;
49-
_BYTE_CODE(byte v) : val(v)
50-
{}
51-
};
52-
#define _BYTE(a) _BYTE_CODE(a)
53-
54-
inline Print &operator <<(Print &obj, const _BYTE_CODE &arg)
55-
{ obj.write(arg.val); return obj; }
56-
57-
#else
58-
59-
#define _BYTE(a) _BASED(a, BYTE)
60-
61-
#endif
62-
63-
#define _HEX(a) _BASED(a, HEX)
64-
#define _DEC(a) _BASED(a, DEC)
65-
#define _OCT(a) _BASED(a, OCT)
66-
#define _BIN(a) _BASED(a, BIN)
67-
68-
// Specialization for class _BASED
69-
// Thanks to Arduino forum user Ben Combee who suggested this
70-
// clever technique to allow for expressions like
71-
// Serial << _HEX(a);
72-
73-
inline Print &operator <<(Print &obj, const _BASED &arg)
74-
{ obj.print(arg.val, arg.base); return obj; }
75-
76-
#if ARDUINO >= 18
77-
// Specialization for class _FLOAT
78-
// Thanks to Michael Margolis for suggesting a way
79-
// to accommodate Arduino 0018's floating point precision
80-
// feature like this:
81-
// Serial << _FLOAT(gps_latitude, 6); // 6 digits of precision
82-
83-
struct _FLOAT
84-
{
85-
float val;
86-
int digits;
87-
_FLOAT(double v, int d): val(v), digits(d)
88-
{}
89-
};
90-
91-
inline Print &operator <<(Print &obj, const _FLOAT &arg)
92-
{ obj.print(arg.val, arg.digits); return obj; }
93-
#endif
94-
95-
// Specialization for enum _EndLineCode
96-
// Thanks to Arduino forum user Paul V. who suggested this
97-
// clever technique to allow for expressions like
98-
// Serial << "Hello!" << endl;
99-
100-
enum _EndLineCode { endl };
101-
102-
inline Print &operator <<(Print &obj, _EndLineCode arg)
103-
{ obj.println(); return obj; }
104-
105-
#endif
24+
#include "Arduino.h"
25+
#else
26+
#include "WProgram.h"
27+
#endif
28+
29+
#define STREAMING_LIBRARY_VERSION 5
30+
31+
// Generic template
32+
template<class T>
33+
inline Print &operator <<(Print &stream, T arg)
34+
{ stream.print(arg); return stream; }
35+
36+
struct _BASED
37+
{
38+
long val;
39+
int base;
40+
_BASED(long v, int b): val(v), base(b)
41+
{}
42+
};
43+
44+
#if ARDUINO >= 100
45+
46+
struct _BYTE_CODE
47+
{
48+
byte val;
49+
_BYTE_CODE(byte v) : val(v)
50+
{}
51+
};
52+
#define _BYTE(a) _BYTE_CODE(a)
53+
54+
inline Print &operator <<(Print &obj, const _BYTE_CODE &arg)
55+
{ obj.write(arg.val); return obj; }
56+
57+
#else
58+
59+
#define _BYTE(a) _BASED(a, BYTE)
60+
61+
#endif
62+
63+
#define _HEX(a) _BASED(a, HEX)
64+
#define _DEC(a) _BASED(a, DEC)
65+
#define _OCT(a) _BASED(a, OCT)
66+
#define _BIN(a) _BASED(a, BIN)
67+
68+
// Specialization for class _BASED
69+
// Thanks to Arduino forum user Ben Combee who suggested this
70+
// clever technique to allow for expressions like
71+
// Serial << _HEX(a);
72+
73+
inline Print &operator <<(Print &obj, const _BASED &arg)
74+
{ obj.print(arg.val, arg.base); return obj; }
75+
76+
#if ARDUINO >= 18
77+
// Specialization for class _FLOAT
78+
// Thanks to Michael Margolis for suggesting a way
79+
// to accommodate Arduino 0018's floating point precision
80+
// feature like this:
81+
// Serial << _FLOAT(gps_latitude, 6); // 6 digits of precision
82+
83+
struct _FLOAT
84+
{
85+
float val;
86+
int digits;
87+
_FLOAT(double v, int d): val(v), digits(d)
88+
{}
89+
};
90+
91+
inline Print &operator <<(Print &obj, const _FLOAT &arg)
92+
{ obj.print(arg.val, arg.digits); return obj; }
93+
#endif
94+
95+
// Specialization for enum _EndLineCode
96+
// Thanks to Arduino forum user Paul V. who suggested this
97+
// clever technique to allow for expressions like
98+
// Serial << "Hello!" << endl;
99+
100+
enum _EndLineCode { endl };
101+
102+
inline Print &operator <<(Print &obj, _EndLineCode arg)
103+
{ obj.println(); return obj; }
104+
105+
#endif

0 commit comments

Comments
 (0)