From 8a7702de5d080e53feee92b3ea05212f22f3ced9 Mon Sep 17 00:00:00 2001 From: Helmut Tschemernjak Date: Thu, 16 Nov 2017 09:57:15 +0100 Subject: [PATCH 1/6] Added c++ linker command to allow to include libstdc++ when linking. This is needed otherwise the template C++ container support are missing. The "compiler.c.elf.cmd" specifies the linker, the C linker was wrong here and does not work for true C++ apps. This change does not hurt because when no libstdc++ features are being used there is no change. Changed the Arduino function map() into Arduino_map(). This is needed otherwise it clashes with the C++ template class. e.g.: #include --- cores/arduino/WMath.cpp | 2 +- cores/arduino/WMath.h | 2 +- platform.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cores/arduino/WMath.cpp b/cores/arduino/WMath.cpp index 55caddd62..70df66e80 100644 --- a/cores/arduino/WMath.cpp +++ b/cores/arduino/WMath.cpp @@ -52,7 +52,7 @@ extern long random( long howsmall, long howbig ) return random(diff) + howsmall; } -extern long map(long x, long in_min, long in_max, long out_min, long out_max) +extern long Arduino_map(long x, long in_min, long in_max, long out_min, long out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } diff --git a/cores/arduino/WMath.h b/cores/arduino/WMath.h index 1893955cb..e32273221 100644 --- a/cores/arduino/WMath.h +++ b/cores/arduino/WMath.h @@ -22,7 +22,7 @@ extern long random( long ) ; extern long random( long, long ) ; extern void randomSeed( uint32_t dwSeed ) ; -extern long map( long, long, long, long, long ) ; +extern long Arduino_map( long, long, long, long, long ) ; extern uint16_t makeWord( uint16_t w ) ; extern uint16_t makeWord( uint8_t h, uint8_t l ) ; diff --git a/platform.txt b/platform.txt index 03f054f76..545f5b63d 100644 --- a/platform.txt +++ b/platform.txt @@ -34,7 +34,7 @@ compiler.warning_flags.all=-Wall -Wextra compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ compiler.c.cmd=arm-none-eabi-gcc 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 -compiler.c.elf.cmd=arm-none-eabi-gcc +compiler.c.elf.cmd=arm-none-eabi-g++ compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps compiler.S.cmd=arm-none-eabi-gcc compiler.S.flags=-c -g -x assembler-with-cpp -MMD From 89bed89ae1d9818796b8f10aa229896c2aeabf50 Mon Sep 17 00:00:00 2001 From: Helmut Tschemernjak Date: Thu, 16 Nov 2017 14:34:45 +0100 Subject: [PATCH 2/6] Added a map define to Arduino_map which allows backward compatibility. --- cores/arduino/WMath.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cores/arduino/WMath.h b/cores/arduino/WMath.h index e32273221..54d9c2146 100644 --- a/cores/arduino/WMath.h +++ b/cores/arduino/WMath.h @@ -28,6 +28,7 @@ extern uint16_t makeWord( uint16_t w ) ; extern uint16_t makeWord( uint8_t h, uint8_t l ) ; #define word(...) makeWord(__VA_ARGS__) +#define map Arduino_map #endif /* _WIRING_MATH_ */ From 10f413a9c4229e17241c814f69ea665c63cd7e40 Mon Sep 17 00:00:00 2001 From: Helmut Tschemernjak Date: Thu, 16 Nov 2017 17:24:45 +0100 Subject: [PATCH 3/6] Use map macro with parameters --- cores/arduino/WMath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/arduino/WMath.h b/cores/arduino/WMath.h index 54d9c2146..b1d32e678 100644 --- a/cores/arduino/WMath.h +++ b/cores/arduino/WMath.h @@ -28,7 +28,7 @@ extern uint16_t makeWord( uint16_t w ) ; extern uint16_t makeWord( uint8_t h, uint8_t l ) ; #define word(...) makeWord(__VA_ARGS__) -#define map Arduino_map +#define map(a,b,c,d,e) Arduino_map(a,b,c,d,e) #endif /* _WIRING_MATH_ */ From ce568182e18f15b1252d13ad5c6281de603e9cd9 Mon Sep 17 00:00:00 2001 From: Helmut Tschemernjak Date: Mon, 27 Nov 2017 17:03:44 +0100 Subject: [PATCH 4/6] Removed macro map parameters to avoid build errors --- cores/arduino/WMath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/arduino/WMath.h b/cores/arduino/WMath.h index b1d32e678..a908bcf6c 100644 --- a/cores/arduino/WMath.h +++ b/cores/arduino/WMath.h @@ -28,7 +28,7 @@ extern uint16_t makeWord( uint16_t w ) ; extern uint16_t makeWord( uint8_t h, uint8_t l ) ; #define word(...) makeWord(__VA_ARGS__) -#define map(a,b,c,d,e) Arduino_map(a,b,c,d,e) +#define map Arduino_map #endif /* _WIRING_MATH_ */ From ed5bcf25da2cc67a894712ae94791ff90b327785 Mon Sep 17 00:00:00 2001 From: Helmut Tschemernjak Date: Tue, 28 Nov 2017 13:00:16 +0100 Subject: [PATCH 5/6] The renaming of map is not needed for the C++ map by using std::map See also discussion here: https://github.com/espressif/arduino-esp32/pull/838 --- cores/arduino/WMath.cpp | 2 +- cores/arduino/WMath.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/arduino/WMath.cpp b/cores/arduino/WMath.cpp index 70df66e80..55caddd62 100644 --- a/cores/arduino/WMath.cpp +++ b/cores/arduino/WMath.cpp @@ -52,7 +52,7 @@ extern long random( long howsmall, long howbig ) return random(diff) + howsmall; } -extern long Arduino_map(long x, long in_min, long in_max, long out_min, long out_max) +extern long map(long x, long in_min, long in_max, long out_min, long out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } diff --git a/cores/arduino/WMath.h b/cores/arduino/WMath.h index a908bcf6c..fbf69cb90 100644 --- a/cores/arduino/WMath.h +++ b/cores/arduino/WMath.h @@ -22,7 +22,7 @@ extern long random( long ) ; extern long random( long, long ) ; extern void randomSeed( uint32_t dwSeed ) ; -extern long Arduino_map( long, long, long, long, long ) ; +extern long map( long, long, long, long, long ) ; extern uint16_t makeWord( uint16_t w ) ; extern uint16_t makeWord( uint8_t h, uint8_t l ) ; From cdd1e8880334e0591a9dcaebebe9e331081b573a Mon Sep 17 00:00:00 2001 From: Helmut Tschemernjak Date: Thu, 28 Jun 2018 17:33:46 +0200 Subject: [PATCH 6/6] Removed a left over define. --- cores/arduino/WMath.h | 1 - 1 file changed, 1 deletion(-) diff --git a/cores/arduino/WMath.h b/cores/arduino/WMath.h index fbf69cb90..1893955cb 100644 --- a/cores/arduino/WMath.h +++ b/cores/arduino/WMath.h @@ -28,7 +28,6 @@ extern uint16_t makeWord( uint16_t w ) ; extern uint16_t makeWord( uint8_t h, uint8_t l ) ; #define word(...) makeWord(__VA_ARGS__) -#define map Arduino_map #endif /* _WIRING_MATH_ */