Utils  1.0.2
Utility functions and macros to print with arguments
Utils.h File Reference
#include <Arduino.h>
#include <Print.h>

Go to the source code of this file.

Macros

#define serialBegin(speed)   { Serial.begin(speed); while (!Serial); }
 An utility macro that initialize the default Serial port and waits until the port is ready. More...
 
#define DebugMessagePrintf(...)   { }
 An utility macro that is expanded to myPrintf(...) only if the define DebugMode is active. More...
 
#define DebugSerialBegin(speed)   { }
 An utility macro that is expanded to serialBegin(...) only if the define DebugMode is active. More...
 
#define DebugDelay(amount)   { }
 An utility macro that is expanded to delay(...) only if the define DebugMode is active. More...
 

Functions

void myPrintf (const char *sFmt,...)
 Print formatted data (equivalent to standard C printf) to the default Serial port. More...
 
void myPrintf (const String &sFmt,...)
 Print formatted data (equivalent to standard C printf) to the default Serial port. More...
 
void myPrintf (Print &pr, const char *sFmt,...)
 Print formatted data (equivalent to standard C printf) to a Print object. More...
 
void myPrintf (Print &pr, const String &sFmt,...)
 Print formatted data (equivalent to standard C printf) to a Print object. More...
 
char * format (const char *sFmt,...)
 Print formatted data (equivalent to standard C printf) to a C string. More...
 

Macro Definition Documentation

◆ DebugDelay

#define DebugDelay (   amount)    { }

An utility macro that is expanded to delay(...) only if the define DebugMode is active.

◆ DebugMessagePrintf

#define DebugMessagePrintf (   ...)    { }

An utility macro that is expanded to myPrintf(...) only if the define DebugMode is active.

◆ DebugSerialBegin

#define DebugSerialBegin (   speed)    { }

An utility macro that is expanded to serialBegin(...) only if the define DebugMode is active.

◆ serialBegin

#define serialBegin (   speed)    { Serial.begin(speed); while (!Serial); }

An utility macro that initialize the default Serial port and waits until the port is ready.

Function Documentation

◆ format()

char* format ( const char *  sFmt,
  ... 
)

Print formatted data (equivalent to standard C printf) to a C string.

Writes the C string pointed by sFmt to a C string

If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.

Parameters
sFmtArduino String object that contains the text to be written to Serial
Returns
the formated string. Caller must delete the returned value in order to free allocated memory

◆ myPrintf() [1/4]

void myPrintf ( const char *  sFmt,
  ... 
)

Print formatted data (equivalent to standard C printf) to the default Serial port.

Writes the C string pointed by sFmt to the Serial port.

If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.

Parameters
sFmtC string that contains the text to be written to the default Serial port

◆ myPrintf() [2/4]

void myPrintf ( const String &  sFmt,
  ... 
)

Print formatted data (equivalent to standard C printf) to the default Serial port.

Writes the Arduino String object sFmt to the Serial port.

If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.

Parameters
sFmtArduino String object that contains the text to be written to the default Serial port

◆ myPrintf() [3/4]

void myPrintf ( Print &  pr,
const char *  sFmt,
  ... 
)

Print formatted data (equivalent to standard C printf) to a Print object.

Writes the C string pointed by sFmt to a Print object such as a Serial port or a display that "implements" the Print interface.

If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.

Parameters
prArduino Print object that suports the print and println methods
sFmtArduino String object that contains the text to be written to the Print argument

◆ myPrintf() [4/4]

void myPrintf ( Print &  pr,
const String &  sFmt,
  ... 
)

Print formatted data (equivalent to standard C printf) to a Print object.

Writes the Arduino String object sFmt to a Print object such as a Serial port or a display that "implements" the Print interface.

If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.

Parameters
prArduino Print object that suports the print and println methods
sFmtArduino String object that contains the text to be written to the Print argument