File tree Expand file tree Collapse file tree 3 files changed +18
-13
lines changed Expand file tree Collapse file tree 3 files changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -186,6 +186,16 @@ size_t Print::println(const Printable& x)
186186 return n;
187187}
188188
189+ void Print::printf (const char format[], ...)
190+ {
191+ char buf[PRINTF_BUF];
192+ va_list ap;
193+ va_start (ap, format);
194+ vsnprintf (buf, sizeof (buf), format, ap);
195+ write (buf);
196+ va_end (ap);
197+ }
198+
189199// Private Methods /////////////////////////////////////////////////////////////
190200
191201size_t Print::printNumber (unsigned long n, uint8_t base)
@@ -238,14 +248,14 @@ size_t Print::printFloat(double number, uint8_t digits)
238248
239249 // Print the decimal point, but only if there are digits beyond
240250 if (digits > 0 ) {
241- n += print (' . ' );
251+ n += print (" . " );
242252 }
243253
244254 // Extract digits from the remainder one at a time
245255 while (digits-- > 0 )
246256 {
247257 remainder *= 10.0 ;
248- unsigned int toPrint = (unsigned int )( remainder) ;
258+ unsigned int toPrint = (unsigned int )remainder;
249259 n += print (toPrint);
250260 remainder -= toPrint;
251261 }
Original file line number Diff line number Diff line change 2121
2222#include < inttypes.h>
2323#include < stdio.h> // for size_t
24+ #include < stdarg.h> // for printf
25+ #define PRINTF_BUF 80
2426
2527#include " WString.h"
2628#include " Printable.h"
2729
2830#define DEC 10
2931#define HEX 16
3032#define OCT 8
31- #ifdef BIN // Prevent warnings if BIN is previously defined in "iotnx4.h" or similar
32- #undef BIN
33- #endif
3433#define BIN 2
3534
3635class Print
@@ -57,10 +56,6 @@ class Print
5756 return write ((const uint8_t *)buffer, size);
5857 }
5958
60- // default to zero, meaning "a single write may block"
61- // should be overriden by subclasses with buffering
62- virtual int availableForWrite () { return 0 ; }
63-
6459 size_t print (const __FlashStringHelper *);
6560 size_t print (const String &);
6661 size_t print (const char []);
@@ -85,8 +80,8 @@ class Print
8580 size_t println (double , int = 2 );
8681 size_t println (const Printable&);
8782 size_t println (void );
88-
89- virtual void flush () { /* Empty implementation for backward compatibility */ }
83+
84+ void printf ( const char [], ...);
9085};
9186
9287#endif
Original file line number Diff line number Diff line change @@ -33,13 +33,13 @@ compiler.warning_flags.all=-Wall -Wextra
3333
3434compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
3535compiler.c.cmd=arm-none-eabi-gcc
36- compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD
36+ compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}"""
3737compiler.c.elf.cmd=arm-none-eabi-gcc
3838compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps
3939compiler.S.cmd=arm-none-eabi-gcc
4040compiler.S.flags=-c -g -x assembler-with-cpp -MMD
4141compiler.cpp.cmd=arm-none-eabi-g++
42- compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD
42+ compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}"""
4343compiler.ar.cmd=arm-none-eabi-ar
4444compiler.ar.flags=rcs
4545compiler.objcopy.cmd=arm-none-eabi-objcopy
You can’t perform that action at this time.
0 commit comments