From a6a1720afc9fc615cb0d6a7255e3444369f9c1ee Mon Sep 17 00:00:00 2001 From: Andreas Merkle Date: Fri, 8 Nov 2024 16:28:03 +0100 Subject: [PATCH 1/2] "_USE_MATH_DEFINES" must be defined at project level to ensure that its applied for the math. include. Otherwise the math. might be included already, but without "_USE_MATH_DEFINES" which will raise an error that M_PI is not defined. --- README.md | 7 ++++++- examples/example/platformio.ini | 1 + src/Arduino.h | 10 +++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bc469ec..90813d8 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,12 @@ This library provides for this use case some Arduino interfaces, but not all yet lib_deps = BlueAndi/ArduinoNative @ ~0.1.0 ``` -2. Call the ```Arduino::setup()``` once and the ```Arduino::loop()``` in a infinite loop in your main entry point function. +2. Add this build flags to your _platformio.ini_ in your environment: + ``` + build_flags = + -D _USE_MATH_DEFINES + ``` +3. Call the ```Arduino::setup()``` once and the ```Arduino::loop()``` in a infinite loop in your main entry point function. ## Example See [minimal example](./examples/example/). diff --git a/examples/example/platformio.ini b/examples/example/platformio.ini index 0762229..3207351 100644 --- a/examples/example/platformio.ini +++ b/examples/example/platformio.ini @@ -16,6 +16,7 @@ platform = native @ ~1.2.1 build_flags = -std=c++11 + -D _USE_MATH_DEFINES lib_deps = MainNative BlueAndi/ArduinoNative @ ~0.1.1 diff --git a/src/Arduino.h b/src/Arduino.h index 932a124..84f2287 100644 --- a/src/Arduino.h +++ b/src/Arduino.h @@ -40,7 +40,9 @@ * Compile Switches *****************************************************************************/ -#define _USE_MATH_DEFINES +#ifndef _USE_MATH_DEFINES +#error Please define _USE_MATH_DEFINES in your build flags. +#endif /* _USE_MATH_DEFINES */ /****************************************************************************** * Includes @@ -53,6 +55,9 @@ * Macros *****************************************************************************/ +/** + * Constrain the given value to min. and max. + */ #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) #ifndef PSTR @@ -63,6 +68,9 @@ #define PROGMEM #endif +/** + * The constant PI. + */ #define PI M_PI /****************************************************************************** From e9ab7926b80991944ad763554dbc6052f29928b2 Mon Sep 17 00:00:00 2001 From: Andreas Merkle Date: Fri, 8 Nov 2024 16:30:31 +0100 Subject: [PATCH 2/2] Prepare for v0.2.1 --- library.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.json b/library.json index 4b6fc46..e842ca8 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ArduinoNative", - "version": "0.2.0", + "version": "0.2.1", "description": "Arduino for the native environment. It doesn't support every interface, just some of them!", "authors": [{ "name": "Andreas Merkle",