Skip to content

Add Print::printf #555

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cores/arduino/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,17 @@ size_t Print::printFloat(double number, uint8_t digits)

return n;
}

//added by bonezegei
size_t Print::printf(const char c[], ...){
char text[64];
va_list ap;

if (c == NULL)
return 0;
va_start(ap, c);
vsprintf(text, c, ap);
va_end(ap);

return write(text);
}
2 changes: 2 additions & 0 deletions cores/arduino/Print.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class Print
size_t println(const Printable&);
size_t println(void);

size_t printf(const char[], ...); //added by bonezegei

virtual void flush() { /* Empty implementation for backward compatibility */ }
};

Expand Down
Loading