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

Committer:
sarahmarshy
Date:
2016-09-19
Revision:
1:5b51a271d47e
Parent:
0:8fe86312b714

File content as of revision 1:5b51a271d47e:

#include "Blinky.h"

Blinky::Blinky(PinName led, int interval):
        _led(led), _interval(interval){
    stop_blink=false;
    _led=1;
}
void Blinky::start(){
    _blinker.start(this, &Blinky::blink_led);
} 
void Blinky::stop(){
    stop_blink = true;
    _blinker.join();
}  
void Blinky::blink_led(){
    while (!stop_blink){
        _led = !_led;
        Thread::wait(_interval);
    }
}