diff --git a/Controls/PrearmStatus.Designer.cs b/Controls/PrearmStatus.Designer.cs
new file mode 100644
index 0000000000..8014e159c8
--- /dev/null
+++ b/Controls/PrearmStatus.Designer.cs
@@ -0,0 +1,77 @@
+namespace MissionPlanner.Controls
+{
+ partial class PrearmStatus
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.TXT_PrearmErrors = new System.Windows.Forms.TextBox();
+ this.updatetexttimer = new System.Windows.Forms.Timer(this.components);
+ this.requestchecktimer = new System.Windows.Forms.Timer(this.components);
+ this.SuspendLayout();
+ //
+ // TXT_PrearmErrors
+ //
+ this.TXT_PrearmErrors.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.TXT_PrearmErrors.Location = new System.Drawing.Point(10, 10);
+ this.TXT_PrearmErrors.Multiline = true;
+ this.TXT_PrearmErrors.Name = "TXT_PrearmErrors";
+ this.TXT_PrearmErrors.Size = new System.Drawing.Size(364, 241);
+ this.TXT_PrearmErrors.TabIndex = 0;
+ //
+ // updatetexttimer
+ //
+ this.updatetexttimer.Tick += new System.EventHandler(this.updatetexttimer_Tick);
+ //
+ // requestchecktimer
+ //
+ this.requestchecktimer.Interval = 5000;
+ this.requestchecktimer.Tick += new System.EventHandler(this.requestchecktimer_Tick);
+ //
+ // PrearmStatus
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(384, 261);
+ this.Controls.Add(this.TXT_PrearmErrors);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
+ this.Name = "PrearmStatus";
+ this.Padding = new System.Windows.Forms.Padding(10);
+ this.ShowIcon = false;
+ this.Text = "Prearm Checks";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TextBox TXT_PrearmErrors;
+ private System.Windows.Forms.Timer updatetexttimer;
+ private System.Windows.Forms.Timer requestchecktimer;
+ }
+}
\ No newline at end of file
diff --git a/Controls/PrearmStatus.cs b/Controls/PrearmStatus.cs
new file mode 100644
index 0000000000..d47c1df4eb
--- /dev/null
+++ b/Controls/PrearmStatus.cs
@@ -0,0 +1,79 @@
+using log4net;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace MissionPlanner.Controls
+{
+ public partial class PrearmStatus : Form
+ {
+ private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ private DateTime lastRequestTime = DateTime.MinValue;
+ private DateTime searchTime = DateTime.MinValue;
+ public PrearmStatus()
+ {
+ InitializeComponent();
+
+ Utilities.ThemeManager.ApplyThemeTo(this);
+
+ updatetexttimer.Start();
+ requestchecktimer.Start();
+ requestchecktimer_Tick(null, null);
+ }
+
+ private void requestchecktimer_Tick(object sender, EventArgs e)
+ {
+ if (MainV2.comPort.MAV.cs.prearmstatus) return; // Don't request prearm checks if we are ready to arm
+
+ try
+ {
+ // Request prearm checks to be performed
+ MainV2.comPort.doCommand(
+ (byte)MainV2.comPort.sysidcurrent, (byte)MainV2.comPort.compidcurrent,
+ MAVLink.MAV_CMD.RUN_PREARM_CHECKS,
+ 0, 0, 0, 0, 0, 0, 0,
+ false // don't require ack
+ );
+
+ lastRequestTime = DateTime.Now;
+
+ }
+ catch (Exception ex)
+ {
+ log.Error(ex.Message);
+ }
+ }
+
+ private void updatetexttimer_Tick(object sender, EventArgs e)
+ {
+ // If armed, close the form
+ if(MainV2.comPort.MAV.cs.armed) this.Close();
+
+ // If prearm prearm checks are passing, display a message
+ if (MainV2.comPort.MAV.cs.prearmstatus)
+ {
+ TXT_PrearmErrors.Text = "Ready to Arm";
+ return;
+ }
+
+ // If it has been at least 1 second since the last request, search for all messages since the last request
+ if (DateTime.Now > lastRequestTime.AddSeconds(1))
+ searchTime = lastRequestTime;
+
+ // Fill text box with all unique messages since searchTime that start with "PreArm:"
+ var prearmMessages = MainV2.comPort.MAV.cs.messages.Where(m => m.time > searchTime && m.message.ToLower().StartsWith("prearm:")).Select(m => m.message).Distinct();
+ // If there are no messages, inform the user
+ if (!prearmMessages.Any())
+ prearmMessages = new[] { "Prearm checks failing", "Waiting for error messages..." };
+ TXT_PrearmErrors.Text = string.Join(Environment.NewLine, prearmMessages);
+ }
+ }
+}
diff --git a/Controls/PrearmStatus.resx b/Controls/PrearmStatus.resx
new file mode 100644
index 0000000000..4a3c81415e
--- /dev/null
+++ b/Controls/PrearmStatus.resx
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
+ 156, 17
+
+
\ No newline at end of file
diff --git a/ExtLibs/ArduPilot/CurrentState.cs b/ExtLibs/ArduPilot/CurrentState.cs
index 469fa53c1a..91febb29f8 100644
--- a/ExtLibs/ArduPilot/CurrentState.cs
+++ b/ExtLibs/ArduPilot/CurrentState.cs
@@ -160,6 +160,11 @@ public MAVState parent
public Mavlink_Sensors sensors_health = new Mavlink_Sensors();
public Mavlink_Sensors sensors_present = new Mavlink_Sensors();
+ public bool prearmstatus
+ {
+ get => connected && (sensors_health.prearm || !sensors_enabled.prearm);
+ }
+
private bool useLocation;
///
diff --git a/ExtLibs/ArduPilot/Mavlink/MAVLinkInterface.cs b/ExtLibs/ArduPilot/Mavlink/MAVLinkInterface.cs
index 474258fc69..758592dc44 100644
--- a/ExtLibs/ArduPilot/Mavlink/MAVLinkInterface.cs
+++ b/ExtLibs/ArduPilot/Mavlink/MAVLinkInterface.cs
@@ -5306,7 +5306,7 @@ public async Task readPacketAsync()
Settings.Instance["speechenable"] != null &&
Settings.Instance["speechenable"].ToString() == "True")
{
- if (speechenabled)
+ if (speechenabled && !logdata.StartsWith("PreArm:")) // Suppress audible PreArm messages
Speech.SpeakAsync(logdata);
}
}
diff --git a/ExtLibs/Controls/HUD.cs b/ExtLibs/Controls/HUD.cs
index faf3ec3248..0c63e9ebe6 100644
--- a/ExtLibs/Controls/HUD.cs
+++ b/ExtLibs/Controls/HUD.cs
@@ -220,6 +220,9 @@ private class character
[System.ComponentModel.Browsable(true), DefaultValue(true)]
public bool displayvibe { get; set; }
+ [System.ComponentModel.Browsable(true), DefaultValue(true)]
+ public bool displayprearm { get; set; }
+
[System.ComponentModel.Browsable(true), DefaultValue(true)]
public bool displayAOASSA { get; set; }
@@ -242,11 +245,13 @@ public HUD()
opengl =
displayvibe =
displayekf =
- displayheading =
- displayspeed =
- displayalt =
- displayconninfo =
- displayxtrack = displayrollpitch = displaygps = bgon = hudon = batteryon = true;
+ displayprearm =
+ displayheading =
+ displayspeed =
+ displayalt =
+ displayconninfo =
+ displayxtrack =
+ displayrollpitch = displaygps = bgon = hudon = batteryon = true;
displayAOASSA = false;
@@ -832,6 +837,9 @@ public DateTime datetime
[System.ComponentModel.Browsable(true), System.ComponentModel.Category("Values")]
public float ekfstatus { get; set; }
+ [System.ComponentModel.Browsable(true), System.ComponentModel.Category("Values")]
+ public bool prearmstatus { get; set; }
+
[System.ComponentModel.Browsable(true), System.ComponentModel.Category("Values")]
public float AOA
{
@@ -1145,9 +1153,11 @@ protected override void OnLoad(EventArgs e)
public event EventHandler ekfclick;
public event EventHandler vibeclick;
+ public event EventHandler prearmclick;
Rectangle ekfhitzone = new Rectangle();
Rectangle vibehitzone = new Rectangle();
+ Rectangle prearmhitzone = new Rectangle();
protected override void OnMouseClick(MouseEventArgs e)
{
@@ -1164,6 +1174,12 @@ protected override void OnMouseClick(MouseEventArgs e)
if (vibeclick != null)
vibeclick(this, null);
}
+
+ if (prearmhitzone.IntersectsWith(new Rectangle(e.X, e.Y, 5, 5)) && !status) // Only when not armed
+ {
+ if (prearmclick != null)
+ prearmclick(this, null);
+ }
}
protected override void OnMouseMove(MouseEventArgs e)
@@ -1178,6 +1194,10 @@ protected override void OnMouseMove(MouseEventArgs e)
{
Cursor.Current = Cursors.Hand;
}
+ else if (prearmhitzone.IntersectsWith(new Rectangle(e.X, e.Y, 5, 5)) && !status) // Only when not armed
+ {
+ Cursor.Current = Cursors.Hand;
+ }
else
{
Cursor.Current = DefaultCursor;
@@ -3122,6 +3142,46 @@ internal void doPaint()
}
}
+ if (displayprearm && status == false) // not armed
+ {
+ if (displayicons)
+ {
+ var width = (fontsize + 8) * 3;
+ prearmhitzone = new Rectangle(this.Width - width * 5 + width / 2 - 7, this.Height - (fontsize*2 + 25), width * 2, fontsize + 8);
+ }
+ else
+ {
+ int x = this.Width - 24 * fontsize;
+ if (!prearmstatus) x -= 2 * fontsize;
+ // Estimate the width of the string for the hit zone
+ int width = TextRenderer.MeasureText(prearmstatus ? HUDT.ReadyToArm : HUDT.NotReadyToArm, new Font(HUDT.Font, fontsize + 2)).Width;
+ prearmhitzone = new Rectangle(x, yPos[0] - 4, width, fontsize * 2);
+ }
+
+ if (prearmstatus)
+ {
+ if (displayicons)
+ {
+ DrawImage(HUDT.prearm_green, prearmhitzone.X, prearmhitzone.Y + 2, prearmhitzone.Width, prearmhitzone.Height);
+ }
+ else
+ {
+ drawstring(HUDT.ReadyToArm, font, fontsize + 2, _whiteBrush, prearmhitzone.X, prearmhitzone.Y);
+ }
+ }
+ else
+ {
+ if (displayicons)
+ {
+ DrawImage(HUDT.prearm_red, prearmhitzone.X, prearmhitzone.Y + 2, prearmhitzone.Width, prearmhitzone.Height);
+ }
+ else
+ {
+ drawstring(HUDT.NotReadyToArm, font, fontsize + 2, (SolidBrush)Brushes.Red, prearmhitzone.X, prearmhitzone.Y);
+ }
+ }
+ }
+
if (DesignMode)
{
return;
diff --git a/ExtLibs/Controls/HUDT.Designer.cs b/ExtLibs/Controls/HUDT.Designer.cs
index d809aa7d1a..c289c4341d 100644
--- a/ExtLibs/Controls/HUDT.Designer.cs
+++ b/ExtLibs/Controls/HUDT.Designer.cs
@@ -372,6 +372,15 @@ public static System.Drawing.Bitmap nogps_wide {
}
}
+ ///
+ /// Looks up a localized string similar to Not Ready to Arm.
+ ///
+ public static string NotReadyToArm {
+ get {
+ return ResourceManager.GetString("NotReadyToArm", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to NW.
///
@@ -381,6 +390,35 @@ public static string NW {
}
}
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ public static System.Drawing.Bitmap prearm_green {
+ get {
+ object obj = ResourceManager.GetObject("prearm_green", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ public static System.Drawing.Bitmap prearm_red {
+ get {
+ object obj = ResourceManager.GetObject("prearm_red", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Ready to Arm.
+ ///
+ public static string ReadyToArm {
+ get {
+ return ResourceManager.GetString("ReadyToArm", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
diff --git a/ExtLibs/Controls/HUDT.resx b/ExtLibs/Controls/HUDT.resx
index 413fb4c088..9b90347f14 100644
--- a/ExtLibs/Controls/HUDT.resx
+++ b/ExtLibs/Controls/HUDT.resx
@@ -209,9 +209,21 @@
Resources\nogps_wide.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ Not Ready to Arm
+
NW
+
+ Resources\prearm_green.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ Resources\prearm_red.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ Ready to Arm
+
Resources\rtkfixed_wide.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
diff --git a/ExtLibs/Controls/HUDT.zh-Hans.resx b/ExtLibs/Controls/HUDT.zh-Hans.resx
index 46223b8882..523be00513 100644
--- a/ExtLibs/Controls/HUDT.zh-Hans.resx
+++ b/ExtLibs/Controls/HUDT.zh-Hans.resx
@@ -163,4 +163,10 @@
地速
+
+ 未准备解锁
+
+
+ 准备解锁
+
\ No newline at end of file
diff --git a/ExtLibs/Controls/Resources/prearm_green.png b/ExtLibs/Controls/Resources/prearm_green.png
new file mode 100644
index 0000000000..5a5a8066ea
Binary files /dev/null and b/ExtLibs/Controls/Resources/prearm_green.png differ
diff --git a/ExtLibs/Controls/Resources/prearm_red.png b/ExtLibs/Controls/Resources/prearm_red.png
new file mode 100644
index 0000000000..745177e6f8
Binary files /dev/null and b/ExtLibs/Controls/Resources/prearm_red.png differ
diff --git a/GCSViews/FlightData.Designer.cs b/GCSViews/FlightData.Designer.cs
index 03ba402205..c8e0d6a7ca 100644
--- a/GCSViews/FlightData.Designer.cs
+++ b/GCSViews/FlightData.Designer.cs
@@ -361,6 +361,7 @@ private void InitializeComponent()
this.hud1.DataBindings.Add(new System.Windows.Forms.Binding("navpitch", this.bindingSourceHud, "nav_pitch", true));
this.hud1.DataBindings.Add(new System.Windows.Forms.Binding("navroll", this.bindingSourceHud, "nav_roll", true));
this.hud1.DataBindings.Add(new System.Windows.Forms.Binding("pitch", this.bindingSourceHud, "pitch", true));
+ this.hud1.DataBindings.Add(new System.Windows.Forms.Binding("prearmstatus", this.bindingSourceHud, "prearmstatus", true));
this.hud1.DataBindings.Add(new System.Windows.Forms.Binding("roll", this.bindingSourceHud, "roll", true));
this.hud1.DataBindings.Add(new System.Windows.Forms.Binding("status", this.bindingSourceHud, "armed", true));
this.hud1.DataBindings.Add(new System.Windows.Forms.Binding("targetalt", this.bindingSourceHud, "targetalt", true));
@@ -405,6 +406,7 @@ private void InitializeComponent()
this.hud1.navpitch = 0F;
this.hud1.navroll = 0F;
this.hud1.pitch = 0F;
+ this.hud1.prearmstatus = false;
this.hud1.roll = 0F;
this.hud1.Russian = false;
this.hud1.skyColor1 = System.Drawing.Color.Blue;
@@ -425,6 +427,7 @@ private void InitializeComponent()
this.hud1.xtrack_error = 0F;
this.hud1.ekfclick += new System.EventHandler(this.hud1_ekfclick);
this.hud1.vibeclick += new System.EventHandler(this.hud1_vibeclick);
+ this.hud1.prearmclick += new System.EventHandler(this.hud1_prearmclick);
this.hud1.Load += new System.EventHandler(this.hud1_Load);
this.hud1.DoubleClick += new System.EventHandler(this.hud1_DoubleClick);
this.hud1.Resize += new System.EventHandler(this.hud1_Resize);
diff --git a/GCSViews/FlightData.cs b/GCSViews/FlightData.cs
index 6fded893dc..66a0666872 100644
--- a/GCSViews/FlightData.cs
+++ b/GCSViews/FlightData.cs
@@ -3186,6 +3186,15 @@ private void hud1_vibeclick(object sender, EventArgs e)
frm.Show();
}
+ private void hud1_prearmclick(object sender, EventArgs e)
+ {
+ PrearmStatus frm = new PrearmStatus();
+ frm.RestoreStartupLocation();
+ frm.FormClosed += (a, e2) => frm.SaveStartupLocation();
+ frm.TopMost = true;
+ frm.Show();
+ }
+
///
/// Collapses or expands MainH.Panel1 depending on no. of controls within.
/// If you add controls to SubMainLeft that can be hidden, displaced or removed, add their first parent control here.
diff --git a/MainV2.cs b/MainV2.cs
index f97ee1f080..f47946c9f1 100644
--- a/MainV2.cs
+++ b/MainV2.cs
@@ -2826,7 +2826,8 @@ private async void SerialReader()
lastmessagehigh != MainV2.comPort.MAV.cs.messageHigh &&
MainV2.comPort.MAV.cs.messageHigh != null)
{
- if (!MainV2.comPort.MAV.cs.messageHigh.StartsWith("PX4v2 "))
+ if (!MainV2.comPort.MAV.cs.messageHigh.StartsWith("PX4v2 ") &&
+ !MainV2.comPort.MAV.cs.messageHigh.StartsWith("PreArm:")) // Supress audibly repeating PreArm messages
{
MainV2.speechEngine.SpeakAsync(MainV2.comPort.MAV.cs.messageHigh);
lastmessagehigh = MainV2.comPort.MAV.cs.messageHigh;
diff --git a/MissionPlanner.csproj b/MissionPlanner.csproj
index aafd86ad95..4f7acffae5 100644
--- a/MissionPlanner.csproj
+++ b/MissionPlanner.csproj
@@ -110,6 +110,9 @@
MovingBase.cs
+
+ PrearmStatus.cs
+
PropagationSettings.cs
@@ -697,6 +700,12 @@
MavCommandSelection.cs
+
+ Form
+
+
+ PrearmStatus.cs
+
Form
diff --git a/plugins/example9-hudonoff.cs b/plugins/example9-hudonoff.cs
index f69ebf6657..41fdb649e7 100644
--- a/plugins/example9-hudonoff.cs
+++ b/plugins/example9-hudonoff.cs
@@ -26,7 +26,7 @@ public override string Name
public override string Version
{
- get { return "0.10"; }
+ get { return "0.2"; }
}
public override string Author
@@ -59,6 +59,7 @@ public override bool Loaded()
{"batteryon", "Battery"},
{"displayekf", "EKF"},
{"displayvibe", "Vibe"},
+ {"displayprearm", "Prearm Status"},
{"displayAOASSA", "AOA"},
};