diff options
author | Aditya Gaddam <adityagaddam@gmail.com> | 2012-09-03 18:05:57 -0400 |
---|---|---|
committer | Aditya Gaddam <adityagaddam@gmail.com> | 2012-09-03 18:05:57 -0400 |
commit | 3c0af902520b67ba2a8eb50f96a392d8070e3614 (patch) | |
tree | 4713126612d242aa6fdca0fa63674fc07671dd88 | |
parent | aec407773bbef80478941193f05fd67ce8ed49e0 (diff) | |
download | librambutan-3c0af902520b67ba2a8eb50f96a392d8070e3614.tar.gz librambutan-3c0af902520b67ba2a8eb50f96a392d8070e3614.zip |
"Changed tabs to spaces. Changed some braces placement to match existing examples
Signed-off-by: Aditya Gaddam <adityagaddam@gmail.com>"
-rw-r--r-- | examples/exti-interrupt-callback.cpp | 75 | ||||
-rw-r--r-- | examples/exti-interrupt.cpp | 17 |
2 files changed, 44 insertions, 48 deletions
diff --git a/examples/exti-interrupt-callback.cpp b/examples/exti-interrupt-callback.cpp index 9f018cf..1053ab2 100644 --- a/examples/exti-interrupt-callback.cpp +++ b/examples/exti-interrupt-callback.cpp @@ -12,55 +12,52 @@ #include <wirish/wirish.h> -class MyAwesomeClass -{ +class MyAwesomeClass { public: - // Setup the interrupt handler - void initialize() - { - // LED is off by default - this->isLEDOn = false; - - // Attach interrupt to class method handler - attachInterrupt(BOARD_BUTTON_PIN, buttonInterruptHandler, this, RISING); - } - + // Setup the interrupt handler + 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; + bool isLEDOn; - // 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). - // - // 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 - // 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); - } + // 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). + // + // 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 + // 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); + } }; MyAwesomeClass myClass; // Setup pin modes and the interrupt handler class void setup() { - pinMode(BOARD_BUTTON_PIN, INPUT); + pinMode(BOARD_BUTTON_PIN, INPUT); pinMode(BOARD_LED_PIN, OUTPUT); // The initialize method sets up the event handler to the private method diff --git a/examples/exti-interrupt.cpp b/examples/exti-interrupt.cpp index 06d6b6f..bc02f30 100644 --- a/examples/exti-interrupt.cpp +++ b/examples/exti-interrupt.cpp @@ -12,19 +12,18 @@ bool isLEDOn = false; // Interrupt handler takes in nothing and returns nothing. -void interruptHandler() -{ - // Set LED - isLEDOn = !isLEDOn; - digitalWrite(BOARD_LED_PIN, isLEDOn); - - // Delay slightly for switch debouncing. - delay(20); +void interruptHandler() { + // Set LED + isLEDOn = !isLEDOn; + digitalWrite(BOARD_LED_PIN, isLEDOn); + + // Delay slightly for switch debouncing. + delay(20); } // Setup pin modes and the interrupt handler void setup() { - pinMode(BOARD_BUTTON_PIN, INPUT); + pinMode(BOARD_BUTTON_PIN, INPUT); pinMode(BOARD_LED_PIN, OUTPUT); attachInterrupt(BOARD_BUTTON_PIN, interruptHandler, RISING); |