Skip to content

Instantly share code, notes, and snippets.

@D3f0
Last active December 13, 2015 22:04
Show Gist options
  • Save D3f0/4ac95e4e80a9611c2fd2 to your computer and use it in GitHub Desktop.
Save D3f0/4ac95e4e80a9611c2fd2 to your computer and use it in GitHub Desktop.
Reemplazando printf
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