Last active
December 13, 2015 22:04
-
-
Save D3f0/4ac95e4e80a9611c2fd2 to your computer and use it in GitHub Desktop.
Reemplazando printf
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
class Dbg | |
{ | |
public: | |
// Operador () con cadenas | |
Dbg& operator()(char const *s){ | |
//printf("%s ", s); | |
Serial.print(s); | |
Serial.print(" "); | |
return *this; | |
} | |
// Operador () con enteros | |
Dbg& operator()(int i){ | |
Serial.print(i); | |
Serial.print(" "); | |
return *this; | |
} | |
// El ++ avanza línea | |
Dbg& operator++(){ | |
Serial.print("\n"); | |
return *this; | |
} | |
// Avanzar una línea | |
Dbg& operator++(int){ | |
this->operator++(); | |
return *this; | |
} | |
}; | |
Dbg dbg; | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(115200); | |
char* variable = "pepe"; | |
dbg("Hola")(variable)++; | |
dbg++; | |
dbg("Que tal estás")(1)(20)++; | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment