public static void evaluateCustomCommand(List <byte> bytes) { string cmd = Encoding.ASCII.GetString(bytes.ToArray()); switch (cmd) { case "#take_photo": Camera.TakePhoto(); break; case "#load_photo": Camera.LoadPhoto(); break; case "#autopilotON": Autopilot.TakeControl(); break; case "#autopilotOFF": Autopilot.ReleaseControl(); break; case "#dismiss": Autopilot.Dismiss(); break; case "#land": Autopilot.Land(); break; default: Debug.WriteLine("Command not implemented: " + cmd); break; } }
//private void returnToHomeToggle_Checked(object sender, RoutedEventArgs e) //{ // /*if(gpsHoldToggle.IsChecked == true) // gpsHoldToggle.IsChecked = false;*/ // aux3 = 1000; // Debug.WriteLine("--------- RETURN TO HOME: ON ---------"); //} //private void returnToHomeToggle_Unchecked(object sender, RoutedEventArgs e) //{ // aux3 = 1500; // Debug.WriteLine("--------- RETURN TO HOME: OFF ---------"); //} private void takeOffLandToggle_Checked() { if (takeOffLandToggleTapped) { return; } Autopilot.TakeOff(); plusButton.IsEnabled = true; minusButton.IsEnabled = true; takeOffLandToggle.Source = new BitmapImage(new Uri("ms-appx:///Assets/Icons/land.png")); takeOffLandToggleTapped = true; }
private void takeOffLandToggle_Unchecked() { if (!takeOffLandToggleTapped) { return; } if (App.DroneType == DroneType.Custom && armToggle.IsChecked == true) { var cmd = Encoding.ASCII.GetBytes("#land"); Socket.SendData(cmd); takeOffLandToggle.Opacity = 0.2; } else { Autopilot.Land(); } plusButton.IsEnabled = false; minusButton.IsEnabled = false; takeOffLandToggleTapped = false; }