Beispiel #1
0
        public MainPage()
        {
            this.InitializeComponent();
            this.Unloaded += MainPage_Unloaded;

            led = new MulticolorLed(redPinNumber: 18, greenPinNumber: 23, bluePinNumber: 24);

            button = new PushButton(pinNumber: 26);
            button.RaiseEventsOnUIThread = true;
            button.Click += Button_Click;

            distanceSensor = new Sr04UltrasonicDistanceSensor(triggerPinNumber: 12, echoPinNumber: 16, mode: ReadingMode.Manual);

            var motorDriver = new L298nMotorDriver(motor1Pin1: 27, motor1Pin2: 22, motor2Pin1: 5, motor2Pin2: 6);
            motors = motorDriver.AsLeftRightMotors();

            rnd = new Random(unchecked((int)(DateTime.Now.Ticks)));

            moveTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(MOVE_INTERVAL_SEC) };
            moveTimer.Tick += MoveTimer_Tick;
        }
Beispiel #2
0
        public MainPage()
        {
            this.InitializeComponent();
            Unloaded += MainPage_Unloaded;

            connection = new RemoteConnection();
            connection.OnRoverMovementEvent(RoverMovementEvent);

            var motorDriver = new L298nMotorDriver(motor1Pin1: 27, motor1Pin2: 22, motor2Pin1: 5, motor2Pin2: 6);
            motors = motorDriver.AsLeftRightMotors();

            led = new MulticolorLed(redPinNumber: 18, greenPinNumber: 23, bluePinNumber: 24);

            movements = new Dictionary<RoverMovementType, Action>
            {
                [RoverMovementType.Forward] = () => motors.MoveForward(),
                [RoverMovementType.Backward] = () => motors.MoveBackward(),
                [RoverMovementType.TurnLeft] = () => motors.TurnLeft(),
                [RoverMovementType.TurnRight] = () => motors.TurnRight(),
                [RoverMovementType.RotateLeft] = () => motors.RotateLeft(),
                [RoverMovementType.RotateRight] = () => motors.RotateRight(),
                [RoverMovementType.Stop] = () => motors.Stop()
            };
        }
 internal LeftRightMotors(L298nMotorDriver motorDriver) 
     : base(motorDriver.Motor1, motorDriver.Motor2)
 { }