Skip to content

Commit 9afdbe5

Browse files
committed
Apply astyle to example INO.
1 parent da94340 commit 9afdbe5

File tree

1 file changed

+30
-31
lines changed

1 file changed

+30
-31
lines changed

libraries/esp8266/examples/GPIO/FunctionalInterrupt/FunctionalInterrupt.ino

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,49 +12,48 @@
1212
#define BUTTON2 0
1313
#endif
1414

15-
class Button
16-
{
17-
public:
18-
Button(uint8_t reqPin) : PIN(reqPin) {
19-
pinMode(PIN, INPUT_PULLUP);
20-
attachInterrupt(PIN, std::bind(&Button::isr,this), FALLING);
21-
};
22-
~Button() {
23-
detachFunctionalInterrupt(PIN);
24-
}
15+
class Button {
16+
public:
17+
Button(uint8_t reqPin) : PIN(reqPin) {
18+
pinMode(PIN, INPUT_PULLUP);
19+
attachInterrupt(PIN, std::bind(&Button::isr, this), FALLING);
20+
};
21+
~Button() {
22+
detachFunctionalInterrupt(PIN);
23+
}
2524

2625
#if defined(ESP8266)
27-
void ICACHE_RAM_ATTR isr()
26+
void ICACHE_RAM_ATTR isr()
2827
#elif defined(ESP32)
29-
void IRAM_ATTR isr()
28+
void IRAM_ATTR isr()
3029
#endif
31-
{
32-
numberKeyPresses += 1;
33-
pressed = true;
34-
}
35-
36-
void checkPressed() {
37-
if (pressed) {
38-
Serial.printf("Button on pin %u has been pressed %u times\n", PIN, numberKeyPresses);
39-
pressed = false;
40-
}
41-
}
42-
43-
private:
44-
const uint8_t PIN;
45-
volatile uint32_t numberKeyPresses;
46-
volatile bool pressed;
30+
{
31+
numberKeyPresses += 1;
32+
pressed = true;
33+
}
34+
35+
void checkPressed() {
36+
if (pressed) {
37+
Serial.printf("Button on pin %u has been pressed %u times\n", PIN, numberKeyPresses);
38+
pressed = false;
39+
}
40+
}
41+
42+
private:
43+
const uint8_t PIN;
44+
volatile uint32_t numberKeyPresses;
45+
volatile bool pressed;
4746
};
4847

4948
Button button1(BUTTON1);
5049
Button button2(BUTTON2);
5150

5251

5352
void setup() {
54-
Serial.begin(115200);
53+
Serial.begin(115200);
5554
}
5655

5756
void loop() {
58-
button1.checkPressed();
59-
button2.checkPressed();
57+
button1.checkPressed();
58+
button2.checkPressed();
6059
}

0 commit comments

Comments
 (0)