Skip to content

Commit c70097d

Browse files
committed
Minor fixes ♻️
1 parent 3d48585 commit c70097d

File tree

3 files changed

+18
-61
lines changed

3 files changed

+18
-61
lines changed

.gitignore

Lines changed: 0 additions & 28 deletions
This file was deleted.

examples/Modulino_Buttons/Buttons_Basic/Buttons_Basic.ino

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,31 @@ bool button_b = true;
1616
bool button_c = true;
1717

1818
void setup() {
19-
Serial.begin(9600);
20-
// Initialize Modulino I2C communication
21-
Modulino.begin();
22-
// Detect and connect to buttons module
23-
buttons.begin();
24-
// Turn on the LEDs above buttons A, B, and C
25-
buttons.setLeds(true, true, true);
19+
Serial.begin(9600);
20+
// Initialize Modulino I2C communication
21+
Modulino.begin();
22+
// Detect and connect to buttons module
23+
buttons.begin();
24+
// Turn on the LEDs above buttons A, B, and C
25+
buttons.setLeds(true, true, true);
2626
}
2727
void loop() {
28-
// Check for new button events, returns true when button state changes
29-
if (buttons.update()) {
28+
// Check for new button events, returns true when button state changes
29+
if (buttons.update()) {
3030
// Check which button was pressed (0=A, 1=B, 2=C)
3131
// Also toggle the corresponding LED, for each of the three buttons
3232
if (buttons.isPressed(0)) {
33-
Serial.println("Button A pressed!");
34-
button_a = !button_a;
33+
Serial.println("Button A pressed!");
34+
button_a = !button_a;
3535
} else if (buttons.isPressed(1)) {
36-
Serial.println("Button B pressed!");
37-
button_b = !button_b;
36+
Serial.println("Button B pressed!");
37+
button_b = !button_b;
3838
} else if (buttons.isPressed(2)) {
39-
Serial.println("Button C pressed!");
40-
button_c = !button_c;
39+
Serial.println("Button C pressed!");
40+
button_c = !button_c;
4141
}
42-
42+
4343
// Update the LEDs above buttons, depending on the variables value
4444
buttons.setLeds(button_a, button_b, button_c);
45-
}
45+
}
4646
}

src/Modulino.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -256,27 +256,12 @@ class ModulinoKnob : public Module {
256256
}
257257
return ret;
258258
}
259-
bool update() {
259+
int16_t get() {
260260
uint8_t buf[3];
261261
auto res = read(buf, 3);
262262
if (res == false) {
263263
return 0;
264264
}
265-
get(buf);
266-
return 1;
267-
}
268-
int16_t get(uint8_t * buf = nullptr) {
269-
if (buf == nullptr) {
270-
buf = (uint8_t*)malloc(3);
271-
if (buf == nullptr) {
272-
return 0;
273-
}
274-
auto res = read(buf, 3);
275-
if (res == false) {
276-
_pressed = false;
277-
return 0;
278-
}
279-
}
280265
_pressed = (buf[2] != 0);
281266
int16_t ret = buf[0] | (buf[1] << 8);
282267
return ret;

0 commit comments

Comments
 (0)