ArduinoStreaming

Working libraries, libraries being ported and related hardware
Post Reply
stevestrong
Posts: 1836
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

ArduinoStreaming

Post by stevestrong » Tue Nov 14, 2017 11:22 am

https://github.com/geneReeves/ArduinoStreaming

I recently started to use it, it allows very nice logging:

Code: Select all

uint16_t counter;
...
Serial << ("counter: ") << counter << (", hex: ") << _HEX(counter) << endl;
Maybe we could add it to our F1/F4 libraries (as single file Streaming.h), and extend it if needed.

User avatar
zoomx
Posts: 541
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: ArduinoStreaming

Post by zoomx » Tue Nov 14, 2017 11:42 am


stevestrong
Posts: 1836
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: ArduinoStreaming

Post by stevestrong » Tue Nov 14, 2017 11:52 am

Which is less then the lib.
And is easier to include a header file than insert something which you don't undertand what is doing ;)

User avatar
mrburnette
Posts: 1892
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: ArduinoStreaming

Post by mrburnette » Tue Nov 14, 2017 1:21 pm

Mikal Hart demonstrated this over 4 years ago, I've used it nearly that long in many of my Arduino examples.

See the Rob Tillaart response for some rather neat time formatting, reproduced below:

Code: Select all

Hi Mikal,
Looks good! A small trick to get a leading zero (e.g. in a time string)
int h = 14;
int m = 6
Serial << ((h<10)?"0":"") << h << ":" << ((m<10)?"0":"") << m << endl;
it would be nice to have something parametrised like
Serial << ZERO(hour,2) << ":" << ZERO(minute,2) << endl;
Serial << ZERO(money, 4) << endl;
Ray

fpiSTM
Posts: 250
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: ArduinoStreaming

Post by fpiSTM » Tue Nov 14, 2017 1:22 pm

Nice.
Thanks to share.
Note that the link from zoomx refers to the one made by Mikal Hart which is the original based code for the one from stevestrong ;)

User avatar
zoomx
Posts: 541
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: ArduinoStreaming

Post by zoomx » Tue Nov 14, 2017 1:27 pm

It doesn't works like the library
Taking the STM32_TonePlayer I got an error

Code: Select all

TimerTone.cpp:54: error: 'endl' was not declared in this scope
so you have to change endl with "/n", I suppose!, or add a definition for endl.
Or simply add streaming.h

Stevestrong library is a little different, at the top is witten

Code: Select all

/* 12-05-2015 GgR
    added _FILL and _TIME classes from web page 
*/

User avatar
mrburnette
Posts: 1892
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: ArduinoStreaming

Post by mrburnette » Tue Nov 14, 2017 2:18 pm

zoomx wrote:
Tue Nov 14, 2017 1:27 pm
It doesn't works like the library
<...>
If you inspect the header file, you will see it is implemented as a macro. Therefore, no additional memory is required whatsoever to use the Arduiniana version.


Ray

Post Reply