1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-06 05:21:22 +03:00

add Print::printf

This commit is contained in:
ficeto 2015-05-16 18:25:22 +03:00
parent 53cb1a0140
commit 0b168fd1bf
2 changed files with 12 additions and 0 deletions

View File

@ -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<PGM_P>(ifsh);

View File

@ -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[]);