Given LED PinName and blink interval, spawns a thread that blinks that LED at the specified interval
Dependents: Blinky_Tests Blinky_Tests_GreenTea1
Blinky.cpp
00001 #include "Blinky.h" 00002 00003 Blinky::Blinky(PinName led, int interval): 00004 _led(led), _interval(interval){ 00005 stop_blink=false; 00006 _led=1; 00007 } 00008 void Blinky::start(){ 00009 _blinker.start(this, &Blinky::blink_led); 00010 } 00011 void Blinky::stop(){ 00012 stop_blink = true; 00013 _blinker.join(); 00014 } 00015 void Blinky::blink_led(){ 00016 while (!stop_blink){ 00017 _led = !_led; 00018 Thread::wait(_interval); 00019 } 00020 }
Generated on Tue Jul 12 2022 19:56:34 by 1.7.2