Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BlinkLed HTTPClient EthernetInterface FatFileSystemCpp MSCFileSystem mbed-rtos mbed
Revision 6:83383116c88a, committed 2012-09-01
- Comitter:
- togayan
- Date:
- Sat Sep 01 04:28:20 2012 +0000
- Parent:
- 5:66c3398a14c9
- Commit message:
- HTTPFile was changed to follow the latest HTTPClient library.; BlinkLed was isolated as a library.; Change LED port from LED1,2 to LED3,4 for the specification of pwmout.
Changed in this revision
--- a/BlinkLed.cpp Tue Aug 28 14:41:17 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-#include "BlinkLed.h"
-
-BlinkLed::BlinkLed(PinName pin, float dutyChangeStep, const char* name) :
-led(pin, name),
-dutyChangeStep(dutyChangeStep),
-continueBlink(false),
-thread(0)
-{
-}
-
-BlinkLed::~BlinkLed()
-{
-}
-
-void BlinkLed::startBlink()
-{
- if(continueBlink == false)
- {
- continueBlink = true;
- thread = new Thread(blink, this, osPriorityNormal, 128, NULL);
- }
-}
-
-void BlinkLed::finishBlink()
-{
- if(continueBlink == true)
- {
- continueBlink = false;
- led = 0.0;
- thread->terminate();
- delete thread;
- }
-}
-
-void BlinkLed::blink(void const *argument)
-{
- BlinkLed* blinkLed = (BlinkLed*)argument;
-
- bool up = false;
- float brightness = 0.0;
- while (blinkLed->continueBlink == true)
- {
- if(brightness <= 0.0)
- {
- up = true;
- }
- else if(1.0 <= brightness)
- {
- up = false;
- }
-
- float dutyChangeStep = blinkLed->dutyChangeStep;
- brightness += ((up)?(dutyChangeStep):(-dutyChangeStep));
- blinkLed->led = brightness;
-
- Thread::wait(20);
- }
-}
--- a/BlinkLed.h Tue Aug 28 14:41:17 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/* BlinkLed.h */
-#ifndef BLINKLED_H_
-#define BLINKLED_H_
-
-#include "mbed.h"
-#include "rtos.h"
-
-/** LED which blinks automatically with RTOS
-*/
-class BlinkLed
-{
-public:
- /** Constructor
- */
- BlinkLed(PinName pin, float dutyChangeStep, const char* name = NULL);
-
- /** Destructor
- */
- ~BlinkLed();
-
- /** Start biinking
- */
- void startBlink();
-
- /** Finish biinking
- */
- void finishBlink();
-
-private:
- /** Copy constructor
- * Disable because it is only declaration
- */
- BlinkLed(const BlinkLed&);
-
- /** Copy assignment operators
- * Disable because it is only declaration
- */
- BlinkLed& operator=(const BlinkLed&);
-
- /** Function for blinking
- * This function will be bind to new thread
- */
- static void blink(void const *argument);
-
- /** Target Led
- */
- PwmOut led;
-
- /** Duty ratio step of changing every 20ms
- */
- float dutyChangeStep;
-
- /** Flag of Continue Blink
- */
- bool continueBlink;
-
- /** Pointer to thread for blinking
- */
- Thread* thread;
-};
-
-#endif /* BLINKLED_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BlinkLed.lib Sat Sep 01 04:28:20 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/togayan/code/BlinkLed/#a55a3351317d
--- a/HTTPClient.lib Tue Aug 28 14:41:17 2012 +0000 +++ b/HTTPClient.lib Sat Sep 01 04:28:20 2012 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/togayan/code/HTTPClient/#324727b24465 +http://mbed.org/users/togayan/code/HTTPClient/#68da5c7fed90
--- a/HTTPFile.cpp Tue Aug 28 14:41:17 2012 +0000
+++ b/HTTPFile.cpp Sat Sep 01 04:28:20 2012 +0000
@@ -29,6 +29,12 @@
//Force reopening
}
+/*virtual*/ void HTTPFile::readReset()
+{
+ if(m_fp)
+ fseek(m_fp, 0, SEEK_SET);
+}
+
/*virtual*/ int HTTPFile::read(char* buf, size_t len, size_t* pReadLen)
{
if(!openFile("r")) //File does not exist, or I/O error...
@@ -43,6 +49,12 @@
return OK;
}
+/*virtual*/ void HTTPFile::writeReset()
+{
+ if(m_fp)
+ fseek(m_fp, 0, SEEK_SET);
+}
+
/*virtual*/ int HTTPFile::write(const char* buf, size_t len)
{
if(!openFile("w")) //File does not exist, or I/O error...
--- a/HTTPFile.h Tue Aug 28 14:41:17 2012 +0000
+++ b/HTTPFile.h Sat Sep 01 04:28:20 2012 +0000
@@ -25,6 +25,11 @@
void clear();
protected:
+ /** Reset stream to its beginning
+ * Called by the HTTPClient on each new request
+ */
+ virtual void readReset();
+
/** Read a piece of data to be transmitted
* @param buf Pointer to the buffer on which to copy the data
* @param len Length of the buffer
@@ -32,6 +37,11 @@
*/
virtual int read(char* buf, size_t len, size_t* pReadLen);
+ /** Reset stream to its beginning
+ * Called by the HTTPClient on each new request
+ */
+ virtual void writeReset();
+
/** Write a piece of data transmitted by the server
* @param buf Pointer to the buffer from which to copy the data
* @param len Length of the buffer
--- a/main.cpp Tue Aug 28 14:41:17 2012 +0000
+++ b/main.cpp Sat Sep 01 04:28:20 2012 +0000
@@ -14,8 +14,8 @@
EthernetInterface eth;
HTTPClient http;
MSCFileSystem usb("usb");
-BlinkLed led1(LED1, 0.02);
-BlinkLed led2(LED2, 0.2);
+BlinkLed led3(LED3, 0.02);
+BlinkLed led4(LED4, 0.2);
BlinkLed ethGreen(p26, 0.02);
BlinkLed ethYellow(p25, 0.2);
DigitalOut fsusb30s(p9);
@@ -45,7 +45,7 @@
}
// Indicate downloading
- led2.startBlink();
+ led4.startBlink();
ethYellow.startBlink();
// FSUSB30 switches to HSD1 (mbed)
@@ -158,9 +158,9 @@
fsusb30s = 1; // HSD2
// Indicate finish downloading
- led2.finishBlink();
+ led4.finishBlink();
ethYellow.finishBlink();
- led1.startBlink();
+ led3.startBlink();
ethGreen.startBlink();
while(true){}