From 36bb2e9f3742e087c5469a128bafca127dc2d641 Mon Sep 17 00:00:00 2001 From: Rocketct Date: Mon, 28 Apr 2025 15:03:33 +0200 Subject: [PATCH 1/2] fix for knob press --- src/Modulino.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Modulino.h b/src/Modulino.h index 54c00a0..fb77790 100644 --- a/src/Modulino.h +++ b/src/Modulino.h @@ -320,12 +320,27 @@ class ModulinoKnob : public Module { } return ret; } - int16_t get() { + bool update() { uint8_t buf[3]; auto res = read(buf, 3); if (res == false) { return 0; } + get(buf); + return 1; + } + int16_t get(uint8_t * buf = nullptr) { + if (buf == nullptr) { + buf = (uint8_t*)malloc(3); + if (buf == nullptr) { + return 0; + } + auto res = read(buf, 3); + if (res == false) { + _pressed = false; + return 0; + } + } _pressed = (buf[2] != 0); int16_t ret = buf[0] | (buf[1] << 8); return ret; From 32c7893b4aef1f842a1ba24cc9fcbb385571d8c9 Mon Sep 17 00:00:00 2001 From: Rocketct Date: Mon, 12 May 2025 08:13:49 +0200 Subject: [PATCH 2/2] added retein of last knowb position value --- src/Modulino.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Modulino.h b/src/Modulino.h index fb77790..dd14f5c 100644 --- a/src/Modulino.h +++ b/src/Modulino.h @@ -342,8 +342,8 @@ class ModulinoKnob : public Module { } } _pressed = (buf[2] != 0); - int16_t ret = buf[0] | (buf[1] << 8); - return ret; + int16_t _last_pox = buf[0] | (buf[1] << 8); + return _last_pox; } void set(int16_t value) { if (_bug_on_set) { @@ -366,8 +366,10 @@ class ModulinoKnob : public Module { return 0xFF; } private: + int16_t _last_pox = 0; bool _pressed = false; bool _bug_on_set = false; + protected: uint8_t match[2] = { 0x74, 0x76 }; };