ARTI-FX: Fix printing to USER_PRINT (if !logToFile)

This commit is contained in:
Ewoud
2023-04-07 13:57:27 +02:00
parent 4aea3970a3
commit a6e2cf0b26
2 changed files with 43 additions and 50 deletions

View File

@@ -96,59 +96,52 @@ void artiPrintf(char const * format, ...)
va_start(argp, format); va_start(argp, format);
if (!logToFile) // if (!logToFile)
{ // {
//WLEDMM: to be done, check if we can move to USER_PRINTF // //WLEDMM: not working to use USER_PRINTF here in case of arduino so moving to rocket science part
#if ARTI_PLATFORM == ARTI_ARDUINO //defined in arti_definition.h e.g. arti_wled.h! // vprintf(format, argp);
USER_PRINTF(format, argp); //WLEDMM also supporting netprint // }
#else // else
vprintf(format, argp); #if ARTI_PLATFORM == ARTI_ARDUINO
#endif // rocket science here! As logfile.printf causes crashes/wrong output we create our own printf here
// logFile.printf(format, argp);
} for (size_t i = 0; i < strlen(format); i++)
else {
{ if (format[i] == '%')
#if ARTI_PLATFORM == ARTI_ARDUINO
// rocket science here! As logfile.printf causes crashes/wrong output we create our own printf here
// logFile.printf(format, argp);
for (size_t i = 0; i < strlen(format); i++)
{ {
if (format[i] == '%') switch (format[i+1])
{ {
switch (format[i+1]) case 's':
{ if (logToFile) logFile.print(va_arg(argp, const char *)); else USER_PRINT(va_arg(argp, const char *));
case 's': break;
logFile.print(va_arg(argp, const char *)); case 'u':
break; if (logToFile) logFile.print(va_arg(argp, unsigned int)); else USER_PRINT(va_arg(argp, unsigned int));
case 'u': break;
logFile.print(va_arg(argp, unsigned int)); case 'c':
break; if (logToFile) logFile.print((char)va_arg(argp, int)); else USER_PRINT(va_arg(argp, int));
case 'c': break;
logFile.print((char)va_arg(argp, int)); case 'f':
break; if (logToFile) logFile.print(va_arg(argp, double)); else USER_PRINT(va_arg(argp, double));
case 'f': break;
logFile.print(va_arg(argp, double)); case '%':
break; if (logToFile) logFile.print("%"); else USER_PRINT("%"); // in case of %%
case '%': break;
logFile.print("%"); // in case of %% default:
break; va_arg(argp, int);
default: // logFile.print(x);
va_arg(argp, int); if (logToFile) logFile.print(format[i]); else USER_PRINT(format[i]);
// logFile.print(x); if (logToFile) logFile.print(format[i+1]); else USER_PRINT(format[i+1]);
logFile.print(format[i]);
logFile.print(format[i+1]);
}
i++;
}
else
{
logFile.print(format[i]);
} }
i++;
} }
#else else
vfprintf(logFile, format, argp); {
#endif if (logToFile) logFile.print(format[i]); else USER_PRINT(format[i]);
} }
}
#else
vfprintf(logFile, format, argp);
#endif
va_end(argp); va_end(argp);
} }

View File

@@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2304070 #define VERSION 2304071
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG