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.
Command.h
- Committer:
- Xiaofei
- Date:
- 2015-11-29
- Revision:
- 11:6c56d8ca6e99
- Parent:
- 10:6e32b53f04c3
File content as of revision 11:6c56d8ca6e99:
#pragma once
#include <cstdint>
/** Command class.
* Author Xiaofei Qiu
*/
class Command
{
public:
Command();
Command(const Command&);
virtual ~Command(){}
/** Uses vitual function for dynamic binding */
virtual void execute() = 0;
/** Sets Speed, if is_negative is true, then speed will be negative. otherwaise, speed is posotive */
void setSpeed(const std::int8_t& sp, const std::int8_t& is_negative = 0);
protected:
/** Motor speed */
float _SPEED;
/** Direction of the motor speed */
bool _IS_NEGATIVE;
};
class LedCommand : public Command
{
public:
LedCommand(){}
virtual void execute();
};
class TurnLeftCommand : public Command
{
public:
TurnLeftCommand(){}
virtual void execute();
};
class TurnRightCommand : public Command
{
public:
TurnRightCommand(){}
virtual void execute();
};
class GoStraightCommand : public Command
{
public:
GoStraightCommand(){}
virtual void execute();
};
class StopCommand : public Command
{
public:
StopCommand(){}
virtual void execute();
};