diff --git a/MicroDexed.ino b/MicroDexed.ino index cc668a7..4b32c12 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -552,6 +552,7 @@ void setup() Serial.println(instance_id, DEC); #endif create_audio_dexed_chain(instance_id); + MicroDexed[instance_id]->setCompressor(true); // just a test for enabling the compressor with default values } #ifdef DEBUG for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) diff --git a/Synth_Dexed b/Synth_Dexed new file mode 160000 index 0000000..aed9a09 --- /dev/null +++ b/Synth_Dexed @@ -0,0 +1 @@ +Subproject commit aed9a0994c62b5391fa5448ef8c21932caf9b817 diff --git a/config.h b/config.h index 7c1a375..fc3f836 100644 --- a/config.h +++ b/config.h @@ -90,7 +90,7 @@ //************************************************************************************************* //* DEBUG OUTPUT SETTINGS //************************************************************************************************* -//#define DEBUG 1 +#define DEBUG 1 //#define DEBUG_SHOW_JSON 1 #define SERIAL_SPEED 230400 #define SHOW_XRUN 1 @@ -809,7 +809,8 @@ #define VOLUME_MULTIPLIER 1.4 // Buffer-size define for load/save configuration as JSON -#define JSON_BUFFER_SIZE 8192 +//#define JSON_BUFFER_SIZE 8192 +#define JSON_BUFFER_SIZE 4096 // Internal configuration structure typedef struct dexed_s { diff --git a/dexed_sd.cpp b/dexed_sd.cpp index f3c674f..0cc1ce4 100644 --- a/dexed_sd.cpp +++ b/dexed_sd.cpp @@ -652,6 +652,7 @@ bool load_sd_drumsettings_json(uint8_t number) #endif } } + AudioInterrupts(); return (false); } diff --git a/third-party/ArduinoJson/CHANGELOG.md b/third-party/ArduinoJson/CHANGELOG.md index 6a2e8a8..78cd12a 100644 --- a/third-party/ArduinoJson/CHANGELOG.md +++ b/third-party/ArduinoJson/CHANGELOG.md @@ -1,6 +1,14 @@ ArduinoJson: change log ======================= +v6.19.4 (2022-04-05) +------- + +* Add `ElementProxy::memoryUsage()` +* Add `MemberProxy::memoryUsage()` (issue #1730) +* Add implicit conversion from `JsonDocument` to `JsonVariant` +* Fix comparisons operators with `const JsonDocument&` + v6.19.3 (2022-03-08) ------- diff --git a/third-party/ArduinoJson/CMakeLists.txt b/third-party/ArduinoJson/CMakeLists.txt index cdc848b..f809a58 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.19.3) +project(ArduinoJson VERSION 6.19.4) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) include(CTest) diff --git a/third-party/ArduinoJson/README.md b/third-party/ArduinoJson/README.md index a4c95cb..ddf3547 100644 --- a/third-party/ArduinoJson/README.md +++ b/third-party/ArduinoJson/README.md @@ -7,8 +7,8 @@ [![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) [![LGTM Grade](https://img.shields.io/lgtm/grade/cpp/github/bblanchon/ArduinoJson?label=quality&logo=lgtm)](https://lgtm.com/projects/g/bblanchon/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.19.3&logo=arduino&logoColor=white&color=blue)](https://www.ardu-badge.com/ArduinoJson/6.19.3) -[![PlatformIO Registry](https://badges.registry.platformio.org/packages/bblanchon/library/ArduinoJson.svg?version=6.19.3)](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.19.3) +[![Arduino Library Manager](https://img.shields.io/static/v1?label=Arduino&message=v6.19.4&logo=arduino&logoColor=white&color=blue)](https://www.ardu-badge.com/ArduinoJson/6.19.4) +[![PlatformIO Registry](https://badges.registry.platformio.org/packages/bblanchon/library/ArduinoJson.svg?version=6.19.4)](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.19.4) [![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) diff --git a/third-party/ArduinoJson/appveyor.yml b/third-party/ArduinoJson/appveyor.yml index c713ff4..6e3e458 100644 --- a/third-party/ArduinoJson/appveyor.yml +++ b/third-party/ArduinoJson/appveyor.yml @@ -1,4 +1,4 @@ -version: 6.19.3.{build} +version: 6.19.4.{build} environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/JsonDocument/CMakeLists.txt index e44689c..5356780 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/CMakeLists.txt @@ -5,6 +5,7 @@ add_executable(JsonDocumentTests add.cpp BasicJsonDocument.cpp + cast.cpp compare.cpp containsKey.cpp createNested.cpp diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/DynamicJsonDocument.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/DynamicJsonDocument.cpp index 8a5c7bb..ce050f1 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/DynamicJsonDocument.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/DynamicJsonDocument.cpp @@ -205,4 +205,26 @@ TEST_CASE("DynamicJsonDocument assignment") { REQUIRE_JSON(doc2, "42"); REQUIRE(doc2.capacity() == 4096); } + + SECTION("Assign from MemberProxy") { + StaticJsonDocument<200> doc1; + doc1["value"] = 42; + + DynamicJsonDocument doc2(4096); + doc2 = doc1["value"]; + + REQUIRE_JSON(doc2, "42"); + REQUIRE(doc2.capacity() == 4096); + } + + SECTION("Assign from ElementProxy") { + StaticJsonDocument<200> doc1; + doc1[0] = 42; + + DynamicJsonDocument doc2(4096); + doc2 = doc1[0]; + + REQUIRE_JSON(doc2, "42"); + REQUIRE(doc2.capacity() == 4096); + } } diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/ElementProxy.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/ElementProxy.cpp index 1912d5f..0fe3c47 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/ElementProxy.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/ElementProxy.cpp @@ -10,7 +10,7 @@ using namespace ARDUINOJSON_NAMESPACE; TEST_CASE("ElementProxy::add()") { DynamicJsonDocument doc(4096); doc.addElement(); - ElementProxy ep = doc[0]; + ElementProxy ep = doc[0]; SECTION("add(int)") { ep.add(42); @@ -36,7 +36,7 @@ TEST_CASE("ElementProxy::add()") { TEST_CASE("ElementProxy::clear()") { DynamicJsonDocument doc(4096); doc.addElement(); - ElementProxy ep = doc[0]; + ElementProxy ep = doc[0]; SECTION("size goes back to zero") { ep.add(42); @@ -96,7 +96,7 @@ TEST_CASE("ElementProxy::operator==()") { TEST_CASE("ElementProxy::remove()") { DynamicJsonDocument doc(4096); doc.addElement(); - ElementProxy ep = doc[0]; + ElementProxy ep = doc[0]; SECTION("remove(int)") { ep.add(1); @@ -143,7 +143,7 @@ TEST_CASE("ElementProxy::remove()") { TEST_CASE("ElementProxy::set()") { DynamicJsonDocument doc(4096); - ElementProxy ep = doc[0]; + ElementProxy ep = doc[0]; SECTION("set(int)") { ep.set(42); @@ -169,7 +169,7 @@ TEST_CASE("ElementProxy::set()") { TEST_CASE("ElementProxy::size()") { DynamicJsonDocument doc(4096); doc.addElement(); - ElementProxy ep = doc[0]; + ElementProxy ep = doc[0]; SECTION("returns 0") { REQUIRE(ep.size() == 0); @@ -188,9 +188,24 @@ TEST_CASE("ElementProxy::size()") { } } +TEST_CASE("ElementProxy::memoryUsage()") { + DynamicJsonDocument doc(4096); + doc.addElement(); + ElementProxy ep = doc[0]; + + SECTION("returns 0 for null") { + REQUIRE(ep.memoryUsage() == 0); + } + + SECTION("returns size for string") { + ep.set(std::string("hello")); + REQUIRE(ep.memoryUsage() == 6); + } +} + TEST_CASE("ElementProxy::operator[]") { DynamicJsonDocument doc(4096); - ElementProxy ep = doc[1]; + ElementProxy ep = doc[1]; SECTION("set member") { ep["world"] = 42; @@ -204,3 +219,29 @@ TEST_CASE("ElementProxy::operator[]") { REQUIRE(doc.as() == "[null,[null,null,42]]"); } } + +TEST_CASE("ElementProxy cast to JsonVariantConst") { + DynamicJsonDocument doc(4096); + doc[0] = "world"; + + const ElementProxy ep = doc[0]; + + JsonVariantConst var = ep; + + CHECK(var.as() == "world"); +} + +TEST_CASE("ElementProxy cast to JsonVariant") { + DynamicJsonDocument doc(4096); + doc[0] = "world"; + + ElementProxy ep = doc[0]; + + JsonVariant var = ep; + + CHECK(var.as() == "world"); + + var.set("toto"); + + CHECK(doc.as() == "[\"toto\"]"); +} diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/MemberProxy.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/MemberProxy.cpp index ea1dc44..64cd06a 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/MemberProxy.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/MemberProxy.cpp @@ -229,6 +229,20 @@ TEST_CASE("MemberProxy::size()") { } } +TEST_CASE("MemberProxy::memoryUsage()") { + DynamicJsonDocument doc(4096); + MemberProxy mp = doc["hello"]; + + SECTION("returns 0 when null") { + REQUIRE(mp.memoryUsage() == 0); + } + + SECTION("return the size for a string") { + mp.set(std::string("hello")); + REQUIRE(mp.memoryUsage() == 6); + } +} + TEST_CASE("MemberProxy::operator[]") { DynamicJsonDocument doc(4096); MemberProxy mp = doc["hello"]; @@ -245,3 +259,29 @@ TEST_CASE("MemberProxy::operator[]") { REQUIRE(doc.as() == "{\"hello\":[null,null,42]}"); } } + +TEST_CASE("MemberProxy cast to JsonVariantConst") { + DynamicJsonDocument doc(4096); + doc["hello"] = "world"; + + const MemberProxy mp = doc["hello"]; + + JsonVariantConst var = mp; + + CHECK(var.as() == "world"); +} + +TEST_CASE("MemberProxy cast to JsonVariant") { + DynamicJsonDocument doc(4096); + doc["hello"] = "world"; + + MemberProxy mp = doc["hello"]; + + JsonVariant var = mp; + + CHECK(var.as() == "world"); + + var.set("toto"); + + CHECK(doc.as() == "{\"hello\":\"toto\"}"); +} diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/cast.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/cast.cpp new file mode 100644 index 0000000..e538f4b --- /dev/null +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/cast.cpp @@ -0,0 +1,18 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2022, Benoit BLANCHON +// MIT License + +#include +#include + +#include + +TEST_CASE("Implicit cast to JsonVariant") { + StaticJsonDocument<128> doc; + + doc["hello"] = "world"; + + JsonVariant var = doc; + + CHECK(var.as() == "{\"hello\":\"world\"}"); +} diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/compare.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/compare.cpp index 24d27bc..7e9b950 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/compare.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/compare.cpp @@ -75,3 +75,29 @@ TEST_CASE("StaticJsonDocument::operator==(const DynamicJsonDocument&)") { REQUIRE(doc1 != doc2); } } + +TEST_CASE("JsonDocument::operator==(const JsonDocument&)") { + StaticJsonDocument<256> doc1; + StaticJsonDocument<256> doc2; + const JsonDocument& ref1 = doc1; + const JsonDocument& ref2 = doc2; + + SECTION("Empty") { + REQUIRE(ref1 == ref2); + REQUIRE_FALSE(ref1 != ref2); + } + + SECTION("With same object") { + doc1["hello"] = "world"; + doc2["hello"] = "world"; + REQUIRE(ref1 == ref2); + REQUIRE_FALSE(ref1 != ref2); + } + + SECTION("With different object") { + doc1["hello"] = "world"; + doc2["world"] = "hello"; + REQUIRE_FALSE(ref1 == ref2); + REQUIRE(ref1 != ref2); + } +} diff --git a/third-party/ArduinoJson/library.json b/third-party/ArduinoJson/library.json index e0e6d4f..24a9794 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.19.3", + "version": "6.19.4", "authors": { "name": "Benoit Blanchon", "url": "https://blog.benoitblanchon.fr" diff --git a/third-party/ArduinoJson/library.properties b/third-party/ArduinoJson/library.properties index 72695a1..aa20cfc 100644 --- a/third-party/ArduinoJson/library.properties +++ b/third-party/ArduinoJson/library.properties @@ -1,5 +1,5 @@ name=ArduinoJson -version=6.19.3 +version=6.19.4 author=Benoit Blanchon maintainer=Benoit Blanchon sentence=A simple and efficient JSON library for embedded C++. diff --git a/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp b/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp index d54de49..821cfba 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp @@ -118,6 +118,10 @@ class ElementProxy : public VariantOperators >, return getUpstreamElement().size(); } + FORCE_INLINE size_t memoryUsage() const { + return getUpstreamElement().memoryUsage(); + } + template VariantRef getMember(TNestedKey* key) const { return getUpstreamElement().getMember(key); diff --git a/third-party/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp b/third-party/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp index 90e22e7..274cce7 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp @@ -14,7 +14,8 @@ namespace ARDUINOJSON_NAMESPACE { -class JsonDocument : public Visitable { +class JsonDocument : public Visitable, + public VariantOperators { public: template typename TVisitor::result_type accept(TVisitor& visitor) const { @@ -295,16 +296,12 @@ class JsonDocument : public Visitable { _data.remove(adaptString(key)); } - FORCE_INLINE operator VariantConstRef() const { - return VariantConstRef(&_data); + FORCE_INLINE operator VariantRef() { + return getVariant(); } - bool operator==(VariantConstRef rhs) const { - return getVariant() == rhs; - } - - bool operator!=(VariantConstRef rhs) const { - return getVariant() != rhs; + FORCE_INLINE operator VariantConstRef() const { + return getVariant(); } protected: diff --git a/third-party/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp b/third-party/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp index e8fff4d..9a1bc83 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp @@ -94,6 +94,10 @@ class MemberProxy : public VariantOperators >, return getUpstreamMember().size(); } + FORCE_INLINE size_t memoryUsage() const { + return getUpstreamMember().memoryUsage(); + } + FORCE_INLINE void remove(size_t index) const { getUpstreamMember().remove(index); } diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp index a71f3e0..2f63615 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp @@ -131,9 +131,9 @@ struct RawComparer : ComparerBase { template struct Comparer::value>::type> : ComparerBase { - T rhs; + const T *rhs; // TODO: should be a VariantConstRef - explicit Comparer(T value) : rhs(value) {} + explicit Comparer(const T &value) : rhs(&value) {} CompareResult visitArray(const CollectionData &lhs) { ArrayComparer comparer(lhs); @@ -183,7 +183,7 @@ struct Comparer::value>::type> private: template CompareResult accept(TComparer &comparer) { - CompareResult reversedResult = rhs.accept(comparer); + CompareResult reversedResult = rhs->accept(comparer); switch (reversedResult) { case COMPARE_RESULT_GREATER: return COMPARE_RESULT_LESS; diff --git a/third-party/ArduinoJson/src/ArduinoJson/version.hpp b/third-party/ArduinoJson/src/ArduinoJson/version.hpp index d6a23d4..d2de577 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.19.3" +#define ARDUINOJSON_VERSION "6.19.4" #define ARDUINOJSON_VERSION_MAJOR 6 #define ARDUINOJSON_VERSION_MINOR 19 -#define ARDUINOJSON_VERSION_REVISION 3 +#define ARDUINOJSON_VERSION_REVISION 4 diff --git a/third-party/Bounce2/docs/files/_bounce2_8h_source.html b/third-party/Bounce2/docs/files/_bounce2_8h_source.html index b897765..c70e78d 100644 --- a/third-party/Bounce2/docs/files/_bounce2_8h_source.html +++ b/third-party/Bounce2/docs/files/_bounce2_8h_source.html @@ -119,148 +119,167 @@ $(function() {
63 {
64  // Note : this is private as it migh change in the futur
65 private:
-
66  static const uint8_t DEBOUNCED_STATE = 0b00000001;
-
67  static const uint8_t UNSTABLE_STATE = 0b00000010;
-
68  static const uint8_t CHANGED_STATE = 0b00000100;
+
66  static const uint8_t DEBOUNCED_STATE = 0b00000001; // Final returned calculated debounced state
+
67  static const uint8_t UNSTABLE_STATE = 0b00000010; // Actual last state value behind the scene
+
68  static const uint8_t CHANGED_STATE = 0b00000100; // The DEBOUNCED_STATE has changed since last update()
69 
-
70 private:
-
71  inline void changeState();
-
72  inline void setStateFlag(const uint8_t flag) {state |= flag;}
-
73  inline void unsetStateFlag(const uint8_t flag) {state &= ~flag;}
-
74  inline void toggleStateFlag(const uint8_t flag) {state ^= flag;}
-
75  inline bool getStateFlag(const uint8_t flag) {return((state & flag) != 0);}
-
76 
-
77 public:
-
83  Debouncer();
-
84 
-
92  void interval(uint16_t interval_millis);
-
93 
-
102  bool update();
-
103 
-
109  bool read();
-
110 
-
114  bool fell();
-
115 
-
119  bool rose();
-
120 
+
70 // Note : this is private as it migh change in the futur
+
71 private:
+
72  inline void changeState();
+
73  inline void setStateFlag(const uint8_t flag) {state |= flag;}
+
74  inline void unsetStateFlag(const uint8_t flag) {state &= ~flag;}
+
75  inline void toggleStateFlag(const uint8_t flag) {state ^= flag;}
+
76  inline bool getStateFlag(const uint8_t flag) const {return((state & flag) != 0);}
+
77 
+
78 public:
+
84  Debouncer();
+
85 
+
93  void interval(uint16_t interval_millis);
+
94 
+
103  bool update();
+
104 
+
110  bool read() const;
+
111 
+
115  bool fell() const;
+
116 
+
120  bool rose() const;
121 
122 
-
123 public:
-
129  bool changed( ) { return getStateFlag(CHANGED_STATE); }
-
130 
-
139  unsigned long duration();
-
140 
-
148  unsigned long previousDuration();
-
149 
-
150 protected:
-
151  void begin();
-
152  virtual bool readCurrentState() =0;
-
153  unsigned long previous_millis;
-
154  uint16_t interval_millis;
-
155  uint8_t state;
-
156  unsigned long stateChangeLastTime;
-
157  unsigned long durationOfPreviousState;
-
158 
-
159 };
-
160 
-
161 
-
166 class Bounce : public Debouncer
-
167 {
-
168 
-
169 
-
170 public:
-
171 
-
182  Bounce();
-
183 
-
184 
-
193  void attach(int pin, int mode);
-
194 
-
198  void attach(int pin);
-
199 
-
200  Bounce(uint8_t pin, unsigned long interval_millis ) : Bounce() {
-
201  attach(pin);
-
202  interval(interval_millis);
-
203  }
-
204 
-
206  // Deprecated //
-
208 
-
212  bool risingEdge() { return rose(); }
-
216  bool fallingEdge() { return fell(); }
-
222 protected:
+
123 
+
124 public:
+
130  bool changed( ) const { return getStateFlag(CHANGED_STATE); }
+
131 
+
132 
+
133 
+
134 
+
143  unsigned long currentDuration() const;
+
144 
+
145 
+
153  unsigned long previousDuration() const;
+
154 
+
163  [[deprecated]]
+
164  unsigned long duration() {
+
165  return currentDuration();
+
166  };
+
167 
+
168 protected:
+
169  void begin();
+
170  virtual bool readCurrentState() =0;
+
171  unsigned long previous_millis;
+
172  uint16_t interval_millis;
+
173  uint8_t state;
+
174  unsigned long stateChangeLastTime;
+
175  unsigned long durationOfPreviousState;
+
176 
+
177 };
+
178 
+
179 
+
184 class Bounce : public Debouncer
+
185 {
+
186 
+
187 
+
188 public:
+
189 
+
200  Bounce();
+
201 
+
202 
+
211  void attach(int pin, int mode);
+
212 
+
216  void attach(int pin);
+
217 
+
218  Bounce(uint8_t pin, unsigned long interval_millis ) : Bounce() {
+
219  attach(pin);
+
220  interval(interval_millis);
+
221  }
+
222 
223 
-
224 
-
225  uint8_t pin;
-
226 
-
227  virtual bool readCurrentState() { return digitalRead(pin); }
-
228  virtual void setPinMode(int pin, int mode) {
-
229 #if defined(ARDUINO_ARCH_STM32F1)
-
230  pinMode(pin, (WiringPinMode)mode);
-
231 #else
-
232  pinMode(pin, mode);
-
233 #endif
-
234  }
-
235 
-
236 
-
237 
-
238 };
-
239 
-
243 namespace Bounce2 {
-
244  // code declarations
-
245 
-
246 class Button : public Bounce{
-
247 protected:
-
248  bool stateForPressed = 1; //
-
249  public:
-
260  Button(){ }
-
261 
-
269  void setPressedState(bool state){
-
270  stateForPressed = state;
-
271  }
-
272 
-
276  inline bool getPressedState() {
-
277  return stateForPressed;
-
278  };
-
279 
-
283  inline bool isPressed() {
-
284  return read() == getPressedState();
-
285  };
-
286 
-
290  inline bool pressed() {
-
291  return changed() && isPressed();
-
292  };
-
293 
-
297  inline bool released() {
-
298  return changed() && !isPressed();
-
299  };
-
300 
-
301 };
-
302 };
-
303 
-
304 #endif
+
229  inline int getPin() const {
+
230  return this->pin;
+
231  };
+
232 
+
234  // Deprecated //
+
236 
+
240  [[deprecated]]
+
241  bool risingEdge() const { return rose(); }
+
245  [[deprecated]]
+
246  bool fallingEdge() const { return fell(); }
+
252 protected:
+
253 
+
254 
+
255  uint8_t pin;
+
256 
+
257  virtual bool readCurrentState() { return digitalRead(pin); }
+
258  virtual void setPinMode(int pin, int mode) {
+
259 #if defined(ARDUINO_ARCH_STM32F1)
+
260  pinMode(pin, (WiringPinMode)mode);
+
261 #else
+
262  pinMode(pin, mode);
+
263 #endif
+
264  }
+
265 
+
266 
+
267 
+
268 };
+
269 
+
273 namespace Bounce2 {
+
274  // code declarations
+
275 
+
276 class Button : public Bounce{
+
277 protected:
+
278  bool stateForPressed = 1; //
+
279  public:
+
290  Button(){ }
+
291 
+
299  void setPressedState(bool state){
+
300  stateForPressed = state;
+
301  }
+
302 
+
306  inline bool getPressedState() const {
+
307  return stateForPressed;
+
308  };
+
309 
+
313  inline bool isPressed() const {
+
314  return read() == getPressedState();
+
315  };
+
316 
+
320  inline bool pressed() const {
+
321  return changed() && isPressed();
+
322  };
+
323 
+
327  inline bool released() const {
+
328  return changed() && !isPressed();
+
329  };
+
330 
+
331 };
+
332 };
+
333 
+
334 #endif
-
Definition: Bounce2.h:246
-
bool getPressedState()
Get the electrical state (HIGH/LOW) that corresponds to a physical press.
Definition: Bounce2.h:276
-
bool fell()
Returns true if pin signal transitions from high to low.
Definition: Bounce2.cpp:128
+
Definition: Bounce2.h:276
void interval(uint16_t interval_millis)
Sets the debounce interval in milliseconds.
Definition: Bounce2.cpp:14
-
bool read()
Returns the pin's state (HIGH or LOW).
Definition: Bounce2.cpp:118
+
unsigned long previousDuration() const
Returns the duration in milliseconds of the previous state.
Definition: Bounce2.cpp:103
+
bool getPressedState() const
Get the electrical state (HIGH/LOW) that corresponds to a physical press.
Definition: Bounce2.h:306
Bounce()
Create an instance of the Bounce class.
Definition: Bounce2.cpp:138
-
bool changed()
Returns true if the state changed on last update.
Definition: Bounce2.h:129
-
unsigned long duration()
Returns the duration in milliseconds of the current state.
Definition: Bounce2.cpp:107
-
bool rose()
Returns true if pin signal transitions from low to high.
Definition: Bounce2.cpp:123
-
uint8_t pin
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:225
-
bool released()
Returns true if the button was physically released
Definition: Bounce2.h:297
-
bool isPressed()
Returns true if the button is currently physically pressed.
Definition: Bounce2.h:283
-
bool risingEdge()
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:212
+
unsigned long duration()
DEPRECATED (i.e. do not use). Renamed currentDuration().
Definition: Bounce2.h:164
+
bool fallingEdge() const
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:246
+
bool rose() const
Returns true if pin signal transitions from low to high.
Definition: Bounce2.cpp:123
+
uint8_t pin
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:255
+
bool pressed() const
Returns true if the button was physically pressed
Definition: Bounce2.h:320
+
unsigned long currentDuration() const
Returns the duration in milliseconds of the current state.
Definition: Bounce2.cpp:107
bool update()
Updates the pin's state.
Definition: Bounce2.cpp:32
-
Button()
Create an instance of the Button class. By default, the pressed state is matched to a HIGH electrical...
Definition: Bounce2.h:260
-
bool pressed()
Returns true if the button was physically pressed
Definition: Bounce2.h:290
-
unsigned long previousDuration()
Returns the duration in milliseconds of the previous state.
Definition: Bounce2.cpp:103
-
The Debouncer:Bounce class. Links the Deboucing class to a hardware pin.
Definition: Bounce2.h:166
+
Button()
Create an instance of the Button class. By default, the pressed state is matched to a HIGH electrical...
Definition: Bounce2.h:290
+
The Debouncer:Bounce class. Links the Deboucing class to a hardware pin. This class is odly named,...
Definition: Bounce2.h:184
+
int getPin() const
Return pin that this Bounce is attached to.
Definition: Bounce2.h:229
The Debouce class. Just the deboucing code separated from all harware.
Definition: Bounce2.h:62
-
void setPressedState(bool state)
Set the electrical state (HIGH/LOW) that corresponds to a physical press. By default,...
Definition: Bounce2.h:269
-
bool fallingEdge()
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:216
+
void setPressedState(bool state)
Set the electrical state (HIGH/LOW) that corresponds to a physical press. By default,...
Definition: Bounce2.h:299
+
bool fell() const
Returns true if pin signal transitions from high to low.
Definition: Bounce2.cpp:128
+
bool released() const
Returns true if the button was physically released
Definition: Bounce2.h:327
void attach(int pin, int mode)
Attach to a pin and sets that pin's mode (INPUT, INPUT_PULLUP or OUTPUT).
Definition: Bounce2.cpp:149
-
The Debouncer:Bounce:Button class. The Button class matches an electrical state to a physical action.
Definition: Bounce2.h:243
+
bool isPressed() const
Returns true if the button is currently physically pressed.
Definition: Bounce2.h:313
+
bool read() const
Returns the pin's state (HIGH or LOW).
Definition: Bounce2.cpp:118
+
bool risingEdge() const
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:241
+
bool changed() const
Returns true if the state changed on last update.
Definition: Bounce2.h:130
+
The Debouncer:Bounce:Button class. The Button class matches an electrical state to a physical action.
Definition: Bounce2.h:273
Debouncer()
Create an instance of the Debounce class.
Definition: Bounce2.cpp:10