private async void Maestrodevices_deviceAddedCallback(MaestroDeviceListItem device)
        {
            bool matched = false;

            // we will normally only have one device so
            if (listOfDevices != null)
            {
                await Dispatcher.RunAsync(
                    CoreDispatcherPriority.Normal,
                    new DispatchedHandler(() =>
                {
                    // this can happen on first build as the event will be triggered even though we have built the list manually
                    foreach (MaestroDeviceListItem item in listOfDevices)
                    {
                        if (item.deviceInformation.Id == device.deviceInformation.Id)
                        {
                            // don't add device as we already have it
                            matched = true;
                            break;
                        }
                    }
                    if (matched == false)
                    {
                        // add the new board
                        listOfDevices.Add(device);
                        if ((lbDevices.SelectedIndex == -1) && (listOfDevices.Count > 0))
                        {
                            lbDevices.SelectedIndex = 0;      // select first item by deafult if we have one
                        }
                    }
                }));
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
        {
            if (eventArgs.Parameter as MaestroBoard != null)
            {
                maestroDevice     = (eventArgs.Parameter as MaestroBoard).maestro;
                tbDeviceName.Text = maestroDevice.Name + " Connected";
                drawMaestroControls();
                btnSave.IsEnabled = true;
            }
            else
            {
                tbDeviceName.Text = "Not Connected Pleaese Connect to Device First";
                // just create dummy set of panels
                channelSettings = new ChannelSettingsControl[6];
                for (byte i = 0; i < 6; i++)
                {
                    // add a speed , acceleration and target controls to the app
                    channelSettings[i] = new ChannelSettingsControl();

                    channelSettings[i].ChannelNumber = i;
                    ControlPanel.Children.Add(channelSettings[i]);
                    channelSettings[i].IsEnabled = false;
                    btnSave.IsEnabled            = false;
                }
            }
        }
Exemple #3
0
        protected async override void OnNavigatedTo(NavigationEventArgs eventArgs)
        {
            if (eventArgs.Parameter as MaestroBoard != null)
            {
                maestroDevice     = (eventArgs.Parameter as MaestroBoard).maestro;
                tbDeviceName.Text = maestroDevice.Name + " Connected";
                UInt16 count = maestroDevice.Maestro.ServoCount;
                // get all the settings stored on the board

                settings = await maestroDevice.Maestro.getUscSettings();

                await maestroDevice.Maestro.updateMaestroVariables();

                Task.WaitAll();  // wait until we have all the data
                servoStatus = maestroDevice.Maestro.servoStatus;
                maestroDevice.Maestro.setTarget(0, (ushort)(maestroDevice.Maestro.angleToMicroseconds(0, RHP) + (Offsets[0] * 4)));
                maestroDevice.Maestro.setTarget(1, (ushort)(maestroDevice.Maestro.angleToMicroseconds(1, RKP) + (Offsets[1] * 4)));
                maestroDevice.Maestro.setTarget(2, (ushort)(maestroDevice.Maestro.angleToMicroseconds(2, RAP) + (Offsets[2] * 4)));
                maestroDevice.Maestro.setTarget(3, (ushort)(maestroDevice.Maestro.angleToMicroseconds(3, LHP) + (Offsets[3] * 4)));
                maestroDevice.Maestro.setTarget(4, (ushort)(maestroDevice.Maestro.angleToMicroseconds(4, LKP) + (Offsets[4] * 4)));
                maestroDevice.Maestro.setTarget(5, (ushort)(maestroDevice.Maestro.angleToMicroseconds(5, LAP) + (Offsets[5] * 4)));
                fname = ApplicationData.Current.LocalFolder.Path + "\\Brat.cfg";
                if (File.Exists(fname))
                {
                    // load offsets
                    loadOffsets();
                }
            }
        }
 protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
 {
     if (eventArgs.Parameter as MaestroBoard != null)
     {
         maestroDevice = (eventArgs.Parameter as MaestroBoard).maestro;
         status.Text   = maestroDevice.Name + " Connected";
         updateSerialSettings();
     }
 }
 protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
 {
     if (eventArgs.Parameter as MaestroBoard != null)
     {
         maestroDevice     = (eventArgs.Parameter as MaestroBoard).maestro;
         tbDeviceName.Text = maestroDevice.Name + " Connected";
         // DrawArms();
         // MoveArm();
     }
 }
        private async void Maestrodevices_deviceConnectedCallback(MaestroDeviceListItem device)
        {
            await Dispatcher.RunAsync(
                CoreDispatcherPriority.Normal,
                new DispatchedHandler(() =>
            {
                // now connected so draw our sliders
                status.Text = device.Name + " Connected";

                if (maestroConnectionEvent != null)
                {
                    maestroConnectionEvent(this, NotifyType.Connected);
                }
            }));

            Globals.maestroBoard.maestro        = device;
            Globals.maestroBoard.BoardConnected = true;
        }
 protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
 {
     if (eventArgs.Parameter as MaestroBoard != null)
     {
         maestroDevice     = (eventArgs.Parameter as MaestroBoard).maestro;
         tbDeviceName.Text = maestroDevice.Name + " Connected";
         drawMaestroControls();
     }
     else
     {
         tbDeviceName.Text = "Not Connected Pleaese Connect to Device First";
         maestroChannels   = new MaestroControl[6];
         for (UInt16 i = 0; i < 6; i++)
         {
             // add a speed , acceleration and target controls to the app
             maestroChannels[i] = new MaestroControl();
             maestroChannels[i].ChannelNumber = i;
             maestroChannels[i].IsEnabled     = false;
             maestroPanel.Children.Add(maestroChannels[i]);
         }
     }
 }