Update debug for STM32

This commit is contained in:
fvanroie 2020-04-30 17:30:51 +02:00
parent 7e82697982
commit f9d14e7fba

View File

@ -15,7 +15,7 @@
#endif #endif
#include "hasp_hal.h" #include "hasp_hal.h"
#if HASP_USE_MQTT>0 #if HASP_USE_MQTT > 0
#include "hasp_mqtt.h" #include "hasp_mqtt.h"
#endif #endif
@ -94,7 +94,8 @@ String debugHaspHeader()
{ {
String header((char *)0); String header((char *)0);
header.reserve(256); header.reserve(256);
header = F(" _____ _____ _____ _____\r\n" if(debugAnsiCodes) header += TERM_COLOR_YELLOW;
header += F(" _____ _____ _____ _____\r\n"
" | | | _ | __| _ |\r\n" " | | | _ | __| _ |\r\n"
" | | |__ | __|\r\n" " | | |__ | __|\r\n"
" |__|__|__|__|_____|__|\r\n" " |__|__|__|__|_____|__|\r\n"
@ -216,8 +217,8 @@ static void debugPrintTimestamp(int level, Print * _logOutput)
time_t rawtime; time_t rawtime;
struct tm * timeinfo; struct tm * timeinfo;
//time(&rawtime); // time(&rawtime);
//timeinfo = localtime(&rawtime); // timeinfo = localtime(&rawtime);
// strftime(buffer, sizeof(buffer), "%b %d %H:%M:%S.", timeinfo); // strftime(buffer, sizeof(buffer), "%b %d %H:%M:%S.", timeinfo);
// Serial.println(buffer); // Serial.println(buffer);
@ -229,8 +230,10 @@ static void debugPrintTimestamp(int level, Print * _logOutput)
strftime(buffer, sizeof(buffer), "[%b %d %H:%M:%S.", timeinfo); // Literal String strftime(buffer, sizeof(buffer), "[%b %d %H:%M:%S.", timeinfo); // Literal String
_logOutput->print(buffer); _logOutput->print(buffer);
_logOutput->printf(PSTR("%03lu]"), millis() % 1000); _logOutput->printf(PSTR("%03lu]"), millis() % 1000);
} else */ { } else */
_logOutput->printf(PSTR("[%20.3f]"), (float)millis() / 1000); {
//_logOutput->printf(PSTR("[%20.3f]"), (float)millis() / 1000);
_logOutput->printf(PSTR("[%20d]"), millis() );
} }
} }
@ -331,8 +334,8 @@ void debugPreSetup(JsonObject settings)
if(baudrate >= 9600u) { /* the baudrates are stored divided by 10 */ if(baudrate >= 9600u) { /* the baudrates are stored divided by 10 */
#ifdef STM32_CORE_VERSION_MAJOR #ifdef STM32_CORE_VERSION_MAJOR
Serial.setRx(PA3); // User Serial2 // Serial.setRx(PA3); // User Serial2
Serial.setTx(PA2); // Serial.setTx(PA2);
#endif #endif
Serial.begin(baudrate); /* prepare for possible serial debug */ Serial.begin(baudrate); /* prepare for possible serial debug */
delay(10); delay(10);