Skip to content

Commit

Permalink
CurrentState: add more MAVLink2 BATTERY STATUS information display
Browse files Browse the repository at this point in the history
  • Loading branch information
mxiaogit authored and meee1 committed Jun 19, 2021
1 parent 871bf18 commit 5748b29
Showing 1 changed file with 89 additions and 0 deletions.
89 changes: 89 additions & 0 deletions ExtLibs/ArduPilot/CurrentState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,10 @@ public double battery_voltage
[DisplayText("Bat Voltage (V)")]
public double battery_voltage8 { get; set; }

[GroupText("Battery")]
[DisplayText("Bat Voltage (V)")]
public double battery_voltage9 { get; set; }

[GroupText("Battery")]
[DisplayText("Bat Remaining (%)")]
public int battery_remaining
Expand Down Expand Up @@ -1036,6 +1040,10 @@ public int battery_remaining
[DisplayText("Bat Remaining (%)")]
public int battery_remaining8 { get; set; }

[GroupText("Battery")]
[DisplayText("Bat Remaining (%)")]
public int battery_remaining9 { get; set; }

[GroupText("Battery")]
[DisplayText("Bat Current (Amps)")]
public double current
Expand Down Expand Up @@ -1096,6 +1104,10 @@ public double current2
[DisplayText("Bat8 Current (Amps)")]
public double current8 { get; set; }

[GroupText("Battery")]
[DisplayText("Bat9 Current (Amps)")]
public double current9 { get; set; }

[GroupText("Battery")]
[DisplayText("Bat Watts")]
public double watts => battery_voltage * current;
Expand All @@ -1119,8 +1131,34 @@ public double current2
[GroupText("Battery")] public double battery_cell4 { get; set; }
[GroupText("Battery")] public double battery_cell5 { get; set; }
[GroupText("Battery")] public double battery_cell6 { get; set; }
[GroupText("Battery")] public double battery_cell7 { get; set; }
[GroupText("Battery")] public double battery_cell8 { get; set; }
[GroupText("Battery")] public double battery_cell9 { get; set; }
[GroupText("Battery")] public double battery_cell10 { get; set; }
[GroupText("Battery")] public double battery_cell11 { get; set; }
[GroupText("Battery")] public double battery_cell12 { get; set; }
[GroupText("Battery")] public double battery_cell13 { get; set; }
[GroupText("Battery")] public double battery_cell14 { get; set; }

[GroupText("Battery")] public double battery_temp { get; set; }
[GroupText("Battery")] public double battery_temp2 { get; set; }
[GroupText("Battery")] public double battery_temp3 { get; set; }
[GroupText("Battery")] public double battery_temp4 { get; set; }
[GroupText("Battery")] public double battery_temp5 { get; set; }
[GroupText("Battery")] public double battery_temp6 { get; set; }
[GroupText("Battery")] public double battery_temp7 { get; set; }
[GroupText("Battery")] public double battery_temp8 { get; set; }
[GroupText("Battery")] public double battery_temp9 { get; set; }

[GroupText("Battery")] public double battery_remainmin { get; set; }
[GroupText("Battery")] public double battery_remainmin2 { get; set; }
[GroupText("Battery")] public double battery_remainmin3 { get; set; }
[GroupText("Battery")] public double battery_remainmin4 { get; set; }
[GroupText("Battery")] public double battery_remainmin5 { get; set; }
[GroupText("Battery")] public double battery_remainmin6 { get; set; }
[GroupText("Battery")] public double battery_remainmin7 { get; set; }
[GroupText("Battery")] public double battery_remainmin8 { get; set; }
[GroupText("Battery")] public double battery_remainmin9 { get; set; }

[GroupText("Battery")]
[DisplayText("Bat used EST (mah)")]
Expand Down Expand Up @@ -1150,6 +1188,9 @@ public double current2
[DisplayText("Bat used EST (mah)")]
public double battery_usedmah8 { get; set; }

[GroupText("Battery")]
[DisplayText("Bat used EST (mah)")]
public double battery_usedmah9 { get; set; }

[GroupText("Battery")]
[DisplayText("Bat2 Voltage (V)")]
Expand Down Expand Up @@ -2532,61 +2573,109 @@ private void Parent_OnPacketReceived(object sender, MAVLink.MAVLinkMessage mavLi
else battery_cell5 = 0.0;
if (bats.voltages[5] != ushort.MaxValue) battery_cell6 = bats.voltages[5] / 1000.0;
else battery_cell6 = 0.0;
if (bats.voltages[6] != ushort.MaxValue) battery_cell7 = bats.voltages[6] / 1000.0;
else battery_cell7 = 0.0;
if (bats.voltages[7] != ushort.MaxValue) battery_cell8 = bats.voltages[7] / 1000.0;
else battery_cell8 = 0.0;
if (bats.voltages[8] != ushort.MaxValue) battery_cell9 = bats.voltages[8] / 1000.0;
else battery_cell9 = 0.0;
if (bats.voltages[9] != ushort.MaxValue) battery_cell10 = bats.voltages[9] / 1000.0;
else battery_cell10 = 0.0;
if (bats.voltages_ext[0] != ushort.MaxValue) battery_cell11 = bats.voltages_ext[0] / 1000.0;
else battery_cell11 = 0.0;
if (bats.voltages_ext[1] != ushort.MaxValue) battery_cell12 = bats.voltages_ext[1] / 1000.0;
else battery_cell12 = 0.0;
if (bats.voltages_ext[2] != ushort.MaxValue) battery_cell13 = bats.voltages_ext[2] / 1000.0;
else battery_cell13 = 0.0;
if (bats.voltages_ext[3] != ushort.MaxValue) battery_cell14 = bats.voltages_ext[3] / 1000.0;
else battery_cell14 = 0.0;
}

battery_usedmah = bats.current_consumed;
battery_remaining = bats.battery_remaining;
_current = bats.current_battery / 100.0f;
if (bats.temperature != short.MaxValue)
battery_temp = bats.temperature / 100.0;
battery_remainmin = bats.time_remaining / 60.0f;
}
else if (bats.id == 1)
{
battery_usedmah2 = bats.current_consumed;
battery_remaining2 = bats.battery_remaining;
_current2 = bats.current_battery / 100.0f;
if (bats.temperature != short.MaxValue)
battery_temp2 = bats.temperature / 100.0;
battery_remainmin2 = bats.time_remaining / 60.0f;
}
else if (bats.id == 2)
{
battery_usedmah3 = bats.current_consumed;
battery_remaining3 = bats.battery_remaining;
battery_voltage3 = bats.voltages.Sum(a => a != ushort.MaxValue ? a / 1000.0 : 0);
current3 = bats.current_battery / 100.0f;
if (bats.temperature != short.MaxValue)
battery_temp3 = bats.temperature / 100.0;
battery_remainmin3 = bats.time_remaining / 60.0f;
}
else if (bats.id == 3)
{
battery_usedmah4 = bats.current_consumed;
battery_remaining4 = bats.battery_remaining;
battery_voltage4 = bats.voltages.Sum(a => a != ushort.MaxValue ? a / 1000.0 : 0);
current4 = bats.current_battery / 100.0f;
if (bats.temperature != short.MaxValue)
battery_temp4 = bats.temperature / 100.0;
battery_remainmin4 = bats.time_remaining / 60.0f;
}
else if (bats.id == 4)
{
battery_usedmah5 = bats.current_consumed;
battery_remaining5 = bats.battery_remaining;
battery_voltage5 = bats.voltages.Sum(a => a != ushort.MaxValue ? a / 1000.0 : 0);
current5 = bats.current_battery / 100.0f;
if (bats.temperature != short.MaxValue)
battery_temp5 = bats.temperature / 100.0;
battery_remainmin5 = bats.time_remaining / 60.0f;
}
else if (bats.id == 5)
{
battery_usedmah6 = bats.current_consumed;
battery_remaining6 = bats.battery_remaining;
battery_voltage6 = bats.voltages.Sum(a => a != ushort.MaxValue ? a / 1000.0 : 0);
current6 = bats.current_battery / 100.0f;
if (bats.temperature != short.MaxValue)
battery_temp6 = bats.temperature / 100.0;
battery_remainmin6 = bats.time_remaining / 60.0f;
}
else if (bats.id == 6)
{
battery_usedmah7 = bats.current_consumed;
battery_remaining7 = bats.battery_remaining;
battery_voltage7 = bats.voltages.Sum(a => a != ushort.MaxValue ? a / 1000.0 : 0);
current7 = bats.current_battery / 100.0f;
if (bats.temperature != short.MaxValue)
battery_temp7 = bats.temperature / 100.0;
battery_remainmin7 = bats.time_remaining / 60.0f;
}
else if (bats.id == 7)
{
battery_usedmah8 = bats.current_consumed;
battery_remaining8 = bats.battery_remaining;
battery_voltage8 = bats.voltages.Sum(a => a != ushort.MaxValue ? a / 1000.0 : 0);
current8 = bats.current_battery / 100.0f;
if (bats.temperature != short.MaxValue)
battery_temp8 = bats.temperature / 100.0;
battery_remainmin8 = bats.time_remaining / 60.0f;
}
else if (bats.id == 8)
{
battery_usedmah9 = bats.current_consumed;
battery_remaining9 = bats.battery_remaining;
battery_voltage9 = bats.voltages.Sum(a => a != ushort.MaxValue ? a / 1000.0 : 0);
current9 = bats.current_battery / 100.0f;
if (bats.temperature != short.MaxValue)
battery_temp9 = bats.temperature / 100.0;
battery_remainmin9 = bats.time_remaining / 60.0f;
}
}

Expand Down

0 comments on commit 5748b29

Please sign in to comment.