Simple Blinky library.
Fork of Blinky by
Blinky.h@0:8fe86312b714, 2016-09-19 (annotated)
- Committer:
- sarahmarshy
- Date:
- Mon Sep 19 16:21:27 2016 +0000
- Revision:
- 0:8fe86312b714
- Child:
- 2:256c8d48f5e7
First commit - Blinky library;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sarahmarshy | 0:8fe86312b714 | 1 | /* mbed blinky |
sarahmarshy | 0:8fe86312b714 | 2 | * |
sarahmarshy | 0:8fe86312b714 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
sarahmarshy | 0:8fe86312b714 | 4 | * of this software and associated documentation files (the "Software"), to deal |
sarahmarshy | 0:8fe86312b714 | 5 | * in the Software without restriction, including without limitation the rights |
sarahmarshy | 0:8fe86312b714 | 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
sarahmarshy | 0:8fe86312b714 | 7 | * copies of the Software, and to permit persons to whom the Software is |
sarahmarshy | 0:8fe86312b714 | 8 | * furnished to do so, subject to the following conditions: |
sarahmarshy | 0:8fe86312b714 | 9 | * |
sarahmarshy | 0:8fe86312b714 | 10 | * The above copyright notice and this permission notice shall be included in |
sarahmarshy | 0:8fe86312b714 | 11 | * all copies or substantial portions of the Software. |
sarahmarshy | 0:8fe86312b714 | 12 | * |
sarahmarshy | 0:8fe86312b714 | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
sarahmarshy | 0:8fe86312b714 | 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
sarahmarshy | 0:8fe86312b714 | 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
sarahmarshy | 0:8fe86312b714 | 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
sarahmarshy | 0:8fe86312b714 | 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
sarahmarshy | 0:8fe86312b714 | 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
sarahmarshy | 0:8fe86312b714 | 19 | * THE SOFTWARE. |
sarahmarshy | 0:8fe86312b714 | 20 | */ |
sarahmarshy | 0:8fe86312b714 | 21 | #ifndef MBED_BLINKY_H |
sarahmarshy | 0:8fe86312b714 | 22 | #define MBED_BLINKY_H |
sarahmarshy | 0:8fe86312b714 | 23 | #include "mbed.h" |
sarahmarshy | 0:8fe86312b714 | 24 | #include "rtos.h" |
sarahmarshy | 0:8fe86312b714 | 25 | |
sarahmarshy | 0:8fe86312b714 | 26 | /** Interface to start a thread that blinks an LED |
sarahmarshy | 0:8fe86312b714 | 27 | */ |
sarahmarshy | 0:8fe86312b714 | 28 | class Blinky { |
sarahmarshy | 0:8fe86312b714 | 29 | public: |
sarahmarshy | 0:8fe86312b714 | 30 | /** Create a Blinky |
sarahmarshy | 0:8fe86312b714 | 31 | * |
sarahmarshy | 0:8fe86312b714 | 32 | * @param led A PinName, the pin name of the LED to blink |
sarahmarshy | 0:8fe86312b714 | 33 | * @param interval A int, the interval of time between LED blinks |
sarahmarshy | 0:8fe86312b714 | 34 | */ |
sarahmarshy | 0:8fe86312b714 | 35 | Blinky(PinName led, int interval); |
sarahmarshy | 0:8fe86312b714 | 36 | /**Start a thread executing blink_led*/ |
sarahmarshy | 0:8fe86312b714 | 37 | void start(); |
sarahmarshy | 0:8fe86312b714 | 38 | /**Terminate the thread blinking the LED*/ |
sarahmarshy | 0:8fe86312b714 | 39 | void stop(); |
sarahmarshy | 0:8fe86312b714 | 40 | |
sarahmarshy | 0:8fe86312b714 | 41 | protected: |
sarahmarshy | 0:8fe86312b714 | 42 | /**Function to blink the LED*/ |
sarahmarshy | 0:8fe86312b714 | 43 | void blink_led(); |
sarahmarshy | 0:8fe86312b714 | 44 | /**Thread to execute blink_led*/ |
sarahmarshy | 0:8fe86312b714 | 45 | Thread _blinker; |
sarahmarshy | 0:8fe86312b714 | 46 | /**LED to blink */ |
sarahmarshy | 0:8fe86312b714 | 47 | DigitalOut _led; |
sarahmarshy | 0:8fe86312b714 | 48 | /**Interval of time between blinks*/ |
sarahmarshy | 0:8fe86312b714 | 49 | int _interval; |
sarahmarshy | 0:8fe86312b714 | 50 | /**Bool to stop blinking LED */ |
sarahmarshy | 0:8fe86312b714 | 51 | bool stop_blink; |
sarahmarshy | 0:8fe86312b714 | 52 | }; |
sarahmarshy | 0:8fe86312b714 | 53 | #endif |
sarahmarshy | 0:8fe86312b714 | 54 | |
sarahmarshy | 0:8fe86312b714 | 55 |