diff --git a/cores/esp8266/Print.cpp b/cores/esp8266/Print.cpp index c1405c9f7..aa63cd290 100644 --- a/cores/esp8266/Print.cpp +++ b/cores/esp8266/Print.cpp @@ -30,6 +30,7 @@ #include "Print.h" extern "C" { #include "c_types.h" +#include "ets_sys.h" } // Public Methods ////////////////////////////////////////////////////////////// @@ -43,6 +44,16 @@ size_t ICACHE_FLASH_ATTR Print::write(const uint8_t *buffer, size_t size) { return n; } +size_t Print::printf(const char *format, ...) { + va_list arg; + va_start(arg, format); + char temp[256]; + size_t len = ets_vsnprintf(temp, 256, format, arg); + len = write((const char *)temp); + va_end(arg); + return len; +} + size_t ICACHE_FLASH_ATTR Print::print(const __FlashStringHelper *ifsh) { PGM_P p = reinterpret_cast(ifsh); diff --git a/cores/esp8266/Print.h b/cores/esp8266/Print.h index 79358f157..7366174f5 100644 --- a/cores/esp8266/Print.h +++ b/cores/esp8266/Print.h @@ -63,6 +63,7 @@ class Print { return write((const uint8_t *) buffer, size); } + size_t printf(const char * format, ...); size_t print(const __FlashStringHelper *); size_t print(const String &); size_t print(const char[]);