File tree 3 files changed +18
-13
lines changed
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)
186
186
return n;
187
187
}
188
188
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
+
189
199
// Private Methods /////////////////////////////////////////////////////////////
190
200
191
201
size_t Print::printNumber (unsigned long n, uint8_t base)
@@ -238,14 +248,14 @@ size_t Print::printFloat(double number, uint8_t digits)
238
248
239
249
// Print the decimal point, but only if there are digits beyond
240
250
if (digits > 0 ) {
241
- n += print (' . ' );
251
+ n += print (" . " );
242
252
}
243
253
244
254
// Extract digits from the remainder one at a time
245
255
while (digits-- > 0 )
246
256
{
247
257
remainder *= 10.0 ;
248
- unsigned int toPrint = (unsigned int )( remainder ) ;
258
+ unsigned int toPrint = (unsigned int )remainder ;
249
259
n += print (toPrint);
250
260
remainder -= toPrint;
251
261
}
Original file line number Diff line number Diff line change 21
21
22
22
#include < inttypes.h>
23
23
#include < stdio.h> // for size_t
24
+ #include < stdarg.h> // for printf
25
+ #define PRINTF_BUF 80
24
26
25
27
#include " WString.h"
26
28
#include " Printable.h"
27
29
28
30
#define DEC 10
29
31
#define HEX 16
30
32
#define OCT 8
31
- #ifdef BIN // Prevent warnings if BIN is previously defined in "iotnx4.h" or similar
32
- #undef BIN
33
- #endif
34
33
#define BIN 2
35
34
36
35
class Print
@@ -57,10 +56,6 @@ class Print
57
56
return write ((const uint8_t *)buffer, size);
58
57
}
59
58
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
-
64
59
size_t print (const __FlashStringHelper *);
65
60
size_t print (const String &);
66
61
size_t print (const char []);
@@ -85,8 +80,8 @@ class Print
85
80
size_t println (double , int = 2 );
86
81
size_t println (const Printable&);
87
82
size_t println (void );
88
-
89
- virtual void flush () { /* Empty implementation for backward compatibility */ }
83
+
84
+ void printf ( const char [], ...);
90
85
};
91
86
92
87
#endif
Original file line number Diff line number Diff line change @@ -33,13 +33,13 @@ compiler.warning_flags.all=-Wall -Wextra
33
33
34
34
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
35
35
compiler.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}"""
37
37
compiler.c.elf.cmd=arm-none-eabi-gcc
38
38
compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps
39
39
compiler.S.cmd=arm-none-eabi-gcc
40
40
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
41
41
compiler.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}"""
43
43
compiler.ar.cmd=arm-none-eabi-ar
44
44
compiler.ar.flags=rcs
45
45
compiler.objcopy.cmd=arm-none-eabi-objcopy
You can’t perform that action at this time.
0 commit comments