Skip to content

Commit

Permalink
improve BB validity detection
Browse files Browse the repository at this point in the history
  • Loading branch information
stronnag committed Jul 20, 2018
1 parent 05d0eaa commit 700716c
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 40 deletions.
1 change: 1 addition & 0 deletions common/mspcmd.vala
Expand Up @@ -108,6 +108,7 @@ public class MSP : Object {
TO_FRAME = (LTM_BASE + 'O'),
TN_FRAME = (LTM_BASE + 'N'),
TX_FRAME = (LTM_BASE + 'X'),
Ta_FRAME = (LTM_BASE + 'a'), // private, amps message
Tq_FRAME = (LTM_BASE + 'q'), // private, quit message
Tx_FRAME = (LTM_BASE + 'x'), // private, quit message

Expand Down
5 changes: 5 additions & 0 deletions common/serial-device.vala
Expand Up @@ -703,10 +703,15 @@ public class MWSerial : Object
needed = (uint16) MSize.LTM_XFRAME;
cmd = MSP.Cmds.TX_FRAME;
break;
// Lower case are 'private'
case 'q':
needed = 2;
cmd = MSP.Cmds.Tq_FRAME;
break;
case 'a':
needed = 2;
cmd = MSP.Cmds.Ta_FRAME;
break;
case 'x':
needed = 1;
cmd = MSP.Cmds.Tx_FRAME;
Expand Down
33 changes: 26 additions & 7 deletions mwp/dialogs.vala
Expand Up @@ -95,11 +95,16 @@ public class Units : GLib.Object
public class OdoView : GLib.Object
{
private Gtk.Dialog dialog;
private Gtk.Label odospeed;
private Gtk.Label ododist;
private Gtk.Label odotime;
private Gtk.Label odospeed;
private Gtk.Label odospeed_u;
private Gtk.Label ododist;
private Gtk.Label ododist_u;
private Gtk.Label odorange;
private Gtk.Label odorange_u;
private Gtk.Label odoalt;
private Gtk.Label odoamps;
private Gtk.Label odoalt_u;
private Gtk.Button odoclose;
private uint to = 15;
private uint tid = 0;
Expand All @@ -108,11 +113,16 @@ public class OdoView : GLib.Object
public OdoView(Gtk.Builder builder, Gtk.Window? w, uint _to)
{
dialog = builder.get_object ("odoview") as Gtk.Dialog;
odotime = builder.get_object ("odotime") as Gtk.Label;
ododist = builder.get_object ("ododist") as Gtk.Label;
odospeed = builder.get_object ("odospeed") as Gtk.Label;
ododist_u = builder.get_object ("ododist_u") as Gtk.Label;
odospeed = builder.get_object ("odospeed") as Gtk.Label;
odospeed_u = builder.get_object ("odospeed_u") as Gtk.Label;
odotime = builder.get_object ("odotime") as Gtk.Label;
odorange = builder.get_object ("odorange") as Gtk.Label;
odorange_u = builder.get_object ("odorange_u") as Gtk.Label;
odoalt = builder.get_object ("odoalt") as Gtk.Label;
odoamps = builder.get_object ("odoamps") as Gtk.Label;
odoalt_u = builder.get_object ("odoalt_u") as Gtk.Label;
odoclose = builder.get_object ("odoclose") as Gtk.Button;
dialog.set_transient_for(w);
to = _to;
Expand All @@ -129,11 +139,20 @@ public class OdoView : GLib.Object

public void display(Odostats o, bool autohide=false)
{
ododist.label = " %.0f ".printf(Units.distance(o.distance));
odospeed.label = " %.1f ".printf(Units.speed(o.speed));
odotime.label = " %u:%02u ".printf(o.time / 60, o.time % 60);
ododist_u.label = Units.distance_units();
odospeed.label = " %.1f ".printf(Units.speed(o.speed));
odospeed_u.label = Units.speed_units();
ododist.label = " %.0f ".printf(Units.distance(o.distance));
ododist_u.label = Units.distance_units();
odorange.label = " %.0f ".printf(Units.distance(o.range));
odorange_u.label = Units.distance_units();
odoalt.label = " %.0f ".printf(Units.distance(o.alt));
odoalt_u.label = Units.distance_units();
if(o.amps > 0)
odoamps.label = " %.2f ".printf(o.amps);
else
odoamps.label = "N/A";

unhide();
if(autohide)
{
Expand Down
157 changes: 132 additions & 25 deletions mwp/mwp.ui
Expand Up @@ -3438,7 +3438,7 @@ Also aborts mission if the next waypoint distance is more than this number.</pro
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
Expand All @@ -3450,9 +3450,61 @@ Also aborts mission if the next waypoint distance is more than this number.</pro
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="ododist_u">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">metres</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="odospeed_u">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">m/s</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="ododist">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="hexpand">False</property>
<property name="label" translatable="yes">0</property>
<property name="justify">right</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="odospeed">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="hexpand">False</property>
<property name="label" translatable="yes">0</property>
<property name="justify">right</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
Expand All @@ -3462,84 +3514,139 @@ Also aborts mission if the next waypoint distance is more than this number.</pro
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="ododist_u">
<object class="GtkLabel" id="odotime">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">metres</property>
<property name="hexpand">False</property>
<property name="label" translatable="yes">0:00</property>
<property name="justify">right</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="odospeed_u">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Maximum Range</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="odorange">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">m/s</property>
<property name="label" translatable="yes">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="odorange_u">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">metres</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Maximum Altitude</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">2</property>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="ododist">
<object class="GtkLabel" id="odoalt">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="hexpand">False</property>
<property name="label" translatable="yes">0</property>
<property name="justify">right</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="odoalt_u">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">metres</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">mm:ss</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="odospeed">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Maximum Amps</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="odoamps">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="hexpand">False</property>
<property name="label" translatable="yes">0</property>
<property name="justify">right</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="odotime">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="hexpand">False</property>
<property name="label" translatable="yes">0:00</property>
<property name="justify">right</property>
<property name="label" translatable="yes">Amps</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="left_attach">2</property>
<property name="top_attach">5</property>
</packing>
</child>
</object>
Expand Down
26 changes: 22 additions & 4 deletions mwp/mwp.vala
Expand Up @@ -54,6 +54,9 @@ public struct Odostats
double speed;
double distance;
uint time;
double alt;
double range;
double amps;
}

public struct VersInfo
Expand Down Expand Up @@ -1567,9 +1570,11 @@ public class MWPlanner : Gtk.Application {
zoomer.adjustment.value = (int)val;

get_map_size();
if(craft != null && (!msp.available || !gpsfix))
if (replayer != Player.BBOX)
craft.park();
/* 2018-07-20 --- not sure why this exists
* if(craft != null && (!msp.available || !gpsfix))
* if (replayer != Player.BBOX)
* craft.park();
*/
});

zoomer.adjustment.value_changed.connect (() =>
Expand Down Expand Up @@ -3054,7 +3059,8 @@ public class MWPlanner : Gtk.Application {
radstatus.annul();
if (armed == 1)
{
odo.speed = odo.distance = odo.time = 0;
odo = {0};
odo.alt = -9999;
reboot_status();
init_craft_icon();
if(!no_trail)
Expand Down Expand Up @@ -3134,6 +3140,11 @@ public class MWPlanner : Gtk.Application {
odo.distance += ddm;
if (spd > odo.speed)
odo.speed = spd;
if(NavStatus.cg.range > odo.range)
odo.range = NavStatus.cg.range;
double estalt = (double)NavStatus.alti.estalt/100.0;
if (estalt > odo.alt)
odo.alt = estalt;
}

private void reset_poller()
Expand Down Expand Up @@ -5365,6 +5376,13 @@ public class MWPlanner : Gtk.Application {
odo.time = val;
break;

case MSP.Cmds.Ta_FRAME:
uint16 val = *(((uint16*)raw));
double amps = val/100.0;
if (amps > odo.amps)
odo.amps = amps;
break;

case MSP.Cmds.Tx_FRAME:
if (replayer != Player.NONE)
{
Expand Down

0 comments on commit 700716c

Please sign in to comment.