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
LedCmdHandler.cpp
- Committer:
- Bobty
- Date:
- 2015-08-18
- Revision:
- 0:887096209439
File content as of revision 0:887096209439:
// 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;
}