Rob Dobson / Mbed 2 deprecated SpideyWallWeb

Dependencies:   EthernetInterfacePlusHostname RdWebServer mbed-rtos mbed

Committer:
Bobty
Date:
Tue Aug 18 16:03:29 2015 +0000
Revision:
0:887096209439
Initial - unchanged since 2013

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Bobty 0:887096209439 1 // Handle Led Commands
Bobty 0:887096209439 2
Bobty 0:887096209439 3 #include "mbed.h"
Bobty 0:887096209439 4 #include <stdio.h>
Bobty 0:887096209439 5 #include <string.h>
Bobty 0:887096209439 6 #include "ledstrip.h"
Bobty 0:887096209439 7 #include "LedCmdHandler.h"
Bobty 0:887096209439 8 #include "EffectSmooth.h"
Bobty 0:887096209439 9 #include "EffectSnake.h"
Bobty 0:887096209439 10
Bobty 0:887096209439 11 void LedCmdHandler::AddEffects()
Bobty 0:887096209439 12 {
Bobty 0:887096209439 13 effects.push_back(new EffectSmooth(pLedStrip));
Bobty 0:887096209439 14 effects.push_back(new EffectSnake(pLedStrip));
Bobty 0:887096209439 15 }
Bobty 0:887096209439 16
Bobty 0:887096209439 17 void LedCmdHandler::DoCommand(char* cmdStr)
Bobty 0:887096209439 18 {
Bobty 0:887096209439 19 // Stop any existing command
Bobty 0:887096209439 20 Stop();
Bobty 0:887096209439 21
Bobty 0:887096209439 22 printf("Cmd %s\n\r", cmdStr);
Bobty 0:887096209439 23 // Extract command
Bobty 0:887096209439 24 char* pch = strtok (cmdStr,"/");
Bobty 0:887096209439 25 if (pch == NULL)
Bobty 0:887096209439 26 return;
Bobty 0:887096209439 27
Bobty 0:887096209439 28 // Find a matching command
Bobty 0:887096209439 29 list<Effect*>::iterator iter;
Bobty 0:887096209439 30 for(iter = effects.begin(); iter != effects.end(); ++iter)
Bobty 0:887096209439 31 {
Bobty 0:887096209439 32 printf("Trying %s vs %s\n\r", (*iter)->GetName(), pch);
Bobty 0:887096209439 33 wait_ms(1000);
Bobty 0:887096209439 34 if (strcmp((*iter)->GetName(), pch) == 0)
Bobty 0:887096209439 35 {
Bobty 0:887096209439 36 pCurEffect = *iter;
Bobty 0:887096209439 37 printf("Command = %s", pCurEffect->GetName());
Bobty 0:887096209439 38 pCurEffect->Init(cmdStr);
Bobty 0:887096209439 39 break;
Bobty 0:887096209439 40 }
Bobty 0:887096209439 41 }
Bobty 0:887096209439 42 }
Bobty 0:887096209439 43
Bobty 0:887096209439 44 void LedCmdHandler::NextGen()
Bobty 0:887096209439 45 {
Bobty 0:887096209439 46 if (pCurEffect != NULL)
Bobty 0:887096209439 47 pCurEffect->NextGen();
Bobty 0:887096209439 48 }
Bobty 0:887096209439 49
Bobty 0:887096209439 50 void LedCmdHandler::Stop()
Bobty 0:887096209439 51 {
Bobty 0:887096209439 52 if (pCurEffect != NULL)
Bobty 0:887096209439 53 pCurEffect->Stop();
Bobty 0:887096209439 54 pCurEffect = NULL;
Bobty 0:887096209439 55 }