예제 #1
0
        private void ParseCommand(GoPiGoCommand command, int value)
        {
            var motorController = _goPiGo.MotorController();

            switch (command)
            {
            case GoPiGoCommand.Stop:
                motorController.Stop();
                break;

            case GoPiGoCommand.Backward:
                motorController.MoveBackward();
                break;

            case GoPiGoCommand.Forward:
                motorController.MoveForward();
                break;

            case GoPiGoCommand.Left:
                motorController.MoveLeft();
                break;

            case GoPiGoCommand.Right:
                motorController.MoveRight();
                break;

            case GoPiGoCommand.RotateLeft:
                motorController.RotateLeft();
                break;

            case GoPiGoCommand.RotateRight:
                motorController.RotateRight();
                break;

            case GoPiGoCommand.SetLeftMotorSpeed:
                motorController.SetLeftMotorSpeed(value);
                break;

            case GoPiGoCommand.SetRightMotorSpeed:
                motorController.SetRightMotorSpeed(value);
                break;

            case GoPiGoCommand.SwitchLeftLed:
                _leftLed.ChangeState((SensorStatus)value);
                break;

            case GoPiGoCommand.SwitchRightled:
                _rightLed.ChangeState((SensorStatus)value);
                break;

            case GoPiGoCommand.SetServoAngle:
                motorController.RotateServo(value);
                break;
            }
        }