ArduinoCore-API icon indicating copy to clipboard operation
ArduinoCore-API copied to clipboard

Add "streaming" syntax support to Print class

Open jfjlaros opened this issue 2 years ago • 3 comments

I wrote a couple of lines of helper code to allow for easy printing. If anyone is interested, I could incorporate it in Stream.h and open a pull request.

Usage:

int a {9};
int b {10};
Serial << "You have " << a << " out of " << b << " retries left.\n";
// Prints: "You have 9 out of 10 retries left."
Serial << makePair(1.2, 4) << ' ' << makePair(12, BIN) << '\n';
// Prints: "1.2000 1100"

jfjlaros avatar Feb 04 '23 12:02 jfjlaros

Hi @jfjlaros :coffee: :wave:

Maybe you can prepare a PR for this? I might add though, that there's some possibility that this might never make it into the Arduino API (not my call though).

aentinger avatar Feb 06 '23 06:02 aentinger

I can try, but this issue has been transferred to a repository that none of the cores I use depend on. So testing will be challenging.

jfjlaros avatar Feb 06 '23 18:02 jfjlaros

PR #181 is more or less what I had in mind.

jfjlaros avatar Feb 06 '23 21:02 jfjlaros