From 71ee0ecbccb519b6cb63fb95e32b2d1dc1ac4a50 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Mon, 13 Feb 2023 10:32:09 +0100 Subject: [PATCH] Added new ArduinoJson library. Added new Synth_Dexed library. --- third-party/ArduinoJson/CHANGELOG.md | 7 + third-party/ArduinoJson/CMakeLists.txt | 2 +- .../ArduinoJson/{LICENSE.md => LICENSE.txt} | 20 +- third-party/ArduinoJson/README.md | 14 +- third-party/ArduinoJson/appveyor.yml | 2 +- .../extras/scripts/build-arduino-package.sh | 2 +- .../scripts/publish-particle-library.sh | 2 +- .../ArduinoJson/extras/scripts/publish.sh | 3 + .../extras/tests/Cpp11/stl_containers.cpp | 74 ++- .../extras/tests/Helpers/Arduino.h | 1 - .../extras/tests/JsonArray/copyArray.cpp | 2 +- .../extras/tests/JsonDeserializer/object.cpp | 6 +- .../extras/tests/Misc/StringAdapters.cpp | 1 + .../MixedConfiguration/enable_progmem_1.cpp | 2 + .../enable_string_deduplication_0.cpp | 2 + .../enable_string_deduplication_1.cpp | 2 + .../tests/MixedConfiguration/issue1707.cpp | 2 + .../ArduinoJson/extras/tests/catch/catch.hpp | 427 ++++++++++++------ third-party/ArduinoJson/idf_component.yml | 12 + third-party/ArduinoJson/library.json | 2 +- third-party/ArduinoJson/library.properties | 2 +- third-party/ArduinoJson/logo.svg | 1 - .../Deserialization/DeserializationError.hpp | 20 +- .../src/ArduinoJson/Numbers/FloatTraits.hpp | 83 ++-- .../Polyfills/pgmspace_generic.hpp | 35 +- .../ArduinoJson/Polyfills/static_array.hpp | 30 -- .../ArduinoJson/Variant/VariantRefBase.hpp | 8 +- .../ArduinoJson/src/ArduinoJson/version.hpp | 4 +- third-party/Synth_Dexed/src/dexed.cpp | 37 ++ third-party/Synth_Dexed/src/dexed.h | 12 + 30 files changed, 542 insertions(+), 275 deletions(-) rename third-party/ArduinoJson/{LICENSE.md => LICENSE.txt} (99%) create mode 100644 third-party/ArduinoJson/idf_component.yml delete mode 100644 third-party/ArduinoJson/logo.svg delete mode 100644 third-party/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp diff --git a/third-party/ArduinoJson/CHANGELOG.md b/third-party/ArduinoJson/CHANGELOG.md index a0125a9..dd4945b 100644 --- a/third-party/ArduinoJson/CHANGELOG.md +++ b/third-party/ArduinoJson/CHANGELOG.md @@ -1,6 +1,13 @@ ArduinoJson: change log ======================= +v6.20.1 (2023-02-08) +------- + +* Remove explicit exclusion of `as()` and `as()` (issue #1860) + If you try to call them, you'll now get the same error message as any unsupported type. + You could also add a custom converter for `char*` and `char`. + v6.20.0 (2022-12-26) ------- diff --git a/third-party/ArduinoJson/CMakeLists.txt b/third-party/ArduinoJson/CMakeLists.txt index 7841c0e..f31fffe 100644 --- a/third-party/ArduinoJson/CMakeLists.txt +++ b/third-party/ArduinoJson/CMakeLists.txt @@ -10,7 +10,7 @@ if(ESP_PLATFORM) return() endif() -project(ArduinoJson VERSION 6.20.0) +project(ArduinoJson VERSION 6.20.1) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) include(CTest) diff --git a/third-party/ArduinoJson/LICENSE.md b/third-party/ArduinoJson/LICENSE.txt similarity index 99% rename from third-party/ArduinoJson/LICENSE.md rename to third-party/ArduinoJson/LICENSE.txt index dee0b5b..e59620d 100644 --- a/third-party/ArduinoJson/LICENSE.md +++ b/third-party/ArduinoJson/LICENSE.txt @@ -1,10 +1,10 @@ -The MIT License (MIT) ---------------------- - -Copyright © 2014-2022, Benoit BLANCHON - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +The MIT License (MIT) +--------------------- + +Copyright © 2014-2022, Benoit BLANCHON + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/third-party/ArduinoJson/README.md b/third-party/ArduinoJson/README.md index 1e843d8..b0f539d 100644 --- a/third-party/ArduinoJson/README.md +++ b/third-party/ArduinoJson/README.md @@ -1,17 +1,18 @@

- ArduinoJson + ArduinoJson

--- -[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bblanchon/ArduinoJson/ci.yml?branch=6.x)](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A6.x) +[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bblanchon/ArduinoJson/ci.yml?branch=6.x&logo=github)](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A6.x) [![Continuous Integration](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/6.x?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x) [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/arduinojson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) [![Coveralls branch](https://img.shields.io/coveralls/github/bblanchon/ArduinoJson/6.x?logo=coveralls)](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x) -[![Arduino Library Manager](https://img.shields.io/static/v1?label=Arduino&message=v6.20.0&logo=arduino&logoColor=white&color=blue)](https://www.ardu-badge.com/ArduinoJson/6.20.0) -[![PlatformIO Registry](https://badges.registry.platformio.org/packages/bblanchon/library/ArduinoJson.svg?version=6.20.0)](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.20.0) -[![GitHub stars](https://img.shields.io/github/stars/bblanchon/ArduinoJson?style=flat&logo=github)](https://github.com/bblanchon/ArduinoJson/stargazers) -[![GitHub Sponsors](https://img.shields.io/github/sponsors/bblanchon?logo=github)](https://github.com/sponsors/bblanchon) +[![Arduino Library Manager](https://img.shields.io/static/v1?label=Arduino&message=v6.20.1&logo=arduino&logoColor=white&color=blue)](https://www.ardu-badge.com/ArduinoJson/6.20.1) +[![PlatformIO Registry](https://badges.registry.platformio.org/packages/bblanchon/library/ArduinoJson.svg?version=6.20.1)](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.20.1) +[![ESP IDF](https://img.shields.io/static/v1?label=ESP+IDF&message=v6.20.1&logo=cpu&logoColor=white&color=blue)](https://components.espressif.com/components/bblanchon/arduinojson) +[![GitHub stars](https://img.shields.io/github/stars/bblanchon/ArduinoJson?style=flat&logo=github&color=orange)](https://github.com/bblanchon/ArduinoJson/stargazers) +[![GitHub Sponsors](https://img.shields.io/github/sponsors/bblanchon?logo=github&color=orange)](https://github.com/sponsors/bblanchon) ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). @@ -99,7 +100,6 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). * Most popular of all Arduino libraries on [GitHub](https://github.com/search?o=desc&q=arduino+library&s=stars&type=Repositories) * [Used in hundreds of projects](https://www.hackster.io/search?i=projects&q=arduinojson) * [Responsive support](https://github.com/bblanchon/ArduinoJson/issues?q=is%3Aissue+is%3Aclosed) - * [Discord server](https://discord.gg/DzN6hHHD4h) ## Quickstart diff --git a/third-party/ArduinoJson/appveyor.yml b/third-party/ArduinoJson/appveyor.yml index 0276d5d..06681d4 100644 --- a/third-party/ArduinoJson/appveyor.yml +++ b/third-party/ArduinoJson/appveyor.yml @@ -1,4 +1,4 @@ -version: 6.20.0.{build} +version: 6.20.1.{build} environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 diff --git a/third-party/ArduinoJson/extras/scripts/build-arduino-package.sh b/third-party/ArduinoJson/extras/scripts/build-arduino-package.sh index 339db2f..09f6efb 100755 --- a/third-party/ArduinoJson/extras/scripts/build-arduino-package.sh +++ b/third-party/ArduinoJson/extras/scripts/build-arduino-package.sh @@ -18,6 +18,6 @@ rm -f "$OUTPUT" src \ keywords.txt \ library.properties \ - LICENSE.md \ + LICENSE.txt \ README.md \ ArduinoJson.h diff --git a/third-party/ArduinoJson/extras/scripts/publish-particle-library.sh b/third-party/ArduinoJson/extras/scripts/publish-particle-library.sh index 62c3140..d410c47 100755 --- a/third-party/ArduinoJson/extras/scripts/publish-particle-library.sh +++ b/third-party/ArduinoJson/extras/scripts/publish-particle-library.sh @@ -9,7 +9,7 @@ trap 'rm -rf "$WORK_DIR"' EXIT cp "$SOURCE_DIR/README.md" "$WORK_DIR/README.md" cp "$SOURCE_DIR/CHANGELOG.md" "$WORK_DIR/CHANGELOG.md" cp "$SOURCE_DIR/library.properties" "$WORK_DIR/library.properties" -cp "$SOURCE_DIR/LICENSE.md" "$WORK_DIR/LICENSE.txt" +cp "$SOURCE_DIR/LICENSE.txt" "$WORK_DIR/LICENSE.txt" cp -r "$SOURCE_DIR/src" "$WORK_DIR/" cp -r "$SOURCE_DIR/examples" "$WORK_DIR/" diff --git a/third-party/ArduinoJson/extras/scripts/publish.sh b/third-party/ArduinoJson/extras/scripts/publish.sh index c5a4eef..d3459d0 100755 --- a/third-party/ArduinoJson/extras/scripts/publish.sh +++ b/third-party/ArduinoJson/extras/scripts/publish.sh @@ -38,6 +38,9 @@ update_version_in_source () { sed -i~ -bE "s/version: .*$/version: $VERSION.{build}/" appveyor.yml rm appveyor.yml~ + sed -i~ -bE "s/^version: .*$/version: \"$VERSION\"/" idf_component.yml + rm idf_component.yml~ + sed -i~ -bE \ -e "s/ARDUINOJSON_VERSION .*$/ARDUINOJSON_VERSION \"$VERSION\"/" \ -e "s/ARDUINOJSON_VERSION_MAJOR .*$/ARDUINOJSON_VERSION_MAJOR $MAJOR/" \ diff --git a/third-party/ArduinoJson/extras/tests/Cpp11/stl_containers.cpp b/third-party/ArduinoJson/extras/tests/Cpp11/stl_containers.cpp index 9e590c1..4c664e7 100644 --- a/third-party/ArduinoJson/extras/tests/Cpp11/stl_containers.cpp +++ b/third-party/ArduinoJson/extras/tests/Cpp11/stl_containers.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -28,12 +29,38 @@ struct Converter > { static bool checkJson(JsonVariantConst src) { JsonArrayConst array = src; bool result = array; + for (JsonVariantConst item : array) + result &= item.is(); + return result; + } +}; + +template +struct Converter > { + static void toJson(const std::array& src, JsonVariant dst) { + JsonArray array = dst.to(); + for (T item : src) + array.add(item); + } + + static std::array fromJson(JsonVariantConst src) { + std::array dst; + dst.fill(0); + size_t idx = 0; + for (T item : src.as()) + dst[idx++] = item; + return dst; + } + + static bool checkJson(JsonVariantConst src) { + JsonArrayConst array = src; + bool result = array; + size_t size = 0; for (JsonVariantConst item : array) { - if (!result) - break; - result = item.is(); + result &= item.is(); + size++; } - return result; + return result && size == N; } }; } // namespace ARDUINOJSON_NAMESPACE @@ -70,3 +97,42 @@ TEST_CASE("vector") { CHECK(doc.is >() == false); } } + +TEST_CASE("array") { + typedef std::array array_type; + + SECTION("toJson") { + array_type v; + v[0] = 1; + v[1] = 2; + + StaticJsonDocument<128> doc; + doc.set(v); + REQUIRE(doc.as() == "[1,2]"); + } + + SECTION("fromJson") { + StaticJsonDocument<128> doc; + doc.add(1); + doc.add(2); + + auto v = doc.as(); + REQUIRE(v.size() == 2); + CHECK(v[0] == 1); + CHECK(v[1] == 2); + } + + SECTION("checkJson") { + StaticJsonDocument<128> doc; + CHECK(doc.is() == false); + + doc.add(1); + CHECK(doc.is() == false); + + doc.add(2); + CHECK(doc.is() == true); + + doc[0] = "foo"; + CHECK(doc.is() == false); + } +} diff --git a/third-party/ArduinoJson/extras/tests/Helpers/Arduino.h b/third-party/ArduinoJson/extras/tests/Helpers/Arduino.h index 4f24b26..bacc1a8 100644 --- a/third-party/ArduinoJson/extras/tests/Helpers/Arduino.h +++ b/third-party/ArduinoJson/extras/tests/Helpers/Arduino.h @@ -7,6 +7,5 @@ #include "api/Print.h" #include "api/Stream.h" #include "api/String.h" -#include "progmem_emulation.hpp" #define ARDUINO_H_INCLUDED 1 diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/copyArray.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/copyArray.cpp index 599821d..a28c5ac 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/copyArray.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonArray/copyArray.cpp @@ -165,7 +165,7 @@ TEST_CASE("copyArray()") { char json[32] = ""; int source[][3] = {{1, 2, 3}, {4, 5, 6}}; - CAPTURE(SIZE) + CAPTURE(SIZE); bool ok = copyArray(source, array); CAPTURE(doc.memoryUsage()); diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/object.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/object.cpp index e5d5de7..79b2975 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/object.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/object.cpp @@ -100,7 +100,7 @@ TEST_CASE("deserialize JSON object") { REQUIRE(obj["key"] == "value"); } - SECTION("Before the colon") { + SECTION("Before the comma") { DeserializationError err = deserializeJson(doc, "{\"key1\":\"value1\" ,\"key2\":\"value2\"}"); JsonObject obj = doc.as(); @@ -112,9 +112,9 @@ TEST_CASE("deserialize JSON object") { REQUIRE(obj["key2"] == "value2"); } - SECTION("After the colon") { + SECTION("After the comma") { DeserializationError err = - deserializeJson(doc, "{\"key1\":\"value1\" ,\"key2\":\"value2\"}"); + deserializeJson(doc, "{\"key1\":\"value1\", \"key2\":\"value2\"}"); JsonObject obj = doc.as(); REQUIRE(err == DeserializationError::Ok); diff --git a/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp b/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp index 0228233..03c4196 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp @@ -6,6 +6,7 @@ #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 #include "custom_string.hpp" +#include "progmem_emulation.hpp" #include "weird_strcmp.hpp" #include diff --git a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_progmem_1.cpp b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_progmem_1.cpp index 9ddf7f2..61e6c28 100644 --- a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_progmem_1.cpp +++ b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_progmem_1.cpp @@ -2,6 +2,8 @@ // Copyright © 2014-2022, Benoit BLANCHON // MIT License +#include "progmem_emulation.hpp" + #define ARDUINOJSON_ENABLE_PROGMEM 1 #include diff --git a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_0.cpp b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_0.cpp index d9ca166..4adb5ca 100644 --- a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_0.cpp +++ b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_0.cpp @@ -2,6 +2,8 @@ // Copyright © 2014-2022, Benoit BLANCHON // 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/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_1.cpp b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_1.cpp index 27fc18d..0059777 100644 --- a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_1.cpp +++ b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_1.cpp @@ -2,6 +2,8 @@ // Copyright © 2014-2022, Benoit BLANCHON // 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/third-party/ArduinoJson/extras/tests/MixedConfiguration/issue1707.cpp b/third-party/ArduinoJson/extras/tests/MixedConfiguration/issue1707.cpp index befdee5..fce024c 100644 --- a/third-party/ArduinoJson/extras/tests/MixedConfiguration/issue1707.cpp +++ b/third-party/ArduinoJson/extras/tests/MixedConfiguration/issue1707.cpp @@ -5,6 +5,8 @@ #define ARDUINO #define memcpy_P(dest, src, n) memcpy((dest), (src), (n)) +#include "progmem_emulation.hpp" + #include #include diff --git a/third-party/ArduinoJson/extras/tests/catch/catch.hpp b/third-party/ArduinoJson/extras/tests/catch/catch.hpp index fdb046f..fe13018 100644 --- a/third-party/ArduinoJson/extras/tests/catch/catch.hpp +++ b/third-party/ArduinoJson/extras/tests/catch/catch.hpp @@ -1,6 +1,6 @@ /* * Catch v1.12.2 - * Generated: 2018-05-14 15:10:01.112442 + * Generated: 2023-01-17 08:45:40.979381 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -214,7 +214,7 @@ //////////////////////////////////////////////////////////////////////////////// // Use variadic macros if the compiler supports them -#if ( defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \ +#if ( defined _MSC_VER && _MSC_VER >= 1400 && !defined __EDGE__) || \ ( defined __WAVE__ && __WAVE_HAS_VARIADICS ) || \ ( defined __GNUC__ && __GNUC__ >= 3 ) || \ ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L ) @@ -2129,6 +2129,9 @@ namespace Catch{ #define CATCH_TRAP() \ __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \ : : : "memory","r0","r3","r4" ) /* NOLINT */ + #elif defined(__aarch64__) + // Backport of https://github.com/catchorg/Catch2/commit/a25c1a24af8bffd35727a888a307ff0280cf9387 + #define CATCH_TRAP() __asm__(".inst 0xd4200000") #else #define CATCH_TRAP() __asm__("int $3\n" : : /* NOLINT */ ) #endif @@ -6392,18 +6395,21 @@ CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS // #included from: catch_fatal_condition.hpp #define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED +#include +#include + namespace Catch { - // Report the error condition - inline void reportFatal( std::string const& message ) { - IContext& context = Catch::getCurrentContext(); - IResultCapture* resultCapture = context.getResultCapture(); - resultCapture->handleFatalErrorCondition( message ); - } +//! Signals fatal error message to the run context +inline void reportFatal(std::string const &message) { + IContext &context = Catch::getCurrentContext(); + IResultCapture *resultCapture = context.getResultCapture(); + resultCapture->handleFatalErrorCondition(message); +} } // namespace Catch -#if defined ( CATCH_PLATFORM_WINDOWS ) ///////////////////////////////////////// +#if defined(CATCH_PLATFORM_WINDOWS) ///////////////////////////////////////// // #included from: catch_windows_h_proxy.h #define TWOBLUECUBES_CATCH_WINDOWS_H_PROXY_H_INCLUDED @@ -6429,176 +6435,307 @@ namespace Catch { #endif -# if !defined ( CATCH_CONFIG_WINDOWS_SEH ) +#if !defined(CATCH_CONFIG_WINDOWS_SEH) namespace Catch { - struct FatalConditionHandler { - void reset() {} - }; -} +class FatalConditionHandler { + bool m_started; + + // Install/disengage implementation for specific platform. + // Should be if-defed to work on current platform, can assume + // engage-disengage 1:1 pairing. + void engage_platform() {} + void disengage_platform() {} + +public: + // Should also have platform-specific implementations as needed + FatalConditionHandler() : m_started(false) {} + ~FatalConditionHandler() {} + + void engage() { + assert(!m_started && "Handler cannot be installed twice."); + m_started = true; + engage_platform(); + } + + void disengage() { + assert(m_started && + "Handler cannot be uninstalled without being installed first"); + m_started = false; + disengage_platform(); + } +}; +} // namespace Catch -# else // CATCH_CONFIG_WINDOWS_SEH is defined +#else // CATCH_CONFIG_WINDOWS_SEH is defined namespace Catch { - struct SignalDefs { DWORD id; const char* name; }; - extern SignalDefs signalDefs[]; - // There is no 1-1 mapping between signals and windows exceptions. - // Windows can easily distinguish between SO and SigSegV, - // but SigInt, SigTerm, etc are handled differently. - SignalDefs signalDefs[] = { - { EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL - Illegal instruction signal" }, - { EXCEPTION_STACK_OVERFLOW, "SIGSEGV - Stack overflow" }, - { EXCEPTION_ACCESS_VIOLATION, "SIGSEGV - Segmentation violation signal" }, - { EXCEPTION_INT_DIVIDE_BY_ZERO, "Divide by zero error" }, - }; +struct SignalDefs { + DWORD id; + const char *name; +}; +extern SignalDefs signalDefs[]; +// There is no 1-1 mapping between signals and windows exceptions. +// Windows can easily distinguish between SO and SigSegV, +// but SigInt, SigTerm, etc are handled differently. +SignalDefs signalDefs[] = { + {EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL - Illegal instruction signal"}, + {EXCEPTION_STACK_OVERFLOW, "SIGSEGV - Stack overflow"}, + {EXCEPTION_ACCESS_VIOLATION, "SIGSEGV - Segmentation violation signal"}, + {EXCEPTION_INT_DIVIDE_BY_ZERO, "Divide by zero error"}, +}; - struct FatalConditionHandler { +static LONG CALLBACK +handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { + for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { + if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) { + reportFatal(signalDefs[i].name); + } + } + // If its not an exception we care about, pass it along. + // This stops us from eating debugger breaks etc. + return EXCEPTION_CONTINUE_SEARCH; +} - static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { - for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { - if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) { - reportFatal(signalDefs[i].name); - } - } - // If its not an exception we care about, pass it along. - // This stops us from eating debugger breaks etc. - return EXCEPTION_CONTINUE_SEARCH; - } +// Since we do not support multiple instantiations, we put these +// into global variables and rely on cleaning them up in outlined +// constructors/destructors +static PVOID exceptionHandlerHandle = CATCH_NULL; - FatalConditionHandler() { - isSet = true; - // 32k seems enough for Catch to handle stack overflow, - // but the value was found experimentally, so there is no strong guarantee - guaranteeSize = 32 * 1024; - exceptionHandlerHandle = CATCH_NULL; - // Register as first handler in current chain - exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException); - // Pass in guarantee size to be filled - SetThreadStackGuarantee(&guaranteeSize); - } +class FatalConditionHandler { + bool m_started; - static void reset() { - if (isSet) { - // Unregister handler and restore the old guarantee - RemoveVectoredExceptionHandler(exceptionHandlerHandle); - SetThreadStackGuarantee(&guaranteeSize); - exceptionHandlerHandle = CATCH_NULL; - isSet = false; - } - } + // Install/disengage implementation for specific platform. + // Should be if-defed to work on current platform, can assume + // engage-disengage 1:1 pairing. - ~FatalConditionHandler() { - reset(); - } - private: - static bool isSet; - static ULONG guaranteeSize; - static PVOID exceptionHandlerHandle; - }; + void engage_platform() { + // Register as first handler in current chain + exceptionHandlerHandle = + AddVectoredExceptionHandler(1, handleVectoredException); + if (!exceptionHandlerHandle) { + throw std::runtime_error("Could not register vectored exception handler"); + } + } + + void disengage_platform() { + if (!RemoveVectoredExceptionHandler(exceptionHandlerHandle)) { + throw std::runtime_error( + "Could not unregister vectored exception handler"); + } + exceptionHandlerHandle = CATCH_NULL; + } - bool FatalConditionHandler::isSet = false; - ULONG FatalConditionHandler::guaranteeSize = 0; - PVOID FatalConditionHandler::exceptionHandlerHandle = CATCH_NULL; +public: + FatalConditionHandler() : m_started(false) { + ULONG guaranteeSize = static_cast(32 * 1024); + if (!SetThreadStackGuarantee(&guaranteeSize)) { + // We do not want to fully error out, because needing + // the stack reserve should be rare enough anyway. + Catch::cerr() << "Failed to reserve piece of stack." + << " Stack overflows will not be reported successfully."; + } + } + + // We do not attempt to unset the stack guarantee, because + // Windows does not support lowering the stack size guarantee. + ~FatalConditionHandler() {} + + void engage() { + assert(!m_started && "Handler cannot be installed twice."); + m_started = true; + engage_platform(); + } + + void disengage() { + assert(m_started && + "Handler cannot be uninstalled without being installed first"); + m_started = false; + disengage_platform(); + } +}; } // namespace Catch -# endif // CATCH_CONFIG_WINDOWS_SEH +#endif // CATCH_CONFIG_WINDOWS_SEH #else // Not Windows - assumed to be POSIX compatible ////////////////////////// -# if !defined(CATCH_CONFIG_POSIX_SIGNALS) +#if !defined(CATCH_CONFIG_POSIX_SIGNALS) namespace Catch { - struct FatalConditionHandler { - void reset() {} - }; -} +class FatalConditionHandler { + bool m_started; -# else // CATCH_CONFIG_POSIX_SIGNALS is defined + // Install/disengage implementation for specific platform. + // Should be if-defed to work on current platform, can assume + // engage-disengage 1:1 pairing. + void engage_platform() {} + void disengage_platform() {} + +public: + // Should also have platform-specific implementations as needed + FatalConditionHandler() : m_started(false) {} + ~FatalConditionHandler() {} + + void engage() { + assert(!m_started && "Handler cannot be installed twice."); + m_started = true; + engage_platform(); + } + + void disengage() { + assert(m_started && + "Handler cannot be uninstalled without being installed first"); + m_started = false; + disengage_platform(); + } +}; +} // namespace Catch + +#else // CATCH_CONFIG_POSIX_SIGNALS is defined #include namespace Catch { - struct SignalDefs { - int id; - const char* name; - }; - extern SignalDefs signalDefs[]; - SignalDefs signalDefs[] = { - { SIGINT, "SIGINT - Terminal interrupt signal" }, - { SIGILL, "SIGILL - Illegal instruction signal" }, - { SIGFPE, "SIGFPE - Floating point error signal" }, - { SIGSEGV, "SIGSEGV - Segmentation violation signal" }, - { SIGTERM, "SIGTERM - Termination request signal" }, - { SIGABRT, "SIGABRT - Abort (abnormal termination) signal" } - }; - - struct FatalConditionHandler { - - static bool isSet; - static struct sigaction oldSigActions [sizeof(signalDefs)/sizeof(SignalDefs)]; - static stack_t oldSigStack; - static char altStackMem[SIGSTKSZ]; - - static void handleSignal( int sig ) { - std::string name = ""; - for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { - SignalDefs &def = signalDefs[i]; - if (sig == def.id) { - name = def.name; - break; - } - } - reset(); - reportFatal(name); - raise( sig ); - } +struct SignalDefs { + int id; + const char *name; +}; +extern SignalDefs signalDefs[]; +SignalDefs signalDefs[] = { + {SIGINT, "SIGINT - Terminal interrupt signal"}, + {SIGILL, "SIGILL - Illegal instruction signal"}, + {SIGFPE, "SIGFPE - Floating point error signal"}, + {SIGSEGV, "SIGSEGV - Segmentation violation signal"}, + {SIGTERM, "SIGTERM - Termination request signal"}, + {SIGABRT, "SIGABRT - Abort (abnormal termination) signal"}}; + +// Older GCCs trigger -Wmissing-field-initializers for T foo = {} +// which is zero initialization, but not explicit. We want to avoid +// that. +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + +static char *altStackMem = CATCH_NULL; +static std::size_t altStackSize = 0; +static stack_t oldSigStack; +static struct sigaction oldSigActions[sizeof(signalDefs) / sizeof(SignalDefs)]; + +static void restorePreviousSignalHandlers() { + // We set signal handlers back to the previous ones. Hopefully + // nobody overwrote them in the meantime, and doesn't expect + // their signal handlers to live past ours given that they + // installed them after ours.. + for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { + sigaction(signalDefs[i].id, &oldSigActions[i], CATCH_NULL); + } + // Return the old stack + sigaltstack(&oldSigStack, CATCH_NULL); +} - FatalConditionHandler() { - isSet = true; - stack_t sigStack; - sigStack.ss_sp = altStackMem; - sigStack.ss_size = SIGSTKSZ; - sigStack.ss_flags = 0; - sigaltstack(&sigStack, &oldSigStack); - struct sigaction sa = { 0 }; +static void handleSignal(int sig) { + char const *name = ""; + for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { + SignalDefs &def = signalDefs[i]; + if (sig == def.id) { + name = def.name; + break; + } + } + // We need to restore previous signal handlers and let them do + // their thing, so that the users can have the debugger break + // when a signal is raised, and so on. + restorePreviousSignalHandlers(); + reportFatal(name); + raise(sig); +} - sa.sa_handler = handleSignal; - sa.sa_flags = SA_ONSTACK; - for (std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i) { - sigaction(signalDefs[i].id, &sa, &oldSigActions[i]); - } - } +class FatalConditionHandler { + bool m_started; - ~FatalConditionHandler() { - reset(); - } - static void reset() { - if( isSet ) { - // Set signals back to previous values -- hopefully nobody overwrote them in the meantime - for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) { - sigaction(signalDefs[i].id, &oldSigActions[i], CATCH_NULL); - } - // Return the old stack - sigaltstack(&oldSigStack, CATCH_NULL); - isSet = false; - } - } - }; + // Install/disengage implementation for specific platform. + // Should be if-defed to work on current platform, can assume + // engage-disengage 1:1 pairing. + + void engage_platform() { + stack_t sigStack; + sigStack.ss_sp = altStackMem; + sigStack.ss_size = SIGSTKSZ; + sigStack.ss_flags = 0; + sigaltstack(&sigStack, &oldSigStack); + struct sigaction sa = {0}; + + sa.sa_handler = handleSignal; + sa.sa_flags = SA_ONSTACK; + for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { + sigaction(signalDefs[i].id, &sa, &oldSigActions[i]); + } + } + + void disengage_platform() { restorePreviousSignalHandlers(); } - bool FatalConditionHandler::isSet = false; - struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {}; - stack_t FatalConditionHandler::oldSigStack = {}; - char FatalConditionHandler::altStackMem[SIGSTKSZ] = {}; +public: + FatalConditionHandler() : m_started(false) { + assert(!altStackMem && + "Cannot initialize POSIX signal handler when one already exists"); + if (altStackSize == 0) { + altStackSize = SIGSTKSZ; + } + altStackMem = new char[altStackSize](); + } + + ~FatalConditionHandler() { + delete[] altStackMem; + // We signal that another instance can be constructed by zeroing + // out the pointer. + altStackMem = CATCH_NULL; + } + + void engage() { + assert(!m_started && "Handler cannot be installed twice."); + m_started = true; + engage_platform(); + } + + void disengage() { + assert(m_started && + "Handler cannot be uninstalled without being installed first"); + m_started = false; + disengage_platform(); + } +}; + +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } // namespace Catch -# endif // CATCH_CONFIG_POSIX_SIGNALS +#endif // CATCH_CONFIG_POSIX_SIGNALS #endif // not Windows +namespace Catch { + +//! Simple RAII guard for (dis)engaging the FatalConditionHandler +class FatalConditionHandlerGuard { + FatalConditionHandler *m_handler; + +public: + FatalConditionHandlerGuard(FatalConditionHandler *handler) + : m_handler(handler) { + m_handler->engage(); + } + ~FatalConditionHandlerGuard() { m_handler->disengage(); } +}; + +} // end namespace Catch + #include #include #include @@ -6938,9 +7075,8 @@ namespace Catch { } void invokeActiveTestCase() { - FatalConditionHandler fatalConditionHandler; // Handle signals + FatalConditionHandlerGuard _(&m_fatalConditionhandler); m_activeTestCase->invoke(); - fatalConditionHandler.reset(); } private: @@ -6978,6 +7114,7 @@ namespace Catch { std::vector m_unfinishedSections; std::vector m_activeSections; TrackerContext m_trackerContext; + FatalConditionHandler m_fatalConditionhandler; size_t m_prevPassed; bool m_shouldReportUnexpected; }; diff --git a/third-party/ArduinoJson/idf_component.yml b/third-party/ArduinoJson/idf_component.yml new file mode 100644 index 0000000..b88706f --- /dev/null +++ b/third-party/ArduinoJson/idf_component.yml @@ -0,0 +1,12 @@ +version: "6.20.0" +description: >- + A simple and efficient JSON library for embedded C++. + ArduinoJson supports ✔ serialization, ✔ deserialization, ✔ MessagePack, ✔ fixed allocation, ✔ zero-copy, ✔ streams, ✔ filtering, and more. + It is the most popular Arduino library on GitHub ❤❤❤❤❤. + Check out arduinojson.org for a comprehensive documentation. +url: https://arduinojson.org/ +files: + exclude: + - "**/.vs/**/*" + - "examples/**/*" + - "extras/**/*" diff --git a/third-party/ArduinoJson/library.json b/third-party/ArduinoJson/library.json index 01596a9..a368d7b 100644 --- a/third-party/ArduinoJson/library.json +++ b/third-party/ArduinoJson/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/bblanchon/ArduinoJson.git" }, - "version": "6.20.0", + "version": "6.20.1", "authors": { "name": "Benoit Blanchon", "url": "https://blog.benoitblanchon.fr" diff --git a/third-party/ArduinoJson/library.properties b/third-party/ArduinoJson/library.properties index 72a5334..15d5000 100644 --- a/third-party/ArduinoJson/library.properties +++ b/third-party/ArduinoJson/library.properties @@ -1,5 +1,5 @@ name=ArduinoJson -version=6.20.0 +version=6.20.1 author=Benoit Blanchon maintainer=Benoit Blanchon sentence=A simple and efficient JSON library for embedded C++. diff --git a/third-party/ArduinoJson/logo.svg b/third-party/ArduinoJson/logo.svg deleted file mode 100644 index 5afb6ac..0000000 --- a/third-party/ArduinoJson/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp index 96b3a17..16c52ff 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp @@ -6,8 +6,8 @@ #include #include +#include #include -#include #if ARDUINOJSON_ENABLE_STD_STREAM # include @@ -74,16 +74,16 @@ class DeserializationError : public SafeBoolIdom { #if ARDUINOJSON_ENABLE_PROGMEM const __FlashStringHelper* f_str() const { - ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s0, "Ok"); - ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s1, "EmptyInput"); - ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s2, "IncompleteInput"); - ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s3, "InvalidInput"); - ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s4, "NoMemory"); - ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s5, "TooDeep"); - ARDUINOJSON_DEFINE_STATIC_ARRAY( + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s0, "Ok"); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s1, "EmptyInput"); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s2, "IncompleteInput"); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s3, "InvalidInput"); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s4, "NoMemory"); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s5, "TooDeep"); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY( const char*, messages, ARDUINOJSON_EXPAND6({s0, s1, s2, s3, s4, s5})); - return ARDUINOJSON_READ_STATIC_ARRAY(const __FlashStringHelper*, messages, - _code); + return reinterpret_cast( + pgm_read(messages + _code)); } #endif diff --git a/third-party/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp b/third-party/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp index 4d5782b..08aa3d6 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp @@ -10,8 +10,8 @@ #include #include #include +#include #include -#include #include namespace ARDUINOJSON_NAMESPACE { @@ -49,7 +49,7 @@ struct FloatTraits { } static T positiveBinaryPowerOfTen(int index) { - ARDUINOJSON_DEFINE_STATIC_ARRAY( // + ARDUINOJSON_DEFINE_PROGMEM_ARRAY( // uint32_t, factors, ARDUINOJSON_EXPAND18({ 0x40240000, 0x00000000, // 1e1 @@ -62,13 +62,12 @@ struct FloatTraits { 0x5A827748, 0xF9301D32, // 1e128 0x75154FDD, 0x7F73BF3C // 1e256 })); - return forge( - ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index), - ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index + 1)); + return forge(pgm_read(factors + 2 * index), + pgm_read(factors + 2 * index + 1)); } static T negativeBinaryPowerOfTen(int index) { - ARDUINOJSON_DEFINE_STATIC_ARRAY( // + ARDUINOJSON_DEFINE_PROGMEM_ARRAY( // uint32_t, factors, ARDUINOJSON_EXPAND18({ 0x3FB99999, 0x9999999A, // 1e-1 @@ -81,13 +80,12 @@ struct FloatTraits { 0x255BBA08, 0xCF8C979D, // 1e-128 0x0AC80628, 0x64AC6F43 // 1e-256 })); - return forge( - ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index), - ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index + 1)); + return forge(pgm_read(factors + 2 * index), + pgm_read(factors + 2 * index + 1)); } static T negativeBinaryPowerOfTenPlusOne(int index) { - ARDUINOJSON_DEFINE_STATIC_ARRAY( // + ARDUINOJSON_DEFINE_PROGMEM_ARRAY( // uint32_t, factors, ARDUINOJSON_EXPAND18({ 0x3FF00000, 0x00000000, // 1e0 @@ -100,9 +98,8 @@ struct FloatTraits { 0x25915445, 0x81B7DEC2, // 1e-127 0x0AFE07B2, 0x7DD78B14 // 1e-255 })); - return forge( - ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index), - ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index + 1)); + return forge(pgm_read(factors + 2 * index), + pgm_read(factors + 2 * index + 1)); } static T nan() { @@ -175,42 +172,42 @@ struct FloatTraits { } static T positiveBinaryPowerOfTen(int index) { - ARDUINOJSON_DEFINE_STATIC_ARRAY(uint32_t, factors, - ARDUINOJSON_EXPAND6({ - 0x41200000, // 1e1f - 0x42c80000, // 1e2f - 0x461c4000, // 1e4f - 0x4cbebc20, // 1e8f - 0x5a0e1bca, // 1e16f - 0x749dc5ae // 1e32f - })); - return forge(ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, index)); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(uint32_t, factors, + ARDUINOJSON_EXPAND6({ + 0x41200000, // 1e1f + 0x42c80000, // 1e2f + 0x461c4000, // 1e4f + 0x4cbebc20, // 1e8f + 0x5a0e1bca, // 1e16f + 0x749dc5ae // 1e32f + })); + return forge(pgm_read(factors + index)); } static T negativeBinaryPowerOfTen(int index) { - ARDUINOJSON_DEFINE_STATIC_ARRAY(uint32_t, factors, - ARDUINOJSON_EXPAND6({ - 0x3dcccccd, // 1e-1f - 0x3c23d70a, // 1e-2f - 0x38d1b717, // 1e-4f - 0x322bcc77, // 1e-8f - 0x24e69595, // 1e-16f - 0x0a4fb11f // 1e-32f - })); - return forge(ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, index)); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(uint32_t, factors, + ARDUINOJSON_EXPAND6({ + 0x3dcccccd, // 1e-1f + 0x3c23d70a, // 1e-2f + 0x38d1b717, // 1e-4f + 0x322bcc77, // 1e-8f + 0x24e69595, // 1e-16f + 0x0a4fb11f // 1e-32f + })); + return forge(pgm_read(factors + index)); } static T negativeBinaryPowerOfTenPlusOne(int index) { - ARDUINOJSON_DEFINE_STATIC_ARRAY(uint32_t, factors, - ARDUINOJSON_EXPAND6({ - 0x3f800000, // 1e0f - 0x3dcccccd, // 1e-1f - 0x3a83126f, // 1e-3f - 0x33d6bf95, // 1e-7f - 0x26901d7d, // 1e-15f - 0x0c01ceb3 // 1e-31f - })); - return forge(ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, index)); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(uint32_t, factors, + ARDUINOJSON_EXPAND6({ + 0x3f800000, // 1e0f + 0x3dcccccd, // 1e-1f + 0x3a83126f, // 1e-3f + 0x33d6bf95, // 1e-7f + 0x26901d7d, // 1e-15f + 0x0c01ceb3 // 1e-31f + })); + return forge(pgm_read(factors + index)); } static T forge(uint32_t bits) { diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp index d9e964b..106e014 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp @@ -5,20 +5,41 @@ #pragma once #include -#include -#include + +#if ARDUINOJSON_ENABLE_PROGMEM +# include +# include +#endif namespace ARDUINOJSON_NAMESPACE { +#if ARDUINOJSON_ENABLE_PROGMEM + +# ifndef ARDUINOJSON_DEFINE_PROGMEM_ARRAY +# define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value) \ + static type const name[] PROGMEM = value; +# endif + template -typename enable_if::value, T>::type pgm_read(const void* p) { - return reinterpret_cast(pgm_read_ptr(p)); +inline const T* pgm_read(const T* const* p) { + return reinterpret_cast(pgm_read_ptr(p)); } -template -typename enable_if::value, T>::type pgm_read( - const void* p) { +inline uint32_t pgm_read(const uint32_t* p) { return pgm_read_dword(p); } +#else + +# ifndef ARDUINOJSON_DEFINE_PROGMEM_ARRAY +# define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value) \ + static type const name[] = value; +# endif + +template +inline T pgm_read(const T* p) { + return *p; +} + +#endif } // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp deleted file mode 100644 index b2ebbf6..0000000 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// ArduinoJson - https://arduinojson.org -// Copyright © 2014-2022, Benoit BLANCHON -// MIT License - -#pragma once - -#include - -#if ARDUINOJSON_ENABLE_PROGMEM - -# include - -# ifndef ARDUINOJSON_DEFINE_PROGMEM_ARRAY -# define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value) \ - static type const name[] PROGMEM = value; -# endif - -# define ARDUINOJSON_DEFINE_STATIC_ARRAY ARDUINOJSON_DEFINE_PROGMEM_ARRAY - -# define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) \ - pgm_read(name + index) - -#else // i.e. ARDUINOJSON_ENABLE_PROGMEM == 0 - -# define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ - static type const name[] = value; - -# define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) name[index] - -#endif diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp index ddfcf0d..c2df2dc 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp @@ -46,11 +46,9 @@ class VariantRefBase : public VariantTag { // Casts the value to the specified type. // https://arduinojson.org/v6/api/jsonvariant/as/ template - FORCE_INLINE typename enable_if::value && - !is_same::value && - !ConverterNeedsWriteableRef::value, - T>::type - as() const { + FORCE_INLINE + typename enable_if::value, T>::type + as() const { return Converter::fromJson(getVariantConst()); } diff --git a/third-party/ArduinoJson/src/ArduinoJson/version.hpp b/third-party/ArduinoJson/src/ArduinoJson/version.hpp index 7f4aff8..30f688c 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/version.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/version.hpp @@ -4,7 +4,7 @@ #pragma once -#define ARDUINOJSON_VERSION "6.20.0" +#define ARDUINOJSON_VERSION "6.20.1" #define ARDUINOJSON_VERSION_MAJOR 6 #define ARDUINOJSON_VERSION_MINOR 20 -#define ARDUINOJSON_VERSION_REVISION 0 +#define ARDUINOJSON_VERSION_REVISION 1 diff --git a/third-party/Synth_Dexed/src/dexed.cpp b/third-party/Synth_Dexed/src/dexed.cpp index 81dfdda..6c34634 100644 --- a/third-party/Synth_Dexed/src/dexed.cpp +++ b/third-party/Synth_Dexed/src/dexed.cpp @@ -74,6 +74,8 @@ Dexed::Dexed(uint8_t maxnotes, int rate) xrun = 0; render_time_max = 0; + setVelocityScale(MIDI_VELOCITY_SCALING_OFF); + #ifndef TEENSYDUINO compressor = new Compressor(samplerate); #endif @@ -210,6 +212,8 @@ void Dexed::keydown(int16_t pitch, uint8_t velo) { return; } + velo=uint8_t((float(velo)/127.0)*velocity_diff+0.5)+velocity_offset; + pitch += data[144] - TRANSPOSE_FIX; int previousKeyDown = lastKeyDown; @@ -1665,6 +1669,39 @@ void Dexed::getName(char* buffer) buffer[10] = '\0'; } +void Dexed::setVelocityScale(uint8_t offset, uint8_t max) +{ + velocity_offset = offset & 0x7f; + velocity_max = max & 0x7f; + velocity_diff = velocity_max - velocity_offset; +} + +void Dexed::getVelocityScale(uint8_t* offset, uint8_t* max) +{ + *offset = velocity_offset; + *max = velocity_max; +} + +void Dexed::setVelocityScale(uint8_t setup = MIDI_VELOCITY_SCALING_OFF) +{ + switch(setup) + { + case MIDI_VELOCITY_SCALING_DX7: + velocity_offset=16; + velocity_max=109; + break; + case MIDI_VELOCITY_SCALING_DX7II: + velocity_offset=6; + velocity_max=119; + break; + default: // default setup + velocity_offset=0; + velocity_max=127; + break; + } + setVelocityScale(velocity_offset, velocity_max); +} + #ifndef TEENSYDUINO void Dexed::setCompressor(bool enable_compressor) { diff --git a/third-party/Synth_Dexed/src/dexed.h b/third-party/Synth_Dexed/src/dexed.h index 2b7afca..a248b93 100644 --- a/third-party/Synth_Dexed/src/dexed.h +++ b/third-party/Synth_Dexed/src/dexed.h @@ -175,6 +175,9 @@ class Dexed uint16_t getRenderTimeMax(void); void resetRenderTimeMax(void); void ControllersRefresh(void); + void setVelocityScale(uint8_t offset, uint8_t max); + void getVelocityScale(uint8_t* offset, uint8_t* max); + void setVelocityScale(uint8_t setup); #ifndef TEENSYDUINO void setCompressor(bool comp); bool getCompressor(void); @@ -354,9 +357,18 @@ class Dexed void getSamples(int16_t* buffer, uint16_t n_samples); void compress(float32_t* wav_in, float32_t* wav_out, uint16_t n, float32_t threshold, float32_t slope, uint16_t sr, float32_t tla, float32_t twnd, float32_t tatt, float32_t trel); bool use_compressor; + uint8_t velocity_offset; + uint8_t velocity_max; + float velocity_diff; #ifndef TEENSYDUINO Compressor* compressor; #endif + + enum { + MIDI_VELOCITY_SCALING_OFF, + MIDI_VELOCITY_SCALING_DX7, + MIDI_VELOCITY_SCALING_DX7II + }; }; #endif