Exemple #1
0
 private void MovementManager_OnMovement2(MovementManager.MovementDirectionEnum direction, byte speedLeft, byte speedRight)
 {
     // Intercept and forward movement commands
     if (direction == MovementManager.MovementDirectionEnum.Stop)
     {
         EZBManager.PrimaryEZB.SendCommandData(0, 0x00, _MOVEMENT_STOP);
     }
     else if (direction == MovementManager.MovementDirectionEnum.Forward)
     {
         EZBManager.EZBs[0].SendCommandData(0, 0x00, _MOVEMENT_FORWARD, speedLeft, speedRight);
     }
     else if (direction == MovementManager.MovementDirectionEnum.Left)
     {
         EZBManager.EZBs[0].SendCommandData(0, 0x00, _MOVEMENT_LEFT, speedLeft, speedRight);
     }
     else if (direction == MovementManager.MovementDirectionEnum.Right)
     {
         EZBManager.EZBs[0].SendCommandData(0, 0x00, _MOVEMENT_RIGHT, speedLeft, speedRight);
     }
     else if (direction == MovementManager.MovementDirectionEnum.Reverse)
     {
         EZBManager.EZBs[0].SendCommandData(0, 0x00, _MOVEMENT_REVERSE, speedLeft, speedRight);
     }
 }
        private void Movement_OnMovement2(MovementManager.MovementDirectionEnum direction, byte speedLeft, byte speedRight)
        {
            if (_robotController == null || IsClosing)
            {
                return;
            }

            var speedLeftScaled  = (short)Functions.RemapScalar(speedLeft, 0, 255, 0, 500);
            var speedRightScaled = (short)Functions.RemapScalar(speedRight, 0, 255, 0, 500);

            if (direction == MovementManager.MovementDirectionEnum.Stop)
            {
                _robotController.DriveDirect(0, 0);

                Invokers.SetBackColor(btnForward, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnRight, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnLeft, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnReverse, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnStop, Common.ChangeColorBrightness(btnForward.Parent.BackColor, -0.3f));
            }
            else if (direction == MovementManager.MovementDirectionEnum.Forward)
            {
                _robotController.DriveDirect(speedLeftScaled, speedRightScaled);

                Invokers.SetBackColor(btnForward, Common.ChangeColorBrightness(btnForward.Parent.BackColor, -0.3f));
                Invokers.SetBackColor(btnRight, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnLeft, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnReverse, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnStop, btnForward.Parent.BackColor);
            }
            else if (direction == MovementManager.MovementDirectionEnum.Right)
            {
                _robotController.DriveDirect(speedLeftScaled, -speedRightScaled);

                Invokers.SetBackColor(btnForward, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnRight, Common.ChangeColorBrightness(btnForward.Parent.BackColor, -0.3f));
                Invokers.SetBackColor(btnLeft, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnReverse, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnStop, btnForward.Parent.BackColor);
            }
            else if (direction == MovementManager.MovementDirectionEnum.Reverse)
            {
                _robotController.DriveDirect(-speedLeftScaled, -speedRightScaled);

                Invokers.SetBackColor(btnForward, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnRight, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnLeft, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnReverse, Common.ChangeColorBrightness(btnForward.Parent.BackColor, -0.3f));
                Invokers.SetBackColor(btnStop, btnForward.Parent.BackColor);
            }
            else if (direction == MovementManager.MovementDirectionEnum.Left)
            {
                _robotController.DriveDirect(-speedLeftScaled, speedRightScaled);

                Invokers.SetBackColor(btnForward, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnRight, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnLeft, Common.ChangeColorBrightness(btnForward.Parent.BackColor, -0.3f));
                Invokers.SetBackColor(btnReverse, btnForward.Parent.BackColor);
                Invokers.SetBackColor(btnStop, btnForward.Parent.BackColor);
            }
        }