sys/arduino: use fmt_float to print float values

This commit is contained in:
Alexandre Abadie 2020-10-27 15:31:42 +01:00
parent f46572a308
commit 1be6bd7567
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
2 changed files with 3 additions and 1 deletions

View File

@ -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

View File

@ -22,6 +22,7 @@ extern "C" {
#include <string.h>
#include <stdio.h>
#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;
}