@@ -7,10 +7,10 @@ struct Button {
7
7
uint8_t PIN;
8
8
volatile uint32_t numberKeyPresses;
9
9
volatile int pressed;
10
- void (*isr)(struct Button *);
11
10
};
12
11
13
- void isr (struct Button * button) {
12
+ void isr (void * param) {
13
+ struct Button *button = (struct Button *) param;
14
14
button->numberKeyPresses += 1 ;
15
15
button->pressed = 1 ;
16
16
}
@@ -22,15 +22,15 @@ void checkPressed(struct Button* button) {
22
22
}
23
23
}
24
24
25
- struct Button button1 = {BUTTON1, 0 , 0 , isr };
26
- struct Button button2 = {BUTTON2, 0 , 0 , isr };
25
+ struct Button button1 = {BUTTON1, 0 , 0 };
26
+ struct Button button2 = {BUTTON2, 0 , 0 };
27
27
28
28
void setup () {
29
29
Serial.begin (115200 );
30
30
pinMode (button1.PIN , INPUT_PULLUP);
31
31
pinMode (button2.PIN , INPUT_PULLUP);
32
- attachInterrupt (button1.PIN , ( void ()())isr , FALLING);
33
- attachInterrupt (button2.PIN , ( void ()())isr , FALLING);
32
+ attachInterruptArg (button1.PIN , isr, ( void *)&button1 , FALLING);
33
+ attachInterruptArg (button2.PIN , isr, ( void *)&button2 , FALLING);
34
34
}
35
35
36
36
void loop () {
0 commit comments