-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Formatted to Arduino IDE 1.5 library specification.
- Loading branch information
1 parent
7111da7
commit bd59bc2
Showing
6 changed files
with
164 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,12 @@ | |
*.exe | ||
*.out | ||
*.app | ||
|
||
.DS_Store | ||
/.idea | ||
/build | ||
/bin | ||
/lib | ||
/sftp-config.json | ||
.tags | ||
.tags_sorted_by_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#+TITLE: Streaming | ||
#+AUTHOR: Mikal Hart | ||
#+EMAIL: [email protected] | ||
|
||
* Library Information | ||
- Name :: Streaming | ||
- Version :: 5.0.0 | ||
- License :: GNU LGPL | ||
- URL :: https://github.com/janelia-arduino/Streaming | ||
- Author :: Mikal Hart | ||
- Maintainer :: Peter Polidoro | ||
- Email :: [email protected] | ||
|
||
** Description | ||
|
||
Streaming C++-style Output with Operator << | ||
|
||
* Source | ||
|
||
[[http://arduiniana.org/libraries/streaming/]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
#include "Streaming.h" | ||
|
||
void setup() | ||
{ | ||
Serial.begin(9600); | ||
int lettera = 'A'; | ||
int month = 4, day = 17, year = 2009; | ||
|
||
Serial << "This is an example of the new streaming" << endl; | ||
Serial << "library. This allows you to print variables" << endl; | ||
Serial << "and strings without having to type line after" << endl; | ||
Serial << "line of Serial.print() calls. Examples: " << endl; | ||
|
||
Serial << "A is " << lettera << "." << endl; | ||
Serial << "The current date is " << day << "-" << month << "-" << year << "." << endl; | ||
|
||
Serial << "You can use modifiers too, for example:" << endl; | ||
Serial << _BYTE(lettera) << " is " << _HEX(lettera) << " in hex. " << endl; | ||
} | ||
|
||
void loop() | ||
{} | ||
#include "Streaming.h" | ||
|
||
void setup() | ||
{ | ||
Serial.begin(9600); | ||
int lettera = 'A'; | ||
int month = 4, day = 17, year = 2009; | ||
|
||
Serial << "This is an example of the new streaming" << endl; | ||
Serial << "library. This allows you to print variables" << endl; | ||
Serial << "and strings without having to type line after" << endl; | ||
Serial << "line of Serial.print() calls. Examples: " << endl; | ||
|
||
Serial << "A is " << lettera << "." << endl; | ||
Serial << "The current date is " << day << "-" << month << "-" << year << "." << endl; | ||
|
||
Serial << "You can use modifiers too, for example:" << endl; | ||
Serial << _BYTE(lettera) << " is " << _HEX(lettera) << " in hex. " << endl; | ||
} | ||
|
||
void loop() | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name=Streaming | ||
version=5.0.0 | ||
author=Mikal Hart <[email protected]> | ||
maintainer=Peter Polidoro <[email protected]> | ||
sentence=Streaming C++-style Output with Operator << | ||
paragraph=Like this project? Please star it on GitHub! | ||
url=https://github.com/janelia-arduino/Streaming | ||
architectures=* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,105 @@ | ||
/* | ||
Streaming.h - Arduino library for supporting the << streaming operator | ||
Copyright (c) 2010-2012 Mikal Hart. All rights reserved. | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#ifndef ARDUINO_STREAMING | ||
#define ARDUINO_STREAMING | ||
|
||
/* | ||
Streaming.h - Arduino library for supporting the << streaming operator | ||
Copyright (c) 2010-2012 Mikal Hart. All rights reserved. | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#ifndef ARDUINO_STREAMING | ||
#define ARDUINO_STREAMING | ||
|
||
#if defined(ARDUINO) && ARDUINO >= 100 | ||
#include "Arduino.h" | ||
#else | ||
#include "WProgram.h" | ||
#endif | ||
|
||
#define STREAMING_LIBRARY_VERSION 5 | ||
|
||
// Generic template | ||
template<class T> | ||
inline Print &operator <<(Print &stream, T arg) | ||
{ stream.print(arg); return stream; } | ||
|
||
struct _BASED | ||
{ | ||
long val; | ||
int base; | ||
_BASED(long v, int b): val(v), base(b) | ||
{} | ||
}; | ||
|
||
#if ARDUINO >= 100 | ||
|
||
struct _BYTE_CODE | ||
{ | ||
byte val; | ||
_BYTE_CODE(byte v) : val(v) | ||
{} | ||
}; | ||
#define _BYTE(a) _BYTE_CODE(a) | ||
|
||
inline Print &operator <<(Print &obj, const _BYTE_CODE &arg) | ||
{ obj.write(arg.val); return obj; } | ||
|
||
#else | ||
|
||
#define _BYTE(a) _BASED(a, BYTE) | ||
|
||
#endif | ||
|
||
#define _HEX(a) _BASED(a, HEX) | ||
#define _DEC(a) _BASED(a, DEC) | ||
#define _OCT(a) _BASED(a, OCT) | ||
#define _BIN(a) _BASED(a, BIN) | ||
|
||
// Specialization for class _BASED | ||
// Thanks to Arduino forum user Ben Combee who suggested this | ||
// clever technique to allow for expressions like | ||
// Serial << _HEX(a); | ||
|
||
inline Print &operator <<(Print &obj, const _BASED &arg) | ||
{ obj.print(arg.val, arg.base); return obj; } | ||
|
||
#if ARDUINO >= 18 | ||
// Specialization for class _FLOAT | ||
// Thanks to Michael Margolis for suggesting a way | ||
// to accommodate Arduino 0018's floating point precision | ||
// feature like this: | ||
// Serial << _FLOAT(gps_latitude, 6); // 6 digits of precision | ||
|
||
struct _FLOAT | ||
{ | ||
float val; | ||
int digits; | ||
_FLOAT(double v, int d): val(v), digits(d) | ||
{} | ||
}; | ||
|
||
inline Print &operator <<(Print &obj, const _FLOAT &arg) | ||
{ obj.print(arg.val, arg.digits); return obj; } | ||
#endif | ||
|
||
// Specialization for enum _EndLineCode | ||
// Thanks to Arduino forum user Paul V. who suggested this | ||
// clever technique to allow for expressions like | ||
// Serial << "Hello!" << endl; | ||
|
||
enum _EndLineCode { endl }; | ||
|
||
inline Print &operator <<(Print &obj, _EndLineCode arg) | ||
{ obj.println(); return obj; } | ||
|
||
#endif | ||
#include "Arduino.h" | ||
#else | ||
#include "WProgram.h" | ||
#endif | ||
|
||
#define STREAMING_LIBRARY_VERSION 5 | ||
|
||
// Generic template | ||
template<class T> | ||
inline Print &operator <<(Print &stream, T arg) | ||
{ stream.print(arg); return stream; } | ||
|
||
struct _BASED | ||
{ | ||
long val; | ||
int base; | ||
_BASED(long v, int b): val(v), base(b) | ||
{} | ||
}; | ||
|
||
#if ARDUINO >= 100 | ||
|
||
struct _BYTE_CODE | ||
{ | ||
byte val; | ||
_BYTE_CODE(byte v) : val(v) | ||
{} | ||
}; | ||
#define _BYTE(a) _BYTE_CODE(a) | ||
|
||
inline Print &operator <<(Print &obj, const _BYTE_CODE &arg) | ||
{ obj.write(arg.val); return obj; } | ||
|
||
#else | ||
|
||
#define _BYTE(a) _BASED(a, BYTE) | ||
|
||
#endif | ||
|
||
#define _HEX(a) _BASED(a, HEX) | ||
#define _DEC(a) _BASED(a, DEC) | ||
#define _OCT(a) _BASED(a, OCT) | ||
#define _BIN(a) _BASED(a, BIN) | ||
|
||
// Specialization for class _BASED | ||
// Thanks to Arduino forum user Ben Combee who suggested this | ||
// clever technique to allow for expressions like | ||
// Serial << _HEX(a); | ||
|
||
inline Print &operator <<(Print &obj, const _BASED &arg) | ||
{ obj.print(arg.val, arg.base); return obj; } | ||
|
||
#if ARDUINO >= 18 | ||
// Specialization for class _FLOAT | ||
// Thanks to Michael Margolis for suggesting a way | ||
// to accommodate Arduino 0018's floating point precision | ||
// feature like this: | ||
// Serial << _FLOAT(gps_latitude, 6); // 6 digits of precision | ||
|
||
struct _FLOAT | ||
{ | ||
float val; | ||
int digits; | ||
_FLOAT(double v, int d): val(v), digits(d) | ||
{} | ||
}; | ||
|
||
inline Print &operator <<(Print &obj, const _FLOAT &arg) | ||
{ obj.print(arg.val, arg.digits); return obj; } | ||
#endif | ||
|
||
// Specialization for enum _EndLineCode | ||
// Thanks to Arduino forum user Paul V. who suggested this | ||
// clever technique to allow for expressions like | ||
// Serial << "Hello!" << endl; | ||
|
||
enum _EndLineCode { endl }; | ||
|
||
inline Print &operator <<(Print &obj, _EndLineCode arg) | ||
{ obj.println(); return obj; } | ||
|
||
#endif |