Eduardo Avelar / LibThreadProcess

Dependents:   LedsThreading

Fork of BlinkLed by Satoshi Togawa

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BlinkLed.cpp Source File

BlinkLed.cpp

00001 #include "BlinkLed.h"
00002 
00003 BlinkLed::BlinkLed(PinName pin, int n) :
00004     led(pin),
00005     n(n)
00006 {
00007 }
00008 
00009 BlinkLed::~BlinkLed()
00010 {
00011 }
00012 
00013 void BlinkLed::startBlink()
00014 {
00015     thread = new Thread(blink, this);
00016 }
00017 
00018 void BlinkLed::blink(void const *argument)
00019 {
00020     BlinkLed* self = (BlinkLed*)argument;
00021 
00022     while(1)
00023     {
00024         self->led = !self->led;
00025         Thread::wait(self->n);
00026     }
00027 }