Last active
October 25, 2018 07:47
-
-
Save topin89/619e4fed814a45dbb802b6212dcae70e to your computer and use it in GitHub Desktop.
handy print for Arduino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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