2012-04-19 21:05:33 -03:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using ArdupilotMega.Controls.BackstageView;
|
2012-04-24 10:49:27 -03:00
|
|
|
|
using ArdupilotMega.Controls;
|
2012-04-19 21:05:33 -03:00
|
|
|
|
|
|
|
|
|
namespace ArdupilotMega.GCSViews.ConfigurationView
|
|
|
|
|
{
|
2012-07-22 04:51:05 -03:00
|
|
|
|
public partial class ConfigAccelerometerCalibrationPlane : UserControl, IActivate
|
2012-04-19 21:05:33 -03:00
|
|
|
|
{
|
|
|
|
|
bool startup = false;
|
|
|
|
|
|
|
|
|
|
public ConfigAccelerometerCalibrationPlane()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-22 04:51:05 -03:00
|
|
|
|
public void Activate()
|
2012-04-19 21:05:33 -03:00
|
|
|
|
{
|
|
|
|
|
if (!MainV2.comPort.BaseStream.IsOpen)
|
|
|
|
|
{
|
|
|
|
|
this.Enabled = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-12-07 05:19:46 -04:00
|
|
|
|
if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduPlane)
|
2012-04-19 21:05:33 -03:00
|
|
|
|
{
|
|
|
|
|
this.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.Enabled = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startup = true;
|
|
|
|
|
|
2012-12-07 05:19:46 -04:00
|
|
|
|
if (MainV2.comPort.MAV.param["MANUAL_LEVEL"] != null)
|
|
|
|
|
CHK_manuallevel.Checked = MainV2.comPort.MAV.param["MANUAL_LEVEL"].ToString() == "1" ? true : false;
|
2012-04-19 21:05:33 -03:00
|
|
|
|
|
|
|
|
|
startup = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CHK_manuallevel_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (startup)
|
|
|
|
|
return;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
MainV2.comPort.setParam("MANUAL_LEVEL", ((CheckBox)sender).Checked == true ? 1 : 0);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
CustomMessageBox.Show("Failed to level : AP 2.32+ is required");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BUT_levelplane_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
2012-11-25 01:42:46 -04:00
|
|
|
|
{
|
2012-09-03 19:46:56 -03:00
|
|
|
|
MainV2.comPort.doCommand(MAVLink.MAV_CMD.PREFLIGHT_CALIBRATION,1,0,1,0,0,0,0);
|
2012-04-19 21:05:33 -03:00
|
|
|
|
BUT_levelplane.Text = "Complete";
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
CustomMessageBox.Show("Failed to level : AP 2.32+ is required");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|