Fork and fix for mwork
Dependencies: mbed-dev-f303 FastPWM3 millis
macro.h
- Committer:
- annhandt09
- Date:
- 2020-06-26
- Revision:
- 55:fee62d8fd8fb
- Child:
- 58:fb799e99a5f7
File content as of revision 55:fee62d8fd8fb:
#ifndef macro_h #define macro_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; } } #endif