AbleButtons V0.4.0
Lightweight button library for Arduino.
 
Loading...
Searching...
No Matches
Utils.h File Reference

Utility function declarations. More...

#include <Arduino.h>

Go to the source code of this file.

Macros

#define assert(e)   ((e) ? (void)0 : assertSerial(__func__, __FILE__, __LINE__, F(#e)))
 Macro to assert using FlashStringHelper to reduce memory usage. More...
 

Enumerations

enum  endl { endl }
 Special type to allow Serial << endl to print a line and flush the stream. More...
 

Functions

void assertSerial (const char *func, const char *file, int lineno, const __FlashStringHelper *exp)
 Output assertion to Serial when the assertion expression is false. More...
 
template<typename T >
Print & operator<< (Print &p, const T o)
 Output a specific type to the Print stream. More...
 
Print & operator<< (Print &p, enum endl)
 Special stream operator for turning Serial << endl into new line and stream flush. More...
 

Detailed Description

Utility function declarations.

The Utils module defines general utilities. An assert(bool-expression) that outputs to Serial if its false and print-stream << operators to make it easier to output to the Serial object using C++ style stream output operations.

Definition in file Utils.h.

Macro Definition Documentation

◆ assert

#define assert (   e)    ((e) ? (void)0 : assertSerial(__func__, __FILE__, __LINE__, F(#e)))

Macro to assert using FlashStringHelper to reduce memory usage.

If the boolean expression is false, then an assertion error is output to Serial including the function name, source file, line number and the expression itself.

Parameters
eA boolean expression evaluating to true/false.

Definition at line 30 of file Utils.h.

Enumeration Type Documentation

◆ endl

enum endl

Special type to allow Serial << endl to print a line and flush the stream.

Enumerator
endl 

The special value of endl triggers the Serial.println() and Serial.flush().

Definition at line 45 of file Utils.h.

Function Documentation

◆ assertSerial()

void assertSerial ( const char *  func,
const char *  file,
int  lineno,
const __FlashStringHelper *  exp 
)

Output assertion to Serial when the assertion expression is false.

Parameters
funcThe func (function) name.
fileThe FILE name.
linenoThe LINE number.
expThe failing assertion expression.

Definition at line 13 of file Utils.cpp.

◆ operator<<() [1/2]

template<typename T >
Print & operator<< ( Print &  p,
const T  o 
)
inline

Output a specific type to the Print stream.

Parameters
pThe print-stream to output to.
oThe object to output.
Returns
The print-stream object (allows chaining of << operators - as in Serial << x << y << z;).

Definition at line 42 of file Utils.h.

◆ operator<<() [2/2]

Print & operator<< ( Print &  p,
enum  endl 
)
inline

Special stream operator for turning Serial << endl into new line and stream flush.

Parameters
pThe print-stream to output a new line and flush.
endlThe special endl enumeration type
Returns
The print-stream object (allows chaining of << operators - as in Serial << x << y << z;).

Definition at line 58 of file Utils.h.