Fork and fix for mwork

Dependencies:   mbed-dev-f303 FastPWM3 millis

Revision:
58:fb799e99a5f7
Parent:
55:fee62d8fd8fb
--- a/macro.h	Sat Jun 27 07:50:17 2020 +0000
+++ b/macro.h	Mon Jun 29 03:34:16 2020 +0000
@@ -1,39 +1,10 @@
 #ifndef macro_h
 #define macro_h
+#include "mbed.h"
 #include "mode.h"
+
 extern Serial *pc ;
 extern int io_mode;
-#define Serial_printf(A) cond_printf(A)
-// Checks to see if in Serial mode before printing
-void cond_printf(const char *format, ...)
-{    
-    if (io_mode != IO_MODE_SERIAL) {
-        return;
-    }
-    /*if (io_mode == IO_MODE_STEP_DIR) {
-        pc->printf( "thoat");
-        return;
-    }
-    */
-    char loc_buf[64];
-    char * temp = loc_buf;
-    va_list arg;
-    va_list copy;
-    va_start(arg, format);
-    va_copy(copy, arg);
-    size_t len = vsnprintf(NULL, 0, format, arg);
-    va_end(copy);
-    if(len >= sizeof(loc_buf)){
-        temp = new char[len+1];
-        if(temp == NULL) {
-            return;
-        }
-    }
-    len = vsnprintf(temp, len+1, format, arg);
-    pc->printf( temp);
-    va_end(arg);
-    if(len > 64){
-        delete[] temp;
-    }    
-}
+#define Serial_printf(...) cond_printf(__VA_ARGS__)
+void cond_printf(const char *format, ...);
 #endif
\ No newline at end of file