Ardupilot2/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigAccelerometerCalibrationQuad.cs
Michael Oborne 944488afaf APM Planner 1.1.99
Convert to IActivate, IDeactivate scheme, thanks andrew
add support for rfcomm* interfaces on linux
fix guage off screen draw mono issue.
remove use of BackStageViewContentPanel
andrews spacer changes - not using dues to screen space issue
change configpanel constructor to load xml directly
remove IMavlink Interface
fix hsi off screen draw issue on mono
modify hud to use sprite fonts, instead of drawing via GDI+
modify progress reporter to use a 10hz timer to update screen, using invoke/begininvoke fails on mono at 50hz (over 100ms per call).
fix targetalt and target airspeed jumping issue.
lots of cleanup on tab switching, ie stoping timers/other
3dr radio status led update
update ardurover car icon
speedup georef image screen. tested on over 1000 images.
2012-07-22 15:51:05 +08:00

119 lines
3.5 KiB
C#

using System;
using System.Reflection;
using System.Windows.Forms;
using ArdupilotMega.Controls.BackstageView;
using log4net;
using Transitions;
namespace ArdupilotMega.GCSViews.ConfigurationView
{
public partial class ConfigAccelerometerCalibrationQuad : UserControl, IActivate, IDeactivate
{
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private const float DisabledOpacity = 0.2F;
private const float EnabledOpacity = 1.0F;
public ConfigAccelerometerCalibrationQuad()
{
InitializeComponent();
}
private void BUT_levelac2_Click(object sender, EventArgs e)
{
try
{
#if MAVLINK10
Log.Info("Sending level command (mavlink 1.0)");
int fixme; // needs to be accel only
MainV2.comPort.doCommand(MAVLink.MAV_CMD.PREFLIGHT_CALIBRATION,1,1,1,1,1,1,1);
#else
log.Info("Sending level command (mavlink 0.9)");
MainV2.comPort.doAction(MAVLink.MAV_ACTION.MAV_ACTION_CALIBRATE_ACC);
#endif
BUT_levelac2.Text = "Complete";
}
catch(Exception ex)
{
Log.Error("Exception on level", ex);
CustomMessageBox.Show("Failed to level : ac2 2.0.37+ is required");
}
}
private void pictureBox_Click(object sender, EventArgs e)
{
if (sender == pictureBoxPlus)
radioButton_Plus.Checked = true;
else
radioButton_X.Checked = true;
}
private void SetPlus()
{
FadePicBoxes(DisabledOpacity, EnabledOpacity);
SetFrameParam(true);
}
private void SetX()
{
FadePicBoxes(EnabledOpacity, DisabledOpacity);
SetFrameParam(false);
}
private void SetFrameParam(bool isPlus)
{
var f = isPlus ? 0f : 1f;
try
{
MainV2.comPort.setParam("FRAME", f);
}
catch
{
CustomMessageBox.Show("Set frame failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private void FadePicBoxes(float xOpacity, float plusOpacity)
{
var fade = new Transition(new TransitionType_Linear(400));
fade.add(pictureBoxX, "Opacity", xOpacity);
fade.add(pictureBoxPlus, "Opacity", plusOpacity);
fade.run();
}
public void Activate()
{
if ((float)MainV2.comPort.param["FRAME"] == 0)
{
this.radioButton_Plus.Checked = true;
pictureBoxX.Opacity = DisabledOpacity;
pictureBoxPlus.Opacity = EnabledOpacity;
}
else
{
this.radioButton_X.Checked = true;
pictureBoxX.Opacity = EnabledOpacity;
pictureBoxPlus.Opacity = DisabledOpacity;
}
radioButton_Plus.CheckedChanged += RadioButtonPlusCheckedChanged;
}
public void Deactivate()
{
radioButton_Plus.CheckedChanged -= RadioButtonPlusCheckedChanged;
}
void RadioButtonPlusCheckedChanged(object sender, EventArgs e)
{
if (radioButton_X.Checked)
SetX();
else
SetPlus();
}
}
}