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(); Task.WaitAll(); // maestroDevice.Maestro.getMaestroVariables(); tbDeviceName.Text = maestroDevice.Name + " Connected"; // Create an array of controls channelSettings = new ChannelSettingsControl[count]; for (byte i = 0; i < count; i++) { // add a speed , acceleration and target controls to the app channelSettings[i] = new ChannelSettingsControl(); channelSettings[i].ChannelNumber = i; channelSettings[i].Acceleration = settings.channelSettings[i].acceleration; channelSettings[i].Speed = settings.channelSettings[i].speed; channelSettings[i].MinPosition = settings.channelSettings[i].minimum; channelSettings[i].MaxPosition = settings.channelSettings[i].maximum; channelSettings[i].ServoName = settings.channelSettings[i].name; channelSettings[i].Mode = settings.channelSettings[i].mode; channelSettings[i].homeMode = settings.channelSettings[i].homeMode; channelSettings[i].Range = (Int16)settings.channelSettings[i].range; channelSettings[i].Target = settings.channelSettings[i].home; channelSettings[i].Nuetral8Bit = settings.channelSettings[i].neutral; ControlPanel.Children.Add(channelSettings[i]); } }
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; } } }