Skip to content

add Serial.printfln to Print.cpp #12577

@cjhudlin

Description

@cjhudlin

Related area

Serial.print

Hardware specification

esp32 framework

Is your feature request related to a problem?

Hello,
id like to suggest a very simple / small addition to the print.cpp file to add printfln feature. this allows the use of printf with line break instead of having to use \n.

Describe the solution you'd like

in Print.cpp, i added rudimentray code:

size_t Print::printfln(const __FlashStringHelper *ifsh, ...) {
va_list arg;
va_start(arg, ifsh);
const char *format = (reinterpret_cast<const char *>(ifsh));
size_t ret = vprintf(format, arg) + print("\r\n");
va_end(arg);
return ret;
}

size_t Print::printfln(const char *format, ...) {
va_list arg;
va_start(arg, format);
size_t ret = vprintf(format, arg) + print("\r\n");;
va_end(arg);
return ret;
}

and in Print.h:

size_t printfln(const char *format, ...) attribute((format(printf, 2, 3)));
size_t printfln(const __FlashStringHelper *ifsh, ...);

the result is a line break with printf prints

Describe alternatives you've considered

No response

Additional context

No response

I have checked existing list of Feature requests and the Contribution Guide

  • I confirm I have checked existing list of Feature requests and Contribution Guide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions