worked on FAT32 stuff

This commit is contained in:
2021-02-21 09:33:08 +01:00
parent da12992ae8
commit 4ac72c678f
13 changed files with 494 additions and 148 deletions

57
Debug.h
View File

@@ -31,41 +31,54 @@ extern "C" {
class Log {
public:
template<typename... Args> static void addInfo(const char* module, const char* fmt, Args... args) {
template<typename... Args> static inline void addInfo(const char* module, const char* fmt, Args... args) {
add('i', module, fmt, args...);
}
template<typename... Args> static void addError(const char* module, const char* fmt, Args... args) {
template<typename... Args> static inline void addError(const char* module, const char* fmt, Args... args) {
add('e', module, fmt, args...);
while(true) {}
//while(true) {}
}
private:
template<typename... Args> static void add(char level, const char* module, const char* fmt, Args... args) {
char buf[4096];
char* dst = buf;
#if defined(WITH_LOG)
dst = dst + sprintf(dst, "%c[%-10s] ", level, module);
dst = dst + sprintf(dst, fmt, args...);
dst = dst + sprintf(dst, "\n");
template<typename... Args> static void add(char level, const char* module, const char* fmt, Args... args) {
#ifdef IS_DESKTOP
printf(buf);
#elif TEENSY
Serial.print(buf);
#elif ESP8266
os_printf(buf);
#elif ESP32
printf(buf);
#else
#error "unsupported platform"
#endif
// temporal buffer (NOTE! MUST NOT BE TOO LARGE OR IT CAN KILL THE STACK!)
char buf[512];
}
char* dst = buf;
char* end = buf + sizeof(buf);
dst = dst + snprintf(dst, (end-dst), "%c[%-10s] ", level, module);
dst = dst + snprintf(dst, (end-dst)-2, fmt, args...);
dst = dst + snprintf(dst, (end-dst), "\n");
#if IS_DESKTOP
printf(buf);
#elif TEENSY
Serial.print(buf);
#elif ESP8266
os_printf(buf);
#elif ESP32
printf(buf);
#else
#error "unsupported platform"
#endif
}
#else
template<typename... Args> static void add(char , const char* , const char* , Args... ) {}
#endif
};