Skip to content

feat: enhance Print class with float support and printf functionality#268

Open
Aymane-ST wants to merge 1 commit intoarduino:masterfrom
Aymane-ST:pr/print-float-printf
Open

feat: enhance Print class with float support and printf functionality#268
Aymane-ST wants to merge 1 commit intoarduino:masterfrom
Aymane-ST:pr/print-float-printf

Conversation

@Aymane-ST
Copy link
Copy Markdown

Summary

Enhance Print with:

  • print(float, int digits)
  • println(float, int digits)
  • printf(...)
  • vprintf(...)

Why

This improves API completeness and usability:

  • float gets explicit overloads, matching existing double support
  • printf/vprintf provide familiar formatted output on top of the Print interface

Compatibility

This change is additive and backward-compatible:

  • existing Print users are unaffected
  • no existing signatures are changed
  • new functionality becomes available to all Print-derived classes

- Add float overloads to Print::print/println
- Enhance Print with printf() and vprintf() helpers

Signed-off-by: Aymane Bahssain <[email protected]>
@per1234 per1234 mentioned this pull request Apr 26, 2026
Copy link
Copy Markdown
Collaborator

@per1234 per1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for your pull requests @Aymane-ST! The addition of Print::printf et al. is a potential "poison pill" for this PR, since this is something that has historically been explicitly rejected by Arduino. For example:

https://groups.google.com/a/arduino.cc/g/developers/c/E0pUPWeDE2Y/m/GPWl9Nw1BwAJ

Massimo Banzi Feb 13, 2019, 1:26:42 AM

I would avoid adding printf to Serial., the syntax is not very friendly.

People who know how to use it can use sprintf and pass the buffer to print.

Furthermore, we already have a pull request proposing the addition of Print::printf: #28

Please remove the Print::printf component from this pull request to make it focus exclusively on the addition of a float overload of Print::print.

You are very welcome to submit a review on #28 if you have any suggestions for changes to the implementation proposed there. If that review is not resolved to your satisfaction, you can submit a dedicated pull request for your Print::printf et al. proposal.

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.

2 participants