AceCommon  1.1
Arduino library for low-level common functions and features with no external dependencies
printfTo.h
Go to the documentation of this file.
1 /*
2  * MIT License
3  * Copyright (c) 2018 Brian T. Park
4  */
5 
27 #ifndef PRINT_UTILS_PRINTF_TO_H
28 #define PRINT_UTILS_PRINTF_TO_H
29 
30 #include <stdarg.h>
31 #include <Arduino.h>
32 
33 namespace ace_common {
34 
36 const int PRINTF_TO_BUF_SIZE = 192;
37 
39 inline void vprintfTo(Print& printer, const char *fmt, va_list args) {
40  char buf[PRINTF_TO_BUF_SIZE];
41  vsnprintf(buf, PRINTF_TO_BUF_SIZE, fmt, args);
42  printer.print(buf);
43 }
44 
51 inline void printfTo(Print& printer, const char* fmt, ...) {
52  va_list args;
53  va_start(args, fmt);
54  vprintfTo(printer, fmt, args);
55  va_end(args);
56 }
57 
58 }
59 
60 #endif
ace_common::vprintfTo
void vprintfTo(Print &printer, const char *fmt, va_list args)
Helper function for implementing the printfTo() function.
Definition: printfTo.h:39
ace_common::PRINTF_TO_BUF_SIZE
const int PRINTF_TO_BUF_SIZE
Maximum size of the internal stack buffer used by printfTo().
Definition: printfTo.h:36
ace_common::printfTo
void printfTo(Print &printer, const char *fmt,...)
A printf() that works on an Arduino Print object using the built-in vsnprintf().
Definition: printfTo.h:51