diff --git a/CHANGELOG.md b/CHANGELOG.md index 23db7385..42e6ba6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ HEAD * Fix return type of `StaticJsonDocument::operator=` * Avoid pool reallocation in `BasicJsonDocument`'s copy assignment if capacity is the same * Avoid including `Arduino.h` when all its features are disabled (issue #1692, PR #1693 by @paulocsanz) +* Assume `PROGMEM` is available as soon as `ARDUINO` is defined (consequence of #1693) v6.18.5 (2021-09-28) diff --git a/examples/ProgmemExample/ProgmemExample.ino b/examples/ProgmemExample/ProgmemExample.ino index 203c8889..f4166f0e 100644 --- a/examples/ProgmemExample/ProgmemExample.ino +++ b/examples/ProgmemExample/ProgmemExample.ino @@ -14,8 +14,6 @@ #include void setup() { -#ifdef PROGMEM // <- check that Flash strings are supported - DynamicJsonDocument doc(1024); // You can use a Flash String as your JSON input. @@ -46,12 +44,6 @@ void setup() { if (obj["sensor"] == F("gps")) { // ... } - -#else - -#warning PROGMEM is not supported on this platform - -#endif } void loop() { diff --git a/extras/tests/Helpers/Arduino.h b/extras/tests/Helpers/Arduino.h index 656cae27..7ed58f7a 100644 --- a/extras/tests/Helpers/Arduino.h +++ b/extras/tests/Helpers/Arduino.h @@ -7,5 +7,6 @@ #include "api/Print.h" #include "api/Stream.h" #include "api/String.h" +#include "progmem_emulation.hpp" #define ARDUINO_H_INCLUDED 1 diff --git a/extras/tests/Helpers/progmem_emulation.hpp b/extras/tests/Helpers/progmem_emulation.hpp index 086ce10c..545cef36 100644 --- a/extras/tests/Helpers/progmem_emulation.hpp +++ b/extras/tests/Helpers/progmem_emulation.hpp @@ -3,7 +3,6 @@ // MIT License #include // uint8_t -#include // strcmp, strlen... #define PROGMEM diff --git a/extras/tests/Misc/StringAdapters.cpp b/extras/tests/Misc/StringAdapters.cpp index 4cdedc13..fe585080 100644 --- a/extras/tests/Misc/StringAdapters.cpp +++ b/extras/tests/Misc/StringAdapters.cpp @@ -6,7 +6,6 @@ #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 #include "custom_string.hpp" -#include "progmem_emulation.hpp" #include "weird_strcmp.hpp" #include diff --git a/extras/tests/Misc/weird_strcmp.hpp b/extras/tests/Misc/weird_strcmp.hpp index 3dbc0cf2..1d2e88f9 100644 --- a/extras/tests/Misc/weird_strcmp.hpp +++ b/extras/tests/Misc/weird_strcmp.hpp @@ -1,5 +1,11 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + #include +#include // strcmp, strncmp + // Issue #1198: strcmp() implementation that returns a value larger than 8-bit namespace ARDUINOJSON_NAMESPACE { diff --git a/extras/tests/MixedConfiguration/enable_progmem_1.cpp b/extras/tests/MixedConfiguration/enable_progmem_1.cpp index 1f8e8ca5..23e98f72 100644 --- a/extras/tests/MixedConfiguration/enable_progmem_1.cpp +++ b/extras/tests/MixedConfiguration/enable_progmem_1.cpp @@ -2,8 +2,6 @@ // Copyright Benoit Blanchon 2014-2021 // MIT License -#include "progmem_emulation.hpp" - #define ARDUINOJSON_ENABLE_PROGMEM 1 #include diff --git a/extras/tests/MixedConfiguration/enable_string_deduplication_0.cpp b/extras/tests/MixedConfiguration/enable_string_deduplication_0.cpp index 2cf6a785..f4e7ce5c 100644 --- a/extras/tests/MixedConfiguration/enable_string_deduplication_0.cpp +++ b/extras/tests/MixedConfiguration/enable_string_deduplication_0.cpp @@ -2,8 +2,6 @@ // Copyright Benoit Blanchon 2014-2021 // MIT License -#include "progmem_emulation.hpp" - #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 #define ARDUINOJSON_ENABLE_PROGMEM 1 #define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 0 diff --git a/extras/tests/MixedConfiguration/enable_string_deduplication_1.cpp b/extras/tests/MixedConfiguration/enable_string_deduplication_1.cpp index 799e9923..ccc02b79 100644 --- a/extras/tests/MixedConfiguration/enable_string_deduplication_1.cpp +++ b/extras/tests/MixedConfiguration/enable_string_deduplication_1.cpp @@ -2,8 +2,6 @@ // Copyright Benoit Blanchon 2014-2021 // MIT License -#include "progmem_emulation.hpp" - #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 #define ARDUINOJSON_ENABLE_PROGMEM 1 #define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 1 diff --git a/src/ArduinoJson/Configuration.hpp b/src/ArduinoJson/Configuration.hpp index 9befbcad..a90917b8 100644 --- a/src/ArduinoJson/Configuration.hpp +++ b/src/ArduinoJson/Configuration.hpp @@ -131,6 +131,11 @@ # define ARDUINOJSON_ENABLE_ARDUINO_PRINT 1 # endif +// Enable support for PROGMEM +# ifndef ARDUINOJSON_ENABLE_PROGMEM +# define ARDUINOJSON_ENABLE_PROGMEM 1 +# endif + #else // ARDUINO // Disable support for Arduino's String class @@ -148,16 +153,12 @@ # define ARDUINOJSON_ENABLE_ARDUINO_PRINT 0 # endif -#endif // ARDUINO - -#ifndef ARDUINOJSON_ENABLE_PROGMEM -# if defined(PROGMEM) && defined(pgm_read_byte) && defined(pgm_read_dword) && \ - defined(pgm_read_ptr) && defined(pgm_read_float) -# define ARDUINOJSON_ENABLE_PROGMEM 1 -# else +// Disable support for PROGMEM +# ifndef ARDUINOJSON_ENABLE_PROGMEM # define ARDUINOJSON_ENABLE_PROGMEM 0 # endif -#endif + +#endif // ARDUINO // Convert unicode escape sequence (\u0123) to UTF-8 #ifndef ARDUINOJSON_DECODE_UNICODE