public void Right(bool isStreight = false)
 {
     if (!isStreight)
     {
         CancelTimer();
     }
     State = EState.Right;
     BcoreManager.SetMotorPwm(0, Bcore.MaxMotorPwm);
     BcoreManager.SetServoPos(0, Pref.ServoPosRight);
 }
        public void Stop(bool isStreight = false)
        {
            if (!isStreight)
            {
                CancelTimer();
            }

            if (State == EState.Left)
            {
                State = EState.LStop;
            }
            else if (State == EState.Right)
            {
                State = EState.RStop;
            }

            BcoreManager.SetMotorPwm(0, Bcore.StopMotorPwm);
        }
예제 #3
0
        public void OnSensorChanged(SensorEvent e)
        {
            if (!BcoreManager.IsInitialized)
            {
                return;
            }

            var accz = e.Values[2];

            //Android.Util.Log.Debug("ControllerService", "acc:{0}", accz);

            var state = EState.Stop;

            if (accz > 6.0)
            {
                state = EState.Left;
            }
            else if (accz < -6.0)
            {
                state = EState.Right;
            }

            if (state == State)
            {
                return;
            }

            var speed = 0x80;

            switch (state)
            {
            case EState.Left:
                speed = 255;
                break;

            case EState.Right:
                speed = 0;
                break;
            }

            BcoreManager.SetMotorPwm(0, speed);
            State = state;
        }