Simple Blinky library.
Fork of Blinky by
Revision 2:256c8d48f5e7, committed 2016-11-08
- Comitter:
- mbed_demo
- Date:
- Tue Nov 08 22:10:56 2016 +0000
- Parent:
- 1:5b51a271d47e
- Commit message:
- Count times LED was turned on.
Changed in this revision
Blinky.cpp | Show annotated file Show diff for this revision Revisions of this file |
Blinky.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Blinky.cpp Mon Sep 19 19:52:49 2016 +0000 +++ b/Blinky.cpp Tue Nov 08 22:10:56 2016 +0000 @@ -4,7 +4,13 @@ _led(led), _interval(interval){ stop_blink=false; _led=1; + led_count = 0; + } +float Blinky::times_blinked(){ + return led_count; +} + void Blinky::start(){ _blinker.start(this, &Blinky::blink_led); } @@ -15,6 +21,7 @@ void Blinky::blink_led(){ while (!stop_blink){ _led = !_led; + led_count += 0.5; Thread::wait(_interval); } }
--- a/Blinky.h Mon Sep 19 19:52:49 2016 +0000 +++ b/Blinky.h Tue Nov 08 22:10:56 2016 +0000 @@ -37,6 +37,8 @@ void start(); /**Terminate the thread blinking the LED*/ void stop(); + /**Find the number of times the LED has been blinked */ + float times_blinked(); protected: /**Function to blink the LED*/ @@ -49,6 +51,8 @@ int _interval; /**Bool to stop blinking LED */ bool stop_blink; + /**Count of times LED blinked */ + float led_count; }; #endif