Ejemplo n.º 1
0
        //  private unsafe int getservostructsize()
        //{
        //  return sizeof(ServoStatus);
        //}

        private async void drawMaestroControls()
        {
            // get the number of servos on the board
            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
            Connected         = true;
            tbDeviceName.Text = maestroDevice.Name + " Connected";
            // Create an array of  controls
            maestroChannels = new MaestroControl[count];
            for (UInt16 i = 0; i < count; i++)
            {
                // add a speed , acceleration and target controls to the app
                maestroChannels[i] = new MaestroControl();
                maestroChannels[i].ChannelNumber = i;
                // update the controls to show current values from the board
                maestroChannels[i].Acceleration = Convert.ToUInt16(settings.channelSettings[i].acceleration);
                maestroChannels[i].Speed        = Convert.ToUInt16(settings.channelSettings[i].speed);
                // position / 4 as it returns it in 1/4 microseconds
                maestroChannels[i].Position = Convert.ToUInt16(MaestroDevice.positionToMicroseconds(maestroDevice.Maestro.servoStatus[i].position));
                maestroPanel.Children.Add(maestroChannels[i]);
                // add the callbacks for changes
                maestroChannels[i].positionChanged     += MainPage_positionChanged;
                maestroChannels[i].speedChanged        += MainPage_speedChanged;
                maestroChannels[i].accelerationChanged += MainPage_accelerationChanged;
            }
        }
Ejemplo n.º 2
0
 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]);
         }
     }
 }