mirror of
https://github.com/rvdbreemen/OTGW-firmware
synced 2024-11-16 04:33:49 +01:00
55 lines
2.0 KiB
C
55 lines
2.0 KiB
C
|
/*
|
||
|
***************************************************************************
|
||
|
** Program : Debug.h
|
||
|
**
|
||
|
** Copyright (c) 2020 Willem Aandewiel
|
||
|
** Met dank aan Erik
|
||
|
**
|
||
|
** TERMS OF USE: MIT License. See bottom of file.
|
||
|
***************************************************************************
|
||
|
*/
|
||
|
|
||
|
/*---- start macro's ------------------------------------------------------------------*/
|
||
|
|
||
|
#define Debug(...) ({ Serial.print(__VA_ARGS__); \
|
||
|
TelnetStream.print(__VA_ARGS__); \
|
||
|
})
|
||
|
#define Debugln(...) ({ Serial.println(__VA_ARGS__); \
|
||
|
TelnetStream.println(__VA_ARGS__); \
|
||
|
})
|
||
|
#define Debugf(...) ({ Serial.printf(__VA_ARGS__); \
|
||
|
TelnetStream.printf(__VA_ARGS__); \
|
||
|
})
|
||
|
|
||
|
#define DebugFlush() ({ Serial.flush(); \
|
||
|
TelnetStream.flush(); \
|
||
|
})
|
||
|
|
||
|
|
||
|
#define DebugT(...) ({ _debugBOL(__FUNCTION__, __LINE__); \
|
||
|
Debug(__VA_ARGS__); \
|
||
|
})
|
||
|
#define DebugTln(...) ({ _debugBOL(__FUNCTION__, __LINE__); \
|
||
|
Debugln(__VA_ARGS__); \
|
||
|
})
|
||
|
#define DebugTf(...) ({ _debugBOL(__FUNCTION__, __LINE__); \
|
||
|
Debugf(__VA_ARGS__); \
|
||
|
})
|
||
|
|
||
|
/*---- einde macro's ------------------------------------------------------------------*/
|
||
|
|
||
|
// needs #include <TelnetStream.h> // Version 0.0.1 - https://github.com/jandrassy/TelnetStream
|
||
|
|
||
|
char _bol[128];
|
||
|
void _debugBOL(const char *fn, int line)
|
||
|
{
|
||
|
|
||
|
snprintf(_bol, sizeof(_bol), "[%02d:%02d:%02d][%7u|%6u] %-12.12s(%4d): ", \
|
||
|
hour(), minute(), second(), \
|
||
|
ESP.getFreeHeap(), ESP.getMaxFreeBlockSize(),\
|
||
|
fn, line);
|
||
|
|
||
|
Serial.print (_bol);
|
||
|
TelnetStream.print (_bol);
|
||
|
}
|