Permalink
Browse files

EXTI examples: whitespace fixups.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
  • Loading branch information...
1 parent d3581c1 commit d9f8b4f8c462b4fb2e1324567803cfcb839cfc2f Marti Bolivar committed Sep 3, 2012
Showing with 22 additions and 22 deletions.
  1. +16 −16 examples/exti-interrupt-callback.cpp
  2. +6 −6 examples/exti-interrupt.cpp
@@ -4,10 +4,10 @@
//
// This is similar to the exti-interrupt example, but shows the use of a class
// method to handle interrupts.
-//
-// More about attachInterrupt:
+//
+// More about attachInterrupt:
// http://leaflabs.com/docs/lang/api/attachinterrupt.html
-//
+//
#include <wirish/wirish.h>
@@ -18,36 +18,36 @@ class MyAwesomeClass {
void initialize() {
// LED is off by default
this->isLEDOn = false;
-
+
// Attach interrupt to class method handler
attachInterrupt(BOARD_BUTTON_PIN, buttonInterruptHandler, this, RISING);
}
-
+
private:
bool isLEDOn;
- // Static event handler takes a void * argument that was originally
- // passed to the attachInterrupt call. If the argument in question is an
+ // Static event handler takes a void * argument that was originally
+ // passed to the attachInterrupt call. If the argument in question is an
// instance of the class (MyAwesomeClass in this case), the static function
- // get access to that instance's data (even private data).
+ // get access to that instance's data (even private data).
//
- // In other words, this setup allows the Maple to have class method
+ // In other words, this setup allows the Maple to have class method
// interrupt handlers (albeit with a work around).
//
- // However, as you might imagine, this argument can be anything (if you
+ // However, as you might imagine, this argument can be anything (if you
// don't need instance data access).
//
static void buttonInterruptHandler(void *arg) {
// Cast the "generic" void argument to the class instance.
MyAwesomeClass *instance = (MyAwesomeClass *)arg;
-
+
// Accessing private instance data
instance->isLEDOn = !(instance->isLEDOn);
-
+
// Set LED
digitalWrite(BOARD_LED_PIN, instance->isLEDOn);
-
+
// Delay slightly for switch de-bouncing
delay(20);
}
@@ -59,16 +59,16 @@ MyAwesomeClass myClass;
void setup() {
pinMode(BOARD_BUTTON_PIN, INPUT);
pinMode(BOARD_LED_PIN, OUTPUT);
-
+
// The initialize method sets up the event handler to the private method
- // in MyAwesomeClass. There is however, nothing stopping you from setting
+ // in MyAwesomeClass. There is however, nothing stopping you from setting
// up event handlers which are public methods in classes.
myClass.initialize();
}
// Loop. Does nothing in this example.
void loop() {
-
+
}
// Force init to be called *first*, i.e. before static object allocation.
@@ -1,10 +1,10 @@
// Toggles the built-in LED when the built in button
// on the Maple is pushed in. This uses the attachInterrupt function to
// setup the interrupt handler for the button being pressed.
-//
-// More about attachInterrupt:
+//
+// More about attachInterrupt:
// http://leaflabs.com/docs/lang/api/attachinterrupt.html
-//
+//
#include <wirish/wirish.h>
@@ -16,7 +16,7 @@ void interruptHandler() {
// Set LED
isLEDOn = !isLEDOn;
digitalWrite(BOARD_LED_PIN, isLEDOn);
-
+
// Delay slightly for switch debouncing.
delay(20);
}
@@ -25,13 +25,13 @@ void interruptHandler() {
void setup() {
pinMode(BOARD_BUTTON_PIN, INPUT);
pinMode(BOARD_LED_PIN, OUTPUT);
-
+
attachInterrupt(BOARD_BUTTON_PIN, interruptHandler, RISING);
}
// Loop. Does nothing in this example.
void loop() {
-
+
}
// Force init to be called *first*, i.e. before static object allocation.

0 comments on commit d9f8b4f

Please sign in to comment.