Skip to content

fix for knob press #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: joystick
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src/Modulino.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,30 @@ 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;
int16_t _last_pox = buf[0] | (buf[1] << 8);
return _last_pox;
}
void set(int16_t value) {
if (_bug_on_set) {
Expand All @@ -351,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 };
};
Expand Down