private async void btnConnection_Click(object sender, RoutedEventArgs e) { if (SpherosDiscovered.SelectedItem != null) { SpheroConnection connection = await SpheroConnectionProvider.CreateConnection((SpheroInformation)SpherosDiscovered.SelectedItem); Frame.Navigate(typeof(ConnectedPage), connection); } }
/// Les méthodes fournies dans cette section sont utilisées simplement pour permettre /// NavigationHelper pour répondre aux méthodes de navigation de la page. /// /// La logique spécifique à la page doit être placée dans les gestionnaires d'événements pour /// <see cref="GridCS.Common.NavigationHelper.LoadState"/> /// et <see cref="GridCS.Common.NavigationHelper.SaveState"/>. /// Le paramètre de navigation est disponible dans la méthode LoadState /// en plus de l'état de page conservé durant une session antérieure. protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter != null && e.Parameter is SpheroConnection) { _connection = (SpheroConnection)e.Parameter; } navigationHelper.OnNavigatedTo(e); }
protected override async void OnNavigatedFrom(NavigationEventArgs e) { navigationHelper.OnNavigatedFrom(e); if (_connection != null) { await _connection.Disconnect(); _connection = null; } }
//private void Roll(int spheroAngle, int spheroSpeed){} //private void SetBackLED(int p){} //private void SetRGBLED(int p1, int p2, int p3){} //private void SetHeading(int configAngle){} //public JediSphero(SpheroConnection connection) public JediSphero(SpheroConnection connection) : base(connection) { double frequency = 20; _msDelay = (int)(1000.0 / frequency); _connection = connection; _currentX = 0.0; _currentY = 0.0; _speedScale = 0.5; _spheroSpeed = 255.0 * _speedScale; _timer = new Timer(_msDelay); _timer.Elapsed += IterationHandler; _timer.Start(); }
private async void btnConnection_Click(object sender, RoutedEventArgs e) { if (SpherosDiscovered.SelectedItem != null) { SpheroInformation information = (SpheroInformation)SpherosDiscovered.SelectedItem; SpheroConnection connection = await SpheroConnectionProvider.CreateConnection(information); if (connection == null) { MessageBox.Show("Connection failed"); } else { App.CurrentConnection = connection; NavigationService.Navigate(new Uri("/MacroPage.xaml", UriKind.RelativeOrAbsolute)); } } }
public static async Task <JediSphero> GetSpheroAsync() { IEnumerable <SpheroInformation> spheros = await SpheroConnectionProvider.DiscoverSpheros(); SpheroInformation spheroInfo = spheros.FirstOrDefault(); if (spheroInfo == null) { return(null); } SpheroConnection connection = await SpheroConnectionProvider.CreateConnection(spheroInfo); if (connection == null) { return(null); } var spheroDevice = new JediSphero(connection); return(spheroDevice); }
public CoreDevice(SpheroConnection connection) { this._connection = connection; this._connection.SetCore(this); }
/// <summary> /// Create an new sphero with a connection /// </summary> /// <param name="connection">Current connection to the sphero</param> public SpheroDevice(SpheroConnection connection) { this._connection = connection; this._connection.SetSphero(this); }