Download NHK English news podcast automatically. This application requires mpod mother board. See also http://mbed.org/users/geodenx/notebook/mpod/

Dependencies:   BlinkLed HTTPClient EthernetInterface FatFileSystemCpp MSCFileSystem mbed-rtos mbed

Download NHK English news podcast automatically. This application requires mpod mother board. See also http://mbed.org/users/geodenx/notebook/mpod/

Committer:
togayan
Date:
Sat Aug 18 16:46:40 2012 +0000
Revision:
2:0da3a4508b46
Parent:
0:1855a008f28e
Child:
3:07562878d3c3
Fixed some bugs.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
togayan 2:0da3a4508b46 1 #include "BlinkLed.h"
togayan 2:0da3a4508b46 2
togayan 2:0da3a4508b46 3 BlinkLed::BlinkLed(PinName pin, uint32_t millisecWait, const char* name) :
togayan 2:0da3a4508b46 4 led(pin, name),
togayan 2:0da3a4508b46 5 millisecWait(millisecWait),
togayan 2:0da3a4508b46 6 thread(0)
togayan 2:0da3a4508b46 7 {
togayan 2:0da3a4508b46 8 }
togayan 2:0da3a4508b46 9
togayan 2:0da3a4508b46 10 BlinkLed::~BlinkLed()
togayan 2:0da3a4508b46 11 {
togayan 2:0da3a4508b46 12 }
togayan 2:0da3a4508b46 13
togayan 2:0da3a4508b46 14 void BlinkLed::startBlink()
togayan 2:0da3a4508b46 15 {
togayan 2:0da3a4508b46 16 if(thread == 0)
togayan 2:0da3a4508b46 17 {
togayan 2:0da3a4508b46 18 thread = new Thread(blink, this, osPriorityNormal, 128, NULL);
togayan 2:0da3a4508b46 19 }
togayan 2:0da3a4508b46 20 }
togayan 2:0da3a4508b46 21
togayan 2:0da3a4508b46 22 void BlinkLed::finishBlink()
togayan 2:0da3a4508b46 23 {
togayan 2:0da3a4508b46 24 if(thread != 0)
togayan 2:0da3a4508b46 25 {
togayan 2:0da3a4508b46 26 thread->terminate();
togayan 2:0da3a4508b46 27 delete thread;
togayan 2:0da3a4508b46 28 thread = 0;
togayan 2:0da3a4508b46 29 led = 0.0;
togayan 2:0da3a4508b46 30 }
togayan 2:0da3a4508b46 31 }
togayan 2:0da3a4508b46 32
togayan 2:0da3a4508b46 33 void BlinkLed::blink(void const *argument)
togayan 2:0da3a4508b46 34 {
togayan 2:0da3a4508b46 35 BlinkLed* blinkLed = (BlinkLed*)argument;
togayan 2:0da3a4508b46 36
togayan 2:0da3a4508b46 37 int up = 1;
togayan 2:0da3a4508b46 38 float brightness = 0.0;
togayan 2:0da3a4508b46 39 while (1) {
togayan 2:0da3a4508b46 40 if (up == 1 && brightness < 1.0) {
togayan 2:0da3a4508b46 41 ;
togayan 2:0da3a4508b46 42 } else if (up == 1 && brightness >= 1.0) {
togayan 2:0da3a4508b46 43 up = 0;
togayan 2:0da3a4508b46 44 } else if (up == 0 && brightness > 0) {
togayan 2:0da3a4508b46 45 ;
togayan 2:0da3a4508b46 46 } else if (up == 0 && brightness <= 0.0) {
togayan 2:0da3a4508b46 47 up = 1;
togayan 2:0da3a4508b46 48 } else {
togayan 2:0da3a4508b46 49 error("LED PWM error\n");
togayan 2:0da3a4508b46 50 }
togayan 2:0da3a4508b46 51
togayan 2:0da3a4508b46 52 if (up == 1) {
togayan 2:0da3a4508b46 53 brightness += 0.01;
togayan 2:0da3a4508b46 54 } else {
togayan 2:0da3a4508b46 55 brightness -= 0.01;
togayan 2:0da3a4508b46 56 }
togayan 2:0da3a4508b46 57 blinkLed->led = brightness;
togayan 2:0da3a4508b46 58
togayan 2:0da3a4508b46 59 Thread::wait(blinkLed->millisecWait);
togayan 2:0da3a4508b46 60 }
togayan 2:0da3a4508b46 61 }