Skip to content

Commit a89a0df

Browse files
committed
tweaks to make gamebuino meta compile
1 parent 451a78e commit a89a0df

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

cores/arduino/Print.cpp

+12-2
Original file line numberDiff line numberDiff 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

191201
size_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
}

cores/arduino/Print.h

+4-9
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@
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

3635
class 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

platform.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ compiler.warning_flags.all=-Wall -Wextra
3333

3434
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
3535
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}"""
3737
compiler.c.elf.cmd=arm-none-eabi-gcc
3838
compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps
3939
compiler.S.cmd=arm-none-eabi-gcc
4040
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
4141
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}"""
4343
compiler.ar.cmd=arm-none-eabi-ar
4444
compiler.ar.flags=rcs
4545
compiler.objcopy.cmd=arm-none-eabi-objcopy

0 commit comments

Comments
 (0)