Skip to content

Instantly share code, notes, and snippets.

@topin89
Last active October 25, 2018 07:47
Show Gist options
  • Save topin89/619e4fed814a45dbb802b6212dcae70e to your computer and use it in GitHub Desktop.
Save topin89/619e4fed814a45dbb802b6212dcae70e to your computer and use it in GitHub Desktop.
handy print for Arduino
//example:
//multiprint("I = ")(10)("A")()("U = ")(10)("V")();
//result:
//I = 10A
//U = 20V
//
//arguments -- same as Serial.print
//no argument -- Serial.println()
#ifndef H_MULTIPRINT_ARD
#define H_MULTIPRINT_ARD
class Sprint{
public:
template<typename T>
Sprint &operator()(T arg) {
Serial.print(arg);
return *this;
}
Sprint &operator()() {
Serial.println();
return *this;
}
};
#define multiprint(arg) Sprint()(arg)
#endif //H_MULTIPRINT_ARD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment