Skip to content

Commit

Permalink
Fix Print::printf implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Jan 15, 2025
1 parent 893df5c commit fbdccf8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cores/nRF5/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <string.h>
#include <math.h>
#include "Arduino.h"
#include "printf.h"

#include "Print.h"

Expand Down Expand Up @@ -187,11 +188,16 @@ size_t Print::println(const Printable& x)
return n;
}

extern "C" void streamOutput(char character, void* arg)
{
(static_cast<Print *>(arg))->write(character);
}

int Print::printf(const char* format, ...)
{
va_list va;
va_start(va, format);
int ret = vprintf(format, va);
int ret = vfctprintf(&streamOutput, this, format, va);
va_end(va);
return ret;
}
Expand Down

0 comments on commit fbdccf8

Please sign in to comment.