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: EthernetInterfacePlusHostname RdWebServer mbed-rtos mbed
Diff: LedCmdHandler.cpp
- Revision:
- 0:887096209439
diff -r 000000000000 -r 887096209439 LedCmdHandler.cpp
--- /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