FastLED 3.9.15
Loading...
Searching...
No Matches

◆ printf()

template<typename... Args>
size_t fl::SerialPort::printf ( const char * format,
Args... args )
inline

Print formatted string to serial output (printf-style)

Template Parameters
ArgsVariadic template arguments
Parameters
formatPrintf-style format string
argsVariable arguments
Returns
Number of bytes written

Example:

fl::Serial.printf("Value: %d, Hex: 0x%X\n", 42, 255);

Note: Maximum formatted string length is 256 characters.

Definition at line 277 of file serial.h.

277 {
278 if (!format) {
279 return 0;
280 }
281
282 // Format into a fixed-size buffer using fl::snprintf
283 char buffer[256]; // Maximum formatted string length
284 int len = fl::snprintf(buffer, sizeof(buffer), format, args...);
285
286 if (len < 0) {
287 return 0; // Formatting error
288 }
289
290 // Delegate to print() method
291 return print(buffer);
292}
size_t print(const char *str)
Print string to serial output.
int snprintf(char *buffer, fl::size size, const char *format, const Args &... args) FL_NOEXCEPT
Snprintf-like formatting function that writes to a buffer.
Definition stdio.h:666
fl::string format(const char *fmt)
Format with no arguments.
Definition format.h:439
corkscrew_args args
Definition old.h:149

References args, fl::format(), print(), and fl::snprintf().

+ Here is the call graph for this function: