Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add printf to print class #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

MCUdude
Copy link

@MCUdude MCUdude commented Feb 28, 2019

Printf is super useful. This PR will let users use Serial.printf

@PaulStoffregen
Copy link
Sponsor

Didn't Massimo (@mbanzi) say very clearly, only 2 weeks ago on the developers mail list, that this would not be accepted?

@MCUdude
Copy link
Author

MCUdude commented Feb 28, 2019

That may be true, but I'm not in the developer mailing list 😉
I don't quite see why printf is such a bad thing to have available though.

@PaulStoffregen
Copy link
Sponsor

I'm not going to argue this. My only point is this has been proposed over and over, and the Arduino devs have clearly said it does not belong in Arduino's API. Now that you know this, you can look up what they've said and argue if you like.

@MCUdude
Copy link
Author

MCUdude commented Feb 28, 2019

Did some google-fu and found the threads you're referring to. It's really weird, but many (most) of the "We should implement printf in print class" discussions ends up with ranting and personal attacks.

Personally I'd love to see this merged because I personally find printf easy to use and understand. However I'd of course respect if the Arduino Gods have a different opinion than me.

I'll leave this open until it's merged or closed by any of the developers.

@per1234
Copy link
Collaborator

per1234 commented Feb 28, 2019

I believe this is the specific statement from Massimo Banzi that Paul Stoffregen referred to:
https://groups.google.com/a/arduino.cc/d/msg/developers/E0pUPWeDE2Y/GPWl9Nw1BwAJ

Related:
https://github.com/arduino/Arduino/issues/2416

@PaulStoffregen
Copy link
Sponsor

Clearly a lot of people have strong feelings on this matter. Some of those folks may have more passion than wisdom.

FWIW, I have some printf code similar to what Bill Perry suggested just today, but it uses Arduino's Print class rather than duplicating so much code and allocating big buffers. When I get a break in working on hardware, I'm planning to turn it into a nice library that works on all boards.

@Floessie
Copy link

Floessie commented Mar 1, 2019

@PaulStoffregen

I have some printf code similar to what Bill Perry suggested just today

Paul, could you add a link, please? Just out of interest...

@per1234
Copy link
Collaborator

per1234 commented Mar 21, 2019

could you add a link, please? Just out of interest...

I believe this is it:
https://groups.google.com/a/arduino.cc/d/msg/developers/sTacUMEXBTw/H2v9GabLBAAJ

@PaulStoffregen
Copy link
Sponsor

PaulStoffregen commented Mar 21, 2019

Bill's code allocates a 128 byte buffer on the stack.

Sorry, my own no-buffer printf code isn't public at this time. I already maintain a couple dozen libs, which regularly get requests for platform-specific issues (the ESP folks are the worst - so much breaks on those chips...), so I'm not very inclined to release yet another library in an "alpha" quality state.

Edit: Just to be clear, technically any "no buffer" code that relies on Arduino's Print class does involve a 33 byte buffer allocated on the stack, due to Arduino's Print::printNumber() function.

@CLAassistant
Copy link

CLAassistant commented Apr 9, 2021

CLA assistant check
All committers have signed the CLA.

@JAndrassy
Copy link
Contributor

my StreamLib enables to use printf without support in core API.
https://github.com/JAndrassy/StreamLib#formatted-printing
and the implementation doesn't use a buffer. it has avr, arm end esp implementation.
https://github.com/JAndrassy/StreamLib/blob/master/src/PrintPlus.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Print.h add printf API
6 participants