Пример #1
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            usb = new UsbSerial("VID_2341", "PID_0042");//Arduino MEGA

            //construct the firmata client
            firmata = new UwpFirmata();
            arduino = new RemoteDevice(firmata);
            firmata.begin(usb);

            //we do not care about inputs in this example
            //firmata.startListening();

            usb.begin(115200, SerialConfig.SERIAL_8N1);
            arduino.DeviceReady            += Stepper_Usb_ConnectionEstablished; //usb.ConnectionEstablished
            arduino.DeviceReady            += Drive_Usb_ConnectionEstablished;   //usb.ConnectionEstablished
            arduino.DeviceConnectionFailed += Arduino_DeviceConnectionFailed;

            deferral = taskInstance.GetDeferral();
            //pwmController = (await PwmController.GetControllersAsync(PwmPCA9685.PwmProviderPCA9685.GetPwmProvider()))[0];
            //pwmController.SetDesiredFrequency(300); // Check if this is the correct frequency for Talon
            //motorPin = pwmController.OpenPin(13);
            //drive.RampUp(motorPin, .34);
            drive = new FirmataDriveController(firmata);
            step  = new StepperController(firmata);

            var carImpl = new CarImplementation(step, drive);

            carRC.implementation = carImpl;


            await Task.Run(async() =>
            {
                while (!stepperUsbSetup && !driveUsbSetup)
                {
                    //wait
                    await Task.Delay(1);
                }

                carRC.Start();
            });
        }
Пример #2
0
 public CarImplementation(StepperController s, FirmataDriveController d)
 {
     steering = s;
     drive    = d;
 }