Added new ArduinoJson library.

Added new Synth_Dexed library.
dev
Holger Wirtz 2 years ago
parent e64f16de5b
commit 71ee0ecbcc
  1. 7
      third-party/ArduinoJson/CHANGELOG.md
  2. 2
      third-party/ArduinoJson/CMakeLists.txt
  3. 20
      third-party/ArduinoJson/LICENSE.txt
  4. 14
      third-party/ArduinoJson/README.md
  5. 2
      third-party/ArduinoJson/appveyor.yml
  6. 2
      third-party/ArduinoJson/extras/scripts/build-arduino-package.sh
  7. 2
      third-party/ArduinoJson/extras/scripts/publish-particle-library.sh
  8. 3
      third-party/ArduinoJson/extras/scripts/publish.sh
  9. 74
      third-party/ArduinoJson/extras/tests/Cpp11/stl_containers.cpp
  10. 1
      third-party/ArduinoJson/extras/tests/Helpers/Arduino.h
  11. 2
      third-party/ArduinoJson/extras/tests/JsonArray/copyArray.cpp
  12. 6
      third-party/ArduinoJson/extras/tests/JsonDeserializer/object.cpp
  13. 1
      third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp
  14. 2
      third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_progmem_1.cpp
  15. 2
      third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_0.cpp
  16. 2
      third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_1.cpp
  17. 2
      third-party/ArduinoJson/extras/tests/MixedConfiguration/issue1707.cpp
  18. 427
      third-party/ArduinoJson/extras/tests/catch/catch.hpp
  19. 12
      third-party/ArduinoJson/idf_component.yml
  20. 2
      third-party/ArduinoJson/library.json
  21. 2
      third-party/ArduinoJson/library.properties
  22. 1
      third-party/ArduinoJson/logo.svg
  23. 20
      third-party/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp
  24. 83
      third-party/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp
  25. 35
      third-party/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp
  26. 30
      third-party/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp
  27. 8
      third-party/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp
  28. 4
      third-party/ArduinoJson/src/ArduinoJson/version.hpp
  29. 37
      third-party/Synth_Dexed/src/dexed.cpp
  30. 12
      third-party/Synth_Dexed/src/dexed.h

@ -1,6 +1,13 @@
ArduinoJson: change log ArduinoJson: change log
======================= =======================
v6.20.1 (2023-02-08)
-------
* Remove explicit exclusion of `as<char*>()` and `as<char>()` (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) v6.20.0 (2022-12-26)
------- -------

@ -10,7 +10,7 @@ if(ESP_PLATFORM)
return() return()
endif() endif()
project(ArduinoJson VERSION 6.20.0) project(ArduinoJson VERSION 6.20.1)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest) include(CTest)

@ -1,10 +1,10 @@
The MIT License (MIT) The MIT License (MIT)
--------------------- ---------------------
Copyright © 2014-2022, Benoit BLANCHON 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: 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 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 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.

@ -1,17 +1,18 @@
<p align="center"> <p align="center">
<a href="https://arduinojson.org/"><img alt="ArduinoJson" src="logo.svg" /></a> <a href="https://arduinojson.org/"><img alt="ArduinoJson" src="https://arduinojson.org/images/logo.svg" width="200" /></a>
</p> </p>
--- ---
[![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) [![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) [![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) [![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) [![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.0)](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.20.0) [![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)
[![GitHub stars](https://img.shields.io/github/stars/bblanchon/ArduinoJson?style=flat&logo=github)](https://github.com/bblanchon/ArduinoJson/stargazers) [![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 Sponsors](https://img.shields.io/github/sponsors/bblanchon?logo=github)](https://github.com/sponsors/bblanchon) [![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). 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) * 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) * [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) * [Responsive support](https://github.com/bblanchon/ArduinoJson/issues?q=is%3Aissue+is%3Aclosed)
* [Discord server](https://discord.gg/DzN6hHHD4h)
## Quickstart ## Quickstart

@ -1,4 +1,4 @@
version: 6.20.0.{build} version: 6.20.1.{build}
environment: environment:
matrix: matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022

@ -18,6 +18,6 @@ rm -f "$OUTPUT"
src \ src \
keywords.txt \ keywords.txt \
library.properties \ library.properties \
LICENSE.md \ LICENSE.txt \
README.md \ README.md \
ArduinoJson.h ArduinoJson.h

@ -9,7 +9,7 @@ trap 'rm -rf "$WORK_DIR"' EXIT
cp "$SOURCE_DIR/README.md" "$WORK_DIR/README.md" cp "$SOURCE_DIR/README.md" "$WORK_DIR/README.md"
cp "$SOURCE_DIR/CHANGELOG.md" "$WORK_DIR/CHANGELOG.md" cp "$SOURCE_DIR/CHANGELOG.md" "$WORK_DIR/CHANGELOG.md"
cp "$SOURCE_DIR/library.properties" "$WORK_DIR/library.properties" 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/src" "$WORK_DIR/"
cp -r "$SOURCE_DIR/examples" "$WORK_DIR/" cp -r "$SOURCE_DIR/examples" "$WORK_DIR/"

@ -38,6 +38,9 @@ update_version_in_source () {
sed -i~ -bE "s/version: .*$/version: $VERSION.{build}/" appveyor.yml sed -i~ -bE "s/version: .*$/version: $VERSION.{build}/" appveyor.yml
rm appveyor.yml~ rm appveyor.yml~
sed -i~ -bE "s/^version: .*$/version: \"$VERSION\"/" idf_component.yml
rm idf_component.yml~
sed -i~ -bE \ sed -i~ -bE \
-e "s/ARDUINOJSON_VERSION .*$/ARDUINOJSON_VERSION \"$VERSION\"/" \ -e "s/ARDUINOJSON_VERSION .*$/ARDUINOJSON_VERSION \"$VERSION\"/" \
-e "s/ARDUINOJSON_VERSION_MAJOR .*$/ARDUINOJSON_VERSION_MAJOR $MAJOR/" \ -e "s/ARDUINOJSON_VERSION_MAJOR .*$/ARDUINOJSON_VERSION_MAJOR $MAJOR/" \

@ -6,6 +6,7 @@
#include <stdint.h> #include <stdint.h>
#include <catch.hpp> #include <catch.hpp>
#include <array>
#include <string> #include <string>
#include <vector> #include <vector>
@ -28,12 +29,38 @@ struct Converter<std::vector<T> > {
static bool checkJson(JsonVariantConst src) { static bool checkJson(JsonVariantConst src) {
JsonArrayConst array = src; JsonArrayConst array = src;
bool result = array; bool result = array;
for (JsonVariantConst item : array)
result &= item.is<T>();
return result;
}
};
template <typename T, size_t N>
struct Converter<std::array<T, N> > {
static void toJson(const std::array<T, N>& src, JsonVariant dst) {
JsonArray array = dst.to<JsonArray>();
for (T item : src)
array.add(item);
}
static std::array<T, N> fromJson(JsonVariantConst src) {
std::array<T, N> dst;
dst.fill(0);
size_t idx = 0;
for (T item : src.as<JsonArrayConst>())
dst[idx++] = item;
return dst;
}
static bool checkJson(JsonVariantConst src) {
JsonArrayConst array = src;
bool result = array;
size_t size = 0;
for (JsonVariantConst item : array) { for (JsonVariantConst item : array) {
if (!result) result &= item.is<T>();
break; size++;
result = item.is<T>();
} }
return result; return result && size == N;
} }
}; };
} // namespace ARDUINOJSON_NAMESPACE } // namespace ARDUINOJSON_NAMESPACE
@ -70,3 +97,42 @@ TEST_CASE("vector<int>") {
CHECK(doc.is<std::vector<int> >() == false); CHECK(doc.is<std::vector<int> >() == false);
} }
} }
TEST_CASE("array<int, 2>") {
typedef std::array<int, 2> array_type;
SECTION("toJson") {
array_type v;
v[0] = 1;
v[1] = 2;
StaticJsonDocument<128> doc;
doc.set(v);
REQUIRE(doc.as<std::string>() == "[1,2]");
}
SECTION("fromJson") {
StaticJsonDocument<128> doc;
doc.add(1);
doc.add(2);
auto v = doc.as<array_type>();
REQUIRE(v.size() == 2);
CHECK(v[0] == 1);
CHECK(v[1] == 2);
}
SECTION("checkJson") {
StaticJsonDocument<128> doc;
CHECK(doc.is<array_type>() == false);
doc.add(1);
CHECK(doc.is<array_type>() == false);
doc.add(2);
CHECK(doc.is<array_type>() == true);
doc[0] = "foo";
CHECK(doc.is<array_type>() == false);
}
}

@ -7,6 +7,5 @@
#include "api/Print.h" #include "api/Print.h"
#include "api/Stream.h" #include "api/Stream.h"
#include "api/String.h" #include "api/String.h"
#include "progmem_emulation.hpp"
#define ARDUINO_H_INCLUDED 1 #define ARDUINO_H_INCLUDED 1

@ -165,7 +165,7 @@ TEST_CASE("copyArray()") {
char json[32] = ""; char json[32] = "";
int source[][3] = {{1, 2, 3}, {4, 5, 6}}; int source[][3] = {{1, 2, 3}, {4, 5, 6}};
CAPTURE(SIZE) CAPTURE(SIZE);
bool ok = copyArray(source, array); bool ok = copyArray(source, array);
CAPTURE(doc.memoryUsage()); CAPTURE(doc.memoryUsage());

@ -100,7 +100,7 @@ TEST_CASE("deserialize JSON object") {
REQUIRE(obj["key"] == "value"); REQUIRE(obj["key"] == "value");
} }
SECTION("Before the colon") { SECTION("Before the comma") {
DeserializationError err = DeserializationError err =
deserializeJson(doc, "{\"key1\":\"value1\" ,\"key2\":\"value2\"}"); deserializeJson(doc, "{\"key1\":\"value1\" ,\"key2\":\"value2\"}");
JsonObject obj = doc.as<JsonObject>(); JsonObject obj = doc.as<JsonObject>();
@ -112,9 +112,9 @@ TEST_CASE("deserialize JSON object") {
REQUIRE(obj["key2"] == "value2"); REQUIRE(obj["key2"] == "value2");
} }
SECTION("After the colon") { SECTION("After the comma") {
DeserializationError err = DeserializationError err =
deserializeJson(doc, "{\"key1\":\"value1\" ,\"key2\":\"value2\"}"); deserializeJson(doc, "{\"key1\":\"value1\", \"key2\":\"value2\"}");
JsonObject obj = doc.as<JsonObject>(); JsonObject obj = doc.as<JsonObject>();
REQUIRE(err == DeserializationError::Ok); REQUIRE(err == DeserializationError::Ok);

@ -6,6 +6,7 @@
#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1
#include "custom_string.hpp" #include "custom_string.hpp"
#include "progmem_emulation.hpp"
#include "weird_strcmp.hpp" #include "weird_strcmp.hpp"
#include <ArduinoJson/Strings/IsString.hpp> #include <ArduinoJson/Strings/IsString.hpp>

@ -2,6 +2,8 @@
// Copyright © 2014-2022, Benoit BLANCHON // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include "progmem_emulation.hpp"
#define ARDUINOJSON_ENABLE_PROGMEM 1 #define ARDUINOJSON_ENABLE_PROGMEM 1
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -2,6 +2,8 @@
// Copyright © 2014-2022, Benoit BLANCHON // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include "progmem_emulation.hpp"
#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1
#define ARDUINOJSON_ENABLE_PROGMEM 1 #define ARDUINOJSON_ENABLE_PROGMEM 1
#define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 0 #define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 0

@ -2,6 +2,8 @@
// Copyright © 2014-2022, Benoit BLANCHON // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include "progmem_emulation.hpp"
#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1
#define ARDUINOJSON_ENABLE_PROGMEM 1 #define ARDUINOJSON_ENABLE_PROGMEM 1
#define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 1 #define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 1

@ -5,6 +5,8 @@
#define ARDUINO #define ARDUINO
#define memcpy_P(dest, src, n) memcpy((dest), (src), (n)) #define memcpy_P(dest, src, n) memcpy((dest), (src), (n))
#include "progmem_emulation.hpp"
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <catch.hpp> #include <catch.hpp>

@ -1,6 +1,6 @@
/* /*
* Catch v1.12.2 * 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 * This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@ -214,7 +214,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Use variadic macros if the compiler supports them // 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 __WAVE__ && __WAVE_HAS_VARIADICS ) || \
( defined __GNUC__ && __GNUC__ >= 3 ) || \ ( defined __GNUC__ && __GNUC__ >= 3 ) || \
( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L ) ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L )
@ -2129,6 +2129,9 @@ namespace Catch{
#define CATCH_TRAP() \ #define CATCH_TRAP() \
__asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \ __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
: : : "memory","r0","r3","r4" ) /* NOLINT */ : : : "memory","r0","r3","r4" ) /* NOLINT */
#elif defined(__aarch64__)
// Backport of https://github.com/catchorg/Catch2/commit/a25c1a24af8bffd35727a888a307ff0280cf9387
#define CATCH_TRAP() __asm__(".inst 0xd4200000")
#else #else
#define CATCH_TRAP() __asm__("int $3\n" : : /* NOLINT */ ) #define CATCH_TRAP() __asm__("int $3\n" : : /* NOLINT */ )
#endif #endif
@ -6392,18 +6395,21 @@ CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
// #included from: catch_fatal_condition.hpp // #included from: catch_fatal_condition.hpp
#define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED #define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED
#include <cassert>
#include <stdexcept>
namespace Catch { namespace Catch {
// Report the error condition //! Signals fatal error message to the run context
inline void reportFatal( std::string const& message ) { inline void reportFatal(std::string const &message) {
IContext& context = Catch::getCurrentContext(); IContext &context = Catch::getCurrentContext();
IResultCapture* resultCapture = context.getResultCapture(); IResultCapture *resultCapture = context.getResultCapture();
resultCapture->handleFatalErrorCondition( message ); resultCapture->handleFatalErrorCondition(message);
} }
} // namespace Catch } // namespace Catch
#if defined ( CATCH_PLATFORM_WINDOWS ) ///////////////////////////////////////// #if defined(CATCH_PLATFORM_WINDOWS) /////////////////////////////////////////
// #included from: catch_windows_h_proxy.h // #included from: catch_windows_h_proxy.h
#define TWOBLUECUBES_CATCH_WINDOWS_H_PROXY_H_INCLUDED #define TWOBLUECUBES_CATCH_WINDOWS_H_PROXY_H_INCLUDED
@ -6429,176 +6435,307 @@ namespace Catch {
#endif #endif
# if !defined ( CATCH_CONFIG_WINDOWS_SEH ) #if !defined(CATCH_CONFIG_WINDOWS_SEH)
namespace Catch { namespace Catch {
struct FatalConditionHandler { class FatalConditionHandler {
void reset() {} 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 { namespace Catch {
struct SignalDefs { DWORD id; const char* name; }; struct SignalDefs {
extern SignalDefs signalDefs[]; DWORD id;
// There is no 1-1 mapping between signals and windows exceptions. const char *name;
// Windows can easily distinguish between SO and SigSegV, };
// but SigInt, SigTerm, etc are handled differently. extern SignalDefs signalDefs[];
SignalDefs signalDefs[] = { // There is no 1-1 mapping between signals and windows exceptions.
{ EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL - Illegal instruction signal" }, // Windows can easily distinguish between SO and SigSegV,
{ EXCEPTION_STACK_OVERFLOW, "SIGSEGV - Stack overflow" }, // but SigInt, SigTerm, etc are handled differently.
{ EXCEPTION_ACCESS_VIOLATION, "SIGSEGV - Segmentation violation signal" }, SignalDefs signalDefs[] = {
{ EXCEPTION_INT_DIVIDE_BY_ZERO, "Divide by zero error" }, {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) { // Since we do not support multiple instantiations, we put these
for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { // into global variables and rely on cleaning them up in outlined
if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) { // constructors/destructors
reportFatal(signalDefs[i].name); static PVOID exceptionHandlerHandle = CATCH_NULL;
}
}
// If its not an exception we care about, pass it along.
// This stops us from eating debugger breaks etc.
return EXCEPTION_CONTINUE_SEARCH;
}
FatalConditionHandler() { class FatalConditionHandler {
isSet = true; bool m_started;
// 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);
}
static void reset() { // Install/disengage implementation for specific platform.
if (isSet) { // Should be if-defed to work on current platform, can assume
// Unregister handler and restore the old guarantee // engage-disengage 1:1 pairing.
RemoveVectoredExceptionHandler(exceptionHandlerHandle);
SetThreadStackGuarantee(&guaranteeSize);
exceptionHandlerHandle = CATCH_NULL;
isSet = false;
}
}
~FatalConditionHandler() { void engage_platform() {
reset(); // Register as first handler in current chain
} exceptionHandlerHandle =
private: AddVectoredExceptionHandler(1, handleVectoredException);
static bool isSet; if (!exceptionHandlerHandle) {
static ULONG guaranteeSize; throw std::runtime_error("Could not register vectored exception handler");
static PVOID exceptionHandlerHandle; }
}; }
void disengage_platform() {
if (!RemoveVectoredExceptionHandler(exceptionHandlerHandle)) {
throw std::runtime_error(
"Could not unregister vectored exception handler");
}
exceptionHandlerHandle = CATCH_NULL;
}
bool FatalConditionHandler::isSet = false; public:
ULONG FatalConditionHandler::guaranteeSize = 0; FatalConditionHandler() : m_started(false) {
PVOID FatalConditionHandler::exceptionHandlerHandle = CATCH_NULL; ULONG guaranteeSize = static_cast<ULONG>(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 } // namespace Catch
# endif // CATCH_CONFIG_WINDOWS_SEH #endif // CATCH_CONFIG_WINDOWS_SEH
#else // Not Windows - assumed to be POSIX compatible ////////////////////////// #else // Not Windows - assumed to be POSIX compatible //////////////////////////
# if !defined(CATCH_CONFIG_POSIX_SIGNALS) #if !defined(CATCH_CONFIG_POSIX_SIGNALS)
namespace Catch { namespace Catch {
struct FatalConditionHandler { class FatalConditionHandler {
void reset() {} 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 <signal.h> #include <signal.h>
namespace Catch { namespace Catch {
struct SignalDefs { struct SignalDefs {
int id; int id;
const char* name; const char *name;
}; };
extern SignalDefs signalDefs[]; extern SignalDefs signalDefs[];
SignalDefs signalDefs[] = { SignalDefs signalDefs[] = {
{ SIGINT, "SIGINT - Terminal interrupt signal" }, {SIGINT, "SIGINT - Terminal interrupt signal"},
{ SIGILL, "SIGILL - Illegal instruction signal" }, {SIGILL, "SIGILL - Illegal instruction signal"},
{ SIGFPE, "SIGFPE - Floating point error signal" }, {SIGFPE, "SIGFPE - Floating point error signal"},
{ SIGSEGV, "SIGSEGV - Segmentation violation signal" }, {SIGSEGV, "SIGSEGV - Segmentation violation signal"},
{ SIGTERM, "SIGTERM - Termination request signal" }, {SIGTERM, "SIGTERM - Termination request signal"},
{ SIGABRT, "SIGABRT - Abort (abnormal termination) signal" } {SIGABRT, "SIGABRT - Abort (abnormal termination) signal"}};
};
// Older GCCs trigger -Wmissing-field-initializers for T foo = {}
struct FatalConditionHandler { // which is zero initialization, but not explicit. We want to avoid
// that.
static bool isSet; #if defined(__GNUC__)
static struct sigaction oldSigActions [sizeof(signalDefs)/sizeof(SignalDefs)]; #pragma GCC diagnostic push
static stack_t oldSigStack; #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
static char altStackMem[SIGSTKSZ]; #endif
static void handleSignal( int sig ) { static char *altStackMem = CATCH_NULL;
std::string name = "<unknown signal>"; static std::size_t altStackSize = 0;
for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { static stack_t oldSigStack;
SignalDefs &def = signalDefs[i]; static struct sigaction oldSigActions[sizeof(signalDefs) / sizeof(SignalDefs)];
if (sig == def.id) {
name = def.name; static void restorePreviousSignalHandlers() {
break; // 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
reset(); // installed them after ours..
reportFatal(name); for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) {
raise( sig ); sigaction(signalDefs[i].id, &oldSigActions[i], CATCH_NULL);
} }
// Return the old stack
sigaltstack(&oldSigStack, CATCH_NULL);
}
FatalConditionHandler() { static void handleSignal(int sig) {
isSet = true; char const *name = "<unknown signal>";
stack_t sigStack; for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) {
sigStack.ss_sp = altStackMem; SignalDefs &def = signalDefs[i];
sigStack.ss_size = SIGSTKSZ; if (sig == def.id) {
sigStack.ss_flags = 0; name = def.name;
sigaltstack(&sigStack, &oldSigStack); break;
struct sigaction sa = { 0 }; }
}
// 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; class FatalConditionHandler {
sa.sa_flags = SA_ONSTACK; bool m_started;
for (std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i) {
sigaction(signalDefs[i].id, &sa, &oldSigActions[i]);
}
}
~FatalConditionHandler() { // Install/disengage implementation for specific platform.
reset(); // Should be if-defed to work on current platform, can assume
} // engage-disengage 1:1 pairing.
static void reset() {
if( isSet ) { void engage_platform() {
// Set signals back to previous values -- hopefully nobody overwrote them in the meantime stack_t sigStack;
for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) { sigStack.ss_sp = altStackMem;
sigaction(signalDefs[i].id, &oldSigActions[i], CATCH_NULL); sigStack.ss_size = SIGSTKSZ;
} sigStack.ss_flags = 0;
// Return the old stack sigaltstack(&sigStack, &oldSigStack);
sigaltstack(&oldSigStack, CATCH_NULL); struct sigaction sa = {0};
isSet = false;
} 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; public:
struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {}; FatalConditionHandler() : m_started(false) {
stack_t FatalConditionHandler::oldSigStack = {}; assert(!altStackMem &&
char FatalConditionHandler::altStackMem[SIGSTKSZ] = {}; "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 } // namespace Catch
# endif // CATCH_CONFIG_POSIX_SIGNALS #endif // CATCH_CONFIG_POSIX_SIGNALS
#endif // not Windows #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 <cassert> #include <cassert>
#include <set> #include <set>
#include <string> #include <string>
@ -6938,9 +7075,8 @@ namespace Catch {
} }
void invokeActiveTestCase() { void invokeActiveTestCase() {
FatalConditionHandler fatalConditionHandler; // Handle signals FatalConditionHandlerGuard _(&m_fatalConditionhandler);
m_activeTestCase->invoke(); m_activeTestCase->invoke();
fatalConditionHandler.reset();
} }
private: private:
@ -6978,6 +7114,7 @@ namespace Catch {
std::vector<SectionEndInfo> m_unfinishedSections; std::vector<SectionEndInfo> m_unfinishedSections;
std::vector<ITracker*> m_activeSections; std::vector<ITracker*> m_activeSections;
TrackerContext m_trackerContext; TrackerContext m_trackerContext;
FatalConditionHandler m_fatalConditionhandler;
size_t m_prevPassed; size_t m_prevPassed;
bool m_shouldReportUnexpected; bool m_shouldReportUnexpected;
}; };

@ -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/**/*"

@ -7,7 +7,7 @@
"type": "git", "type": "git",
"url": "https://github.com/bblanchon/ArduinoJson.git" "url": "https://github.com/bblanchon/ArduinoJson.git"
}, },
"version": "6.20.0", "version": "6.20.1",
"authors": { "authors": {
"name": "Benoit Blanchon", "name": "Benoit Blanchon",
"url": "https://blog.benoitblanchon.fr" "url": "https://blog.benoitblanchon.fr"

@ -1,5 +1,5 @@
name=ArduinoJson name=ArduinoJson
version=6.20.0 version=6.20.1
author=Benoit Blanchon <blog.benoitblanchon.fr> author=Benoit Blanchon <blog.benoitblanchon.fr>
maintainer=Benoit Blanchon <blog.benoitblanchon.fr> maintainer=Benoit Blanchon <blog.benoitblanchon.fr>
sentence=A simple and efficient JSON library for embedded C++. sentence=A simple and efficient JSON library for embedded C++.

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 17 KiB

@ -6,8 +6,8 @@
#include <ArduinoJson/Misc/SafeBoolIdiom.hpp> #include <ArduinoJson/Misc/SafeBoolIdiom.hpp>
#include <ArduinoJson/Namespace.hpp> #include <ArduinoJson/Namespace.hpp>
#include <ArduinoJson/Polyfills/pgmspace_generic.hpp>
#include <ArduinoJson/Polyfills/preprocessor.hpp> #include <ArduinoJson/Polyfills/preprocessor.hpp>
#include <ArduinoJson/Polyfills/static_array.hpp>
#if ARDUINOJSON_ENABLE_STD_STREAM #if ARDUINOJSON_ENABLE_STD_STREAM
# include <ostream> # include <ostream>
@ -74,16 +74,16 @@ class DeserializationError : public SafeBoolIdom<DeserializationError> {
#if ARDUINOJSON_ENABLE_PROGMEM #if ARDUINOJSON_ENABLE_PROGMEM
const __FlashStringHelper* f_str() const { const __FlashStringHelper* f_str() const {
ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s0, "Ok"); ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s0, "Ok");
ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s1, "EmptyInput"); ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s1, "EmptyInput");
ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s2, "IncompleteInput"); ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s2, "IncompleteInput");
ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s3, "InvalidInput"); ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s3, "InvalidInput");
ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s4, "NoMemory"); ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s4, "NoMemory");
ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s5, "TooDeep"); ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s5, "TooDeep");
ARDUINOJSON_DEFINE_STATIC_ARRAY( ARDUINOJSON_DEFINE_PROGMEM_ARRAY(
const char*, messages, ARDUINOJSON_EXPAND6({s0, s1, s2, s3, s4, s5})); const char*, messages, ARDUINOJSON_EXPAND6({s0, s1, s2, s3, s4, s5}));
return ARDUINOJSON_READ_STATIC_ARRAY(const __FlashStringHelper*, messages, return reinterpret_cast<const __FlashStringHelper*>(
_code); pgm_read(messages + _code));
} }
#endif #endif

@ -10,8 +10,8 @@
#include <ArduinoJson/Configuration.hpp> #include <ArduinoJson/Configuration.hpp>
#include <ArduinoJson/Polyfills/alias_cast.hpp> #include <ArduinoJson/Polyfills/alias_cast.hpp>
#include <ArduinoJson/Polyfills/math.hpp> #include <ArduinoJson/Polyfills/math.hpp>
#include <ArduinoJson/Polyfills/pgmspace_generic.hpp>
#include <ArduinoJson/Polyfills/preprocessor.hpp> #include <ArduinoJson/Polyfills/preprocessor.hpp>
#include <ArduinoJson/Polyfills/static_array.hpp>
#include <ArduinoJson/Polyfills/type_traits.hpp> #include <ArduinoJson/Polyfills/type_traits.hpp>
namespace ARDUINOJSON_NAMESPACE { namespace ARDUINOJSON_NAMESPACE {
@ -49,7 +49,7 @@ struct FloatTraits<T, 8 /*64bits*/> {
} }
static T positiveBinaryPowerOfTen(int index) { static T positiveBinaryPowerOfTen(int index) {
ARDUINOJSON_DEFINE_STATIC_ARRAY( // ARDUINOJSON_DEFINE_PROGMEM_ARRAY( //
uint32_t, factors, uint32_t, factors,
ARDUINOJSON_EXPAND18({ ARDUINOJSON_EXPAND18({
0x40240000, 0x00000000, // 1e1 0x40240000, 0x00000000, // 1e1
@ -62,13 +62,12 @@ struct FloatTraits<T, 8 /*64bits*/> {
0x5A827748, 0xF9301D32, // 1e128 0x5A827748, 0xF9301D32, // 1e128
0x75154FDD, 0x7F73BF3C // 1e256 0x75154FDD, 0x7F73BF3C // 1e256
})); }));
return forge( return forge(pgm_read(factors + 2 * index),
ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index), pgm_read(factors + 2 * index + 1));
ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index + 1));
} }
static T negativeBinaryPowerOfTen(int index) { static T negativeBinaryPowerOfTen(int index) {
ARDUINOJSON_DEFINE_STATIC_ARRAY( // ARDUINOJSON_DEFINE_PROGMEM_ARRAY( //
uint32_t, factors, uint32_t, factors,
ARDUINOJSON_EXPAND18({ ARDUINOJSON_EXPAND18({
0x3FB99999, 0x9999999A, // 1e-1 0x3FB99999, 0x9999999A, // 1e-1
@ -81,13 +80,12 @@ struct FloatTraits<T, 8 /*64bits*/> {
0x255BBA08, 0xCF8C979D, // 1e-128 0x255BBA08, 0xCF8C979D, // 1e-128
0x0AC80628, 0x64AC6F43 // 1e-256 0x0AC80628, 0x64AC6F43 // 1e-256
})); }));
return forge( return forge(pgm_read(factors + 2 * index),
ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index), pgm_read(factors + 2 * index + 1));
ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index + 1));
} }
static T negativeBinaryPowerOfTenPlusOne(int index) { static T negativeBinaryPowerOfTenPlusOne(int index) {
ARDUINOJSON_DEFINE_STATIC_ARRAY( // ARDUINOJSON_DEFINE_PROGMEM_ARRAY( //
uint32_t, factors, uint32_t, factors,
ARDUINOJSON_EXPAND18({ ARDUINOJSON_EXPAND18({
0x3FF00000, 0x00000000, // 1e0 0x3FF00000, 0x00000000, // 1e0
@ -100,9 +98,8 @@ struct FloatTraits<T, 8 /*64bits*/> {
0x25915445, 0x81B7DEC2, // 1e-127 0x25915445, 0x81B7DEC2, // 1e-127
0x0AFE07B2, 0x7DD78B14 // 1e-255 0x0AFE07B2, 0x7DD78B14 // 1e-255
})); }));
return forge( return forge(pgm_read(factors + 2 * index),
ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index), pgm_read(factors + 2 * index + 1));
ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index + 1));
} }
static T nan() { static T nan() {
@ -175,42 +172,42 @@ struct FloatTraits<T, 4 /*32bits*/> {
} }
static T positiveBinaryPowerOfTen(int index) { static T positiveBinaryPowerOfTen(int index) {
ARDUINOJSON_DEFINE_STATIC_ARRAY(uint32_t, factors, ARDUINOJSON_DEFINE_PROGMEM_ARRAY(uint32_t, factors,
ARDUINOJSON_EXPAND6({ ARDUINOJSON_EXPAND6({
0x41200000, // 1e1f 0x41200000, // 1e1f
0x42c80000, // 1e2f 0x42c80000, // 1e2f
0x461c4000, // 1e4f 0x461c4000, // 1e4f
0x4cbebc20, // 1e8f 0x4cbebc20, // 1e8f
0x5a0e1bca, // 1e16f 0x5a0e1bca, // 1e16f
0x749dc5ae // 1e32f 0x749dc5ae // 1e32f
})); }));
return forge(ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, index)); return forge(pgm_read(factors + index));
} }
static T negativeBinaryPowerOfTen(int index) { static T negativeBinaryPowerOfTen(int index) {
ARDUINOJSON_DEFINE_STATIC_ARRAY(uint32_t, factors, ARDUINOJSON_DEFINE_PROGMEM_ARRAY(uint32_t, factors,
ARDUINOJSON_EXPAND6({ ARDUINOJSON_EXPAND6({
0x3dcccccd, // 1e-1f 0x3dcccccd, // 1e-1f
0x3c23d70a, // 1e-2f 0x3c23d70a, // 1e-2f
0x38d1b717, // 1e-4f 0x38d1b717, // 1e-4f
0x322bcc77, // 1e-8f 0x322bcc77, // 1e-8f
0x24e69595, // 1e-16f 0x24e69595, // 1e-16f
0x0a4fb11f // 1e-32f 0x0a4fb11f // 1e-32f
})); }));
return forge(ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, index)); return forge(pgm_read(factors + index));
} }
static T negativeBinaryPowerOfTenPlusOne(int index) { static T negativeBinaryPowerOfTenPlusOne(int index) {
ARDUINOJSON_DEFINE_STATIC_ARRAY(uint32_t, factors, ARDUINOJSON_DEFINE_PROGMEM_ARRAY(uint32_t, factors,
ARDUINOJSON_EXPAND6({ ARDUINOJSON_EXPAND6({
0x3f800000, // 1e0f 0x3f800000, // 1e0f
0x3dcccccd, // 1e-1f 0x3dcccccd, // 1e-1f
0x3a83126f, // 1e-3f 0x3a83126f, // 1e-3f
0x33d6bf95, // 1e-7f 0x33d6bf95, // 1e-7f
0x26901d7d, // 1e-15f 0x26901d7d, // 1e-15f
0x0c01ceb3 // 1e-31f 0x0c01ceb3 // 1e-31f
})); }));
return forge(ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, index)); return forge(pgm_read(factors + index));
} }
static T forge(uint32_t bits) { static T forge(uint32_t bits) {

@ -5,20 +5,41 @@
#pragma once #pragma once
#include <ArduinoJson/Namespace.hpp> #include <ArduinoJson/Namespace.hpp>
#include <ArduinoJson/Polyfills/pgmspace.hpp>
#include <ArduinoJson/Polyfills/type_traits.hpp> #if ARDUINOJSON_ENABLE_PROGMEM
# include <ArduinoJson/Polyfills/pgmspace.hpp>
# include <ArduinoJson/Polyfills/type_traits.hpp>
#endif
namespace ARDUINOJSON_NAMESPACE { 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 T> template <typename T>
typename enable_if<is_pointer<T>::value, T>::type pgm_read(const void* p) { inline const T* pgm_read(const T* const* p) {
return reinterpret_cast<T>(pgm_read_ptr(p)); return reinterpret_cast<const T*>(pgm_read_ptr(p));
} }
template <typename T> inline uint32_t pgm_read(const uint32_t* p) {
typename enable_if<is_same<T, uint32_t>::value, T>::type pgm_read(
const void* p) {
return pgm_read_dword(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 <typename T>
inline T pgm_read(const T* p) {
return *p;
}
#endif
} // namespace ARDUINOJSON_NAMESPACE } // namespace ARDUINOJSON_NAMESPACE

@ -1,30 +0,0 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// MIT License
#pragma once
#include <ArduinoJson/Configuration.hpp>
#if ARDUINOJSON_ENABLE_PROGMEM
# include <ArduinoJson/Polyfills/pgmspace_generic.hpp>
# 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<type>(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

@ -46,11 +46,9 @@ class VariantRefBase : public VariantTag {
// Casts the value to the specified type. // Casts the value to the specified type.
// https://arduinojson.org/v6/api/jsonvariant/as/ // https://arduinojson.org/v6/api/jsonvariant/as/
template <typename T> template <typename T>
FORCE_INLINE typename enable_if<!is_same<T, char*>::value && FORCE_INLINE
!is_same<T, char>::value && typename enable_if<!ConverterNeedsWriteableRef<T>::value, T>::type
!ConverterNeedsWriteableRef<T>::value, as() const {
T>::type
as() const {
return Converter<T>::fromJson(getVariantConst()); return Converter<T>::fromJson(getVariantConst());
} }

@ -4,7 +4,7 @@
#pragma once #pragma once
#define ARDUINOJSON_VERSION "6.20.0" #define ARDUINOJSON_VERSION "6.20.1"
#define ARDUINOJSON_VERSION_MAJOR 6 #define ARDUINOJSON_VERSION_MAJOR 6
#define ARDUINOJSON_VERSION_MINOR 20 #define ARDUINOJSON_VERSION_MINOR 20
#define ARDUINOJSON_VERSION_REVISION 0 #define ARDUINOJSON_VERSION_REVISION 1

@ -74,6 +74,8 @@ Dexed::Dexed(uint8_t maxnotes, int rate)
xrun = 0; xrun = 0;
render_time_max = 0; render_time_max = 0;
setVelocityScale(MIDI_VELOCITY_SCALING_OFF);
#ifndef TEENSYDUINO #ifndef TEENSYDUINO
compressor = new Compressor(samplerate); compressor = new Compressor(samplerate);
#endif #endif
@ -210,6 +212,8 @@ void Dexed::keydown(int16_t pitch, uint8_t velo) {
return; return;
} }
velo=uint8_t((float(velo)/127.0)*velocity_diff+0.5)+velocity_offset;
pitch += data[144] - TRANSPOSE_FIX; pitch += data[144] - TRANSPOSE_FIX;
int previousKeyDown = lastKeyDown; int previousKeyDown = lastKeyDown;
@ -1665,6 +1669,39 @@ void Dexed::getName(char* buffer)
buffer[10] = '\0'; 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 #ifndef TEENSYDUINO
void Dexed::setCompressor(bool enable_compressor) void Dexed::setCompressor(bool enable_compressor)
{ {

@ -175,6 +175,9 @@ class Dexed
uint16_t getRenderTimeMax(void); uint16_t getRenderTimeMax(void);
void resetRenderTimeMax(void); void resetRenderTimeMax(void);
void ControllersRefresh(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 #ifndef TEENSYDUINO
void setCompressor(bool comp); void setCompressor(bool comp);
bool getCompressor(void); bool getCompressor(void);
@ -354,9 +357,18 @@ class Dexed
void getSamples(int16_t* buffer, uint16_t n_samples); 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); 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; bool use_compressor;
uint8_t velocity_offset;
uint8_t velocity_max;
float velocity_diff;
#ifndef TEENSYDUINO #ifndef TEENSYDUINO
Compressor* compressor; Compressor* compressor;
#endif #endif
enum {
MIDI_VELOCITY_SCALING_OFF,
MIDI_VELOCITY_SCALING_DX7,
MIDI_VELOCITY_SCALING_DX7II
};
}; };
#endif #endif

Loading…
Cancel
Save