Update ArduionApi to include Print::printf

Instead of duplicating output call in all children, fork ArduinoApi and
add it in the Print base class.
parent e98fac6e
[submodule "ArduinoCore-API"]
path = ArduinoCore-API
url = https://github.com/arduino/ArduinoCore-API.git
url = https://github.com/earlephilhower/ArduinoCore-API.git
[submodule "pico-sdk"]
path = pico-sdk
url = https://github.com/raspberrypi/pico-sdk.git
......
Subproject commit 2af4a9c721f96b80010caf6923a12809f13026cd
Subproject commit 8f747a4a5756cbea5123b34bb7f65b043cb80c26
......@@ -51,29 +51,6 @@ public:
using Print::write;
operator bool() override;
// By all rights, this should be in Print.h...
size_t printf(const char *format, ...) {
va_list arg;
va_start(arg, format);
char temp[64];
char* buffer = temp;
size_t len = vsnprintf(temp, sizeof(temp), format, arg);
va_end(arg);
if (len > sizeof(temp) - 1) {
buffer = new char[len + 1];
if (!buffer) {
return 0;
}
va_start(arg, format);
vsnprintf(buffer, len + 1, format, arg);
va_end(arg);
}
len = write((const uint8_t*) buffer, len);
if (buffer != temp) {
delete[] buffer;
}
return len;
}
private:
bool _running = false;
uart_inst_t *_uart;
......
......@@ -42,30 +42,6 @@ public:
using Print::write;
operator bool() override;
// By all rights, this should be in Print.h...
size_t printf(const char *format, ...) {
va_list arg;
va_start(arg, format);
char temp[64];
char* buffer = temp;
size_t len = vsnprintf(temp, sizeof(temp), format, arg);
va_end(arg);
if (len > sizeof(temp) - 1) {
buffer = new char[len + 1];
if (!buffer) {
return 0;
}
va_start(arg, format);
vsnprintf(buffer, len + 1, format, arg);
va_end(arg);
}
len = write((const uint8_t*) buffer, len);
if (buffer != temp) {
delete[] buffer;
}
return len;
}
private:
bool _running = false;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment