Skip to content

Instantly share code, notes, and snippets.

@giupo
Created March 5, 2020 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giupo/b3564b9a7b359bc92ec453541c331708 to your computer and use it in GitHub Desktop.
Save giupo/b3564b9a7b359bc92ec453541c331708 to your computer and use it in GitHub Desktop.
/*
* debug.h
*
* Created on: 5 Marzo 2020
* Author: Franco
* Description:
* Il debug viene automaticamente creato se DEBUG_PORT o DEBUG_ESP_PORT viene definito con la porta da usare (Es: Serial)
* DEBUG_PORT deve essere definita in compilazione o come #DEFINE. DEBUG_ESP_PORT viene automaticamente settata da
* Arduino IDE dal menù 'strumenti\Debug port' per gli ESP con gli altri parametri di debug per il wifi.
* Se non si usa Arduino IDE può essere definita come per DEBUG_PORT
*/
//TODO: stampare in automatico il valore delle variabili e il nome
#ifndef DEBUG_H_
#define DEBUG_H_
//=============================================================================================================
// D E B U G
//=============================================================================================================
#ifdef DEBUG
#ifdef DEBUG_ESP_PORT
#ifndef DEBUG_PORT
#define DEBUG_PORT DEBUG_ESP_PORT
#endif
#endif
#ifdef DEBUG_PORT
#define DEBUG_PORT(baud) DEBUG_PORT.begin(baud)
#define DEBUG_MSG(M, ...) DEBUG_PORT.printf("(%s:%d) - " M "\n\r", __FUNCTION__,__LINE__, ##__VA_ARGS__)
#define TT() \
DEBUG_PORT.print(':'); \
DEBUG_PORT.print(__LINE__); \
DEBUG_PORT.print(':'); \
DEBUG_PORT.print(__PRETTY_FUNCTION__)
#endif // DEBUG_PORT
#ifdef DEBUG_ESP_PORT
#define DEBUG_ESP_PORT(baud) DEBUG_ESP_PORT.begin(baud)
#define DEBUG_MSG(M, ...) DEBUG_ESP_PORT.printf("(%s:%d) - " M "\n\r", __FUNCTION__,__LINE__, ##__VA_ARGS__)
#define TT() \
DEBUG_ESP_PORT.print(':'); \
DEBUG_ESP_PORT.print(__LINE__); \
DEBUG_ESP_PORT.print(':'); \
DEBUG_ESP_PORT.print(__PRETTY_FUNCTION__)
#endif // DEBUG_ESP_PORT
#else // DEBUG
#define DEBUG_ESP_PORT(baud) do {} while(0);
#define DEBUG_PORT(baud) do {} while(0);
#define DEBUG_MSG(...) do {} while(0);
#define TT()
#endif // DEBUG
#endif /* DEBUG_H_ */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment