Skip to content

Commit a65f9a2

Browse files
committed
Apply suggested style fixes.
1 parent cf515f3 commit a65f9a2

File tree

2 files changed

+48
-44
lines changed

2 files changed

+48
-44
lines changed

libraries/FunctionalInterrupt/examples/Functional/Functional.ino

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,37 @@
1515
#endif
1616

1717
class Button {
18-
public:
19-
Button(uint8_t reqPin) : PIN(reqPin) {
20-
pinMode(PIN, INPUT_PULLUP);
21-
attachInterrupt(PIN, std::bind(buttonIsr_static, this), FALLING);
22-
};
23-
~Button() {
24-
detachInterrupt(PIN);
25-
}
18+
public:
19+
Button(uint8_t reqPin)
20+
: PIN(reqPin) {
21+
pinMode(PIN, INPUT_PULLUP);
22+
attachInterrupt(PIN, std::bind(buttonIsr_static, this), FALLING);
23+
};
24+
~Button() {
25+
detachInterrupt(PIN);
26+
}
2627

27-
void IRAM_ATTR buttonIsr() {
28-
numberKeyPresses += 1;
29-
pressed = true;
30-
}
28+
void IRAM_ATTR buttonIsr() {
29+
numberKeyPresses += 1;
30+
pressed = true;
31+
}
3132

32-
static void IRAM_ATTR buttonIsr_static(void* const self) {
33-
static_cast<Button*>(self)->buttonIsr();
34-
}
33+
static void IRAM_ATTR buttonIsr_static(void* const self) {
34+
static_cast<Button*>(self)->buttonIsr();
35+
}
3536

36-
uint32_t checkPressed() {
37-
if (pressed) {
38-
Serial.printf("Button on pin %u has been pressed %u times\n", PIN, numberKeyPresses);
39-
pressed = false;
40-
}
41-
return numberKeyPresses;
37+
uint32_t checkPressed() {
38+
if (pressed) {
39+
Serial.printf("Button on pin %u has been pressed %u times\n", PIN, numberKeyPresses);
40+
pressed = false;
4241
}
42+
return numberKeyPresses;
43+
}
4344

44-
private:
45-
const uint8_t PIN;
46-
volatile uint32_t numberKeyPresses = 0;
47-
volatile bool pressed = false;
45+
private:
46+
const uint8_t PIN;
47+
volatile uint32_t numberKeyPresses = 0;
48+
volatile bool pressed = false;
4849
};
4950

5051
Button* button1;

libraries/FunctionalInterrupt/examples/ScheduledFunctional/ScheduledFunctional.ino

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,35 @@
1212
#endif
1313

1414
class Button {
15-
public:
16-
Button(uint8_t reqPin) : PIN(reqPin) {
17-
pinMode(PIN, INPUT_PULLUP);
18-
attachScheduledInterrupt(PIN, [this](const InterruptInfo & ii) {
15+
public:
16+
Button(uint8_t reqPin)
17+
: PIN(reqPin) {
18+
pinMode(PIN, INPUT_PULLUP);
19+
attachScheduledInterrupt(
20+
PIN, [this](const InterruptInfo& ii) {
1921
Serial.print("Pin ");
2022
Serial.println(ii.pin);
2123
numberKeyPresses += 1;
2224
pressed = true;
23-
}, FALLING); // works on ESP8266
24-
};
25-
~Button() {
26-
detachInterrupt(PIN);
27-
}
25+
},
26+
FALLING); // works on ESP8266
27+
};
28+
~Button() {
29+
detachInterrupt(PIN);
30+
}
2831

29-
uint32_t checkPressed() {
30-
if (pressed) {
31-
Serial.printf("Button on pin %u has been pressed %u times\n", PIN, numberKeyPresses);
32-
pressed = false;
33-
}
34-
return numberKeyPresses;
32+
uint32_t checkPressed() {
33+
if (pressed) {
34+
Serial.printf("Button on pin %u has been pressed %u times\n", PIN, numberKeyPresses);
35+
pressed = false;
3536
}
37+
return numberKeyPresses;
38+
}
3639

37-
private:
38-
const uint8_t PIN;
39-
volatile uint32_t numberKeyPresses = 0;
40-
volatile bool pressed = false;
40+
private:
41+
const uint8_t PIN;
42+
volatile uint32_t numberKeyPresses = 0;
43+
volatile bool pressed = false;
4144
};
4245

4346
Button* button1;

0 commit comments

Comments
 (0)