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/

Revision:
0:1855a008f28e
Child:
2:0da3a4508b46
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BlinkLed.cpp	Thu Aug 16 15:49:19 2012 +0000
@@ -0,0 +1,60 @@
+#include "BlinkLed.h"
+    
+BlinkLed::BlinkLed(PinName pin, uint32_t millisecWait, const char* name) :
+led(pin, name),
+millisecWait(millisecWait),
+thread(0)
+{
+}
+
+BlinkLed::~BlinkLed()
+{
+}
+
+void BlinkLed::startBlink()
+{
+    if(thread == 0)
+    {
+        thread = new Thread(blink, this);
+    }
+}
+
+void BlinkLed::finishBlink()
+{
+    if(thread != 0)
+    {
+        thread->terminate();
+        thread = 0;
+        led = 0.0;
+    }
+}
+
+void BlinkLed::blink(void const *argument)
+{
+    BlinkLed* blinkLed = (BlinkLed*)argument;
+    
+    int up = 1;
+    float brightness = 0.0;
+    while (1) {
+        if (up == 1 && brightness < 1.0) {
+            ;
+        } else if (up == 1 && brightness >= 1.0) {
+            up = 0;
+        } else if (up == 0 && brightness > 0) {
+            ;
+        } else if (up == 0 && brightness <= 0.0) {
+            up = 1;
+        } else {
+            error("LED PWM error\n");
+        }
+
+        if (up == 1) {
+            brightness += 0.01;
+        } else {
+            brightness -= 0.01;
+        }
+        blinkLed->led = brightness;
+        
+        Thread::wait(blinkLed->millisecWait);
+    }
+}