private void StopVideoRecordingButton_Click(object sender, RoutedEventArgs e) { _droneClient.StopRecordingVideo(); UpdateDisplay(); StartVideoRecordingButton.Visibility = Visibility.Visible; StopVideoRecordingButton.Visibility = Visibility.Collapsed; VideoRecordingMessageGrid.IsOpen = false; }
private void Video_Click(object sender, RoutedEventArgs e) { if (isRecording) { _droneClient.StopRecordingVideo(); RecordVideoButton.Content = "Rec"; } else { _droneClient.StartRecordingVideo(); RecordVideoButton.Content = "Stop"; } isRecording = !isRecording; }
private void StopVideoRecordingButton_Click(object sender, RoutedEventArgs e) { _droneClient.StopRecordingVideo(); UpdateDisplay(); }
public async void Update() { float pitch = 0, roll = 0, yaw = 0, gaz = 0; if (_DroneClient == null || _Controller == null) { return; } if (!_Controller.IsConnected || !_Controller.GetState(out _ControllerState)) { _FailCounter++; if (_FailCounter > _FailCounterMax) { DroneClient.InputState.Update(0, 0, 0, 0); //Avoid overflow _FailCounter = _FailCounterMax; } return; } if (_ControllerState.PacketNumber <= _ControllerPreviousState.PacketNumber) { return; } //Thumbs var leftThumb = NormalizeInput(_ControllerState.Gamepad.LeftThumbX, _ControllerState.Gamepad.LeftThumbY, Convert.ToInt16(SharpDX.XInput.Gamepad.LeftThumbDeadZone * 1.1), _JoystickRange); if (leftThumb.NormalizedMagnitude > 0) { roll = (float)_ControllerState.Gamepad.LeftThumbX * _RollThrottle / _JoystickRange; pitch = (float)_ControllerState.Gamepad.LeftThumbY * _PitchThrottle / _JoystickRange; } var rightThumb = NormalizeInput(_ControllerState.Gamepad.RightThumbX, _ControllerState.Gamepad.RightThumbY, Convert.ToInt16(SharpDX.XInput.Gamepad.RightThumbDeadZone * 1.1), _JoystickRange); if (rightThumb.NormalizedMagnitude > 0) { yaw = (float)_ControllerState.Gamepad.RightThumbX * _YawThrottle / _JoystickRange; Debug.WriteLine(yaw); gaz = (float)_ControllerState.Gamepad.RightThumbY * _GazThrottle / _JoystickRange; } _FailCounter = 0; DroneClient.InputState.Update(roll, -pitch, yaw, gaz); //Debug.WriteLine("InputState=" + DroneClient.InputState.ToString()); //Buttons var buttons = _ControllerState.Gamepad.Buttons; if (buttons.HasFlag(GamepadButtonFlags.Start)) { if (await DroneClient.ConnectAsync()) { if (DroneClient.NavigationData.State.HasFlag(NavigationState.Landed)) { DroneClient.TakeOff(); } else { DroneClient.Land(); } } } if (buttons.HasFlag(GamepadButtonFlags.Back)) { DroneClient.Emergency(); } if (buttons.HasFlag(GamepadButtonFlags.Y)) { DroneClient.ResetEmergency(); } if (buttons.HasFlag(GamepadButtonFlags.X)) { DroneClient.ExecuteFlatTrim(); } if (buttons.HasFlag(GamepadButtonFlags.A)) { DroneClient.TakePicture(); } if (buttons.HasFlag(GamepadButtonFlags.B)) { if (DroneClient.IsRecording()) { DroneClient.StopRecordingVideo(); } else { DroneClient.StartRecordingVideo(); } } if (buttons.HasFlag(GamepadButtonFlags.DPadLeft)) { DroneClient.PlayAnimation(FlightAnimationType.FlipLeft); } if (buttons.HasFlag(GamepadButtonFlags.DPadUp)) { DroneClient.PlayAnimation(FlightAnimationType.FlipAhead); } if (buttons.HasFlag(GamepadButtonFlags.DPadRight)) { DroneClient.PlayAnimation(FlightAnimationType.FlipRight); } if (buttons.HasFlag(GamepadButtonFlags.DPadDown)) { DroneClient.PlayAnimation(FlightAnimationType.FlipBehind); } _ControllerPreviousState = _ControllerState; }