Пример #1
0
 private void Drone_OnDataChange(object sender, DataChangedEventArgs e)
 {
     if (e.Data.State == DroneState.OTA)
     {
         Drone.OnDataChange -= Drone_OnDataChange;
         SendData();
     }
 }
Пример #2
0
        private void Drone_OnDataChange(object sender, DataChangedEventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke(new EventHandler<DataChangedEventArgs>(Drone_OnDataChange), sender, e);
                return;
            }


            SuspendLayout();

            if (!float.IsNaN(e.Data.Gyro.Pitch) && !float.IsNaN(e.Data.Gyro.Roll))
                artificialHorizon.SetAttitudeIndicatorParameters(e.Data.Gyro.Pitch, -e.Data.Gyro.Roll);
            if (!float.IsNaN(e.Data.Gyro.Yaw))
                headingIndicator.SetHeadingIndicatorParameters((int)e.Data.Gyro.Yaw);

            calibrateGyroButton.Enabled = e.Data.State != DroneState.Armed && e.Data.State != DroneState.Flying;

            orientationLabel.Text = string.Format("Roll: {0} Pitch: {1} Yaw: {2}",
                Formatting.FormatDecimal(e.Data.Gyro.Roll, 2),
                Formatting.FormatDecimal(e.Data.Gyro.Pitch, 2),
                Formatting.FormatDecimal(e.Data.Gyro.Yaw, 2));

            rotationLabel.Text = string.Format("Rotation x: {0} y: {1} z: {2}",
                Formatting.FormatDecimal(e.Data.Gyro.GyroX, 2),
                Formatting.FormatDecimal(e.Data.Gyro.GyroY, 2),
                Formatting.FormatDecimal(e.Data.Gyro.GyroZ, 2));

            float ax = e.Data.Gyro.AccelerationX;
            float ay = e.Data.Gyro.AccelerationY;
            float az = e.Data.Gyro.AccelerationZ;

            float len = (float)Math.Sqrt(ax * ax + ay * ay + az * az);
            accelerationLabel.Text = string.Format("Acceleration x: {0} y: {1} z: {2} len: {3}",
                Formatting.FormatDecimal(ax, 2),
                Formatting.FormatDecimal(ay, 2),
                Formatting.FormatDecimal(az, 2),
                Formatting.FormatDecimal(len, 2));

            magnetLabel.Text = string.Format("Magnet x: {0} y: {1} z: {2}",
                Formatting.FormatDecimal(e.Data.Gyro.MagnetX, 2),
                Formatting.FormatDecimal(e.Data.Gyro.MagnetY, 2),
                Formatting.FormatDecimal(e.Data.Gyro.MagnetZ, 2));

            temperatureLabel.Text = string.Format("Temperature: {0}°C",
                Formatting.FormatDecimal(e.Data.Gyro.Temperature, 2));

            batteryVoltageLabel.Text = string.Format("Battery voltage: {0} V",
                Formatting.FormatDecimal(e.Data.BatteryVoltage, 2));

            ResumeLayout();
        }
Пример #3
0
        private void Drone_OnDataChange(object sender, DataChangedEventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke(new EventHandler<DataChangedEventArgs>(Drone_OnDataChange), sender, e);
                return;
            }

            UpdateGraph(servoGraph, e.Data.MotorValues);

            orientationGraphList.UpdateValue(e.Data.Gyro.Roll, e.Data.Gyro.Pitch, e.Data.Gyro.Yaw);
            rotationGraphList.UpdateValue(e.Data.Gyro.GyroX, e.Data.Gyro.GyroY, e.Data.Gyro.GyroZ);
            accelerationGraphList.UpdateValue(e.Data.Gyro.AccelerationX, e.Data.Gyro.AccelerationY, e.Data.Gyro.AccelerationZ);
        }
Пример #4
0
        private void OnDroneDataChange(object sender, DataChangedEventArgs args)
        {
            if (InvokeRequired)
            {
                Invoke(new EventHandler<DataChangedEventArgs>(OnDroneDataChange), sender, args);
                return;
            }

            QuadMotorValues motorValues = args.Data.MotorValues;

            SetServoValues(motorValues.FrontLeft, motorValues.FrontRight, motorValues.BackLeft, motorValues.BackRight);
            UpdateServoValue(motorValues.FrontLeft, motorValues.FrontRight, motorValues.BackLeft, motorValues.BackRight);
            UpdateEnabled(args.Data.State);
        }
Пример #5
0
 private void Drone_OnDataChange(object sender, DataChangedEventArgs e)
 {
     UpdateProgress();
 }
Пример #6
0
        private void Drone_OnDataChange(object sender, DataChangedEventArgs eventArgs)
        {
            if (InvokeRequired)
            {
                Invoke(new EventHandler<DataChangedEventArgs>(Drone_OnDataChange), this, eventArgs);
                return;
            }

            UpdateData(eventArgs.Data);
        }