From 1be6bd7567c8ac6997e8a66de6f129381f97a7cb Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Tue, 27 Oct 2020 15:31:42 +0100 Subject: [PATCH] sys/arduino: use fmt_float to print float values --- sys/Makefile.dep | 1 + sys/arduino/serialport.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/Makefile.dep b/sys/Makefile.dep index e96a15b89b..dd5a15ef1a 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -13,6 +13,7 @@ ifneq (,$(filter arduino,$(USEMODULE))) FEATURES_OPTIONAL += arduino_pwm FEATURES_OPTIONAL += periph_adc FEATURES_REQUIRED += periph_gpio + USEMODULE += fmt USEMODULE += xtimer endif diff --git a/sys/arduino/serialport.cpp b/sys/arduino/serialport.cpp index e7c4f5e0c4..9b527b3efb 100644 --- a/sys/arduino/serialport.cpp +++ b/sys/arduino/serialport.cpp @@ -22,6 +22,7 @@ extern "C" { #include #include +#include "fmt.h" #include "irq.h" } @@ -148,7 +149,7 @@ size_t SerialPort::print(float val) size_t SerialPort::print(float val, int format) { char buf[64]; - size_t len = sprintf(buf, "%.*f", format, (double)val); + size_t len = fmt_float(buf, val, format); write(buf, len); return len; }