Skip to content

Commit 36bb2e9

Browse files
committed
fix for knob press
1 parent 53aa89e commit 36bb2e9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/Modulino.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,27 @@ class ModulinoKnob : public Module {
320320
}
321321
return ret;
322322
}
323-
int16_t get() {
323+
bool update() {
324324
uint8_t buf[3];
325325
auto res = read(buf, 3);
326326
if (res == false) {
327327
return 0;
328328
}
329+
get(buf);
330+
return 1;
331+
}
332+
int16_t get(uint8_t * buf = nullptr) {
333+
if (buf == nullptr) {
334+
buf = (uint8_t*)malloc(3);
335+
if (buf == nullptr) {
336+
return 0;
337+
}
338+
auto res = read(buf, 3);
339+
if (res == false) {
340+
_pressed = false;
341+
return 0;
342+
}
343+
}
329344
_pressed = (buf[2] != 0);
330345
int16_t ret = buf[0] | (buf[1] << 8);
331346
return ret;

0 commit comments

Comments
 (0)