Rob Dobson / Mbed 2 deprecated SpideyWallWeb

Dependencies:   EthernetInterfacePlusHostname RdWebServer mbed-rtos mbed

Revision:
0:887096209439
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LedCmdHandler.cpp	Tue Aug 18 16:03:29 2015 +0000
@@ -0,0 +1,55 @@
+// Handle Led Commands
+
+#include "mbed.h"
+#include <stdio.h>
+#include <string.h>
+#include "ledstrip.h"
+#include "LedCmdHandler.h"
+#include "EffectSmooth.h"
+#include "EffectSnake.h"
+
+void LedCmdHandler::AddEffects()
+{
+    effects.push_back(new EffectSmooth(pLedStrip));
+    effects.push_back(new EffectSnake(pLedStrip));
+}
+
+void LedCmdHandler::DoCommand(char* cmdStr)
+{
+    // Stop any existing command
+    Stop();
+    
+    printf("Cmd %s\n\r", cmdStr);
+    // Extract command
+    char* pch = strtok (cmdStr,"/");
+    if (pch == NULL)
+        return;
+
+    // Find a matching command
+    list<Effect*>::iterator iter;
+    for(iter = effects.begin(); iter != effects.end(); ++iter)
+    {
+        printf("Trying %s vs %s\n\r", (*iter)->GetName(), pch);
+        wait_ms(1000);
+        if (strcmp((*iter)->GetName(), pch) == 0)
+        {
+            pCurEffect = *iter;
+            printf("Command = %s", pCurEffect->GetName());
+            pCurEffect->Init(cmdStr);
+            break;
+        }
+    }
+}
+
+void LedCmdHandler::NextGen()
+{
+    if (pCurEffect != NULL)
+        pCurEffect->NextGen();    
+}
+
+void LedCmdHandler::Stop()
+{
+    if (pCurEffect != NULL)
+        pCurEffect->Stop();
+    pCurEffect = NULL;
+}
\ No newline at end of file