X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosuilib%2FAltosScanUI.java;h=031158243e69de010d475e14be13f801244c1847;hp=7b5f2c7e64b88a7730b1db46d5a85757695f2f6a;hb=cb23b992be8ba40c97d8988c134a814a13ccd58c;hpb=9557a24b02911a93d74ee29ce359e40266cb4fed diff --git a/altosuilib/AltosScanUI.java b/altosuilib/AltosScanUI.java index 7b5f2c7e..03115824 100644 --- a/altosuilib/AltosScanUI.java +++ b/altosuilib/AltosScanUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_3; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; @@ -25,7 +25,7 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_5.*; +import org.altusmetrum.altoslib_7.*; class AltosScanResult { String callsign; @@ -159,6 +159,8 @@ public class AltosScanUI Thread thread; AltosFrequency[] frequencies; int frequency_index; + int packet_count; + int tick_count; void scan_exception(Exception e) { if (e instanceof FileNotFoundException) { @@ -200,6 +202,7 @@ public class AltosScanUI AltosState state = reader.read(); if (state == null) continue; + packet_count++; if (state.flight != AltosLib.MISSING) { final AltosScanResult result = new AltosScanResult(state.callsign, state.serial, @@ -251,9 +254,6 @@ public class AltosScanUI void next() throws InterruptedException, TimeoutException { reader.set_monitor(false); - /* Let any pending input from the last configuration drain out */ - Thread.sleep(100); - if (select_rate) { boolean wrapped = false; do { @@ -284,6 +284,8 @@ public class AltosScanUI return; } } + packet_count = 0; + tick_count = 0; ++frequency_index; if (frequency_index >= frequencies.length) frequency_index = 0; @@ -308,7 +310,9 @@ public class AltosScanUI } void tick_timer() throws InterruptedException, TimeoutException { - next(); + ++tick_count; + if (packet_count == 0 || tick_count > 5) + next(); } public void actionPerformed(ActionEvent e) { @@ -360,6 +364,8 @@ public class AltosScanUI reader.set_telemetry_rate(r.rate); reader.set_frequency(r.frequency.frequency); reader.save_frequency(); + reader.save_telemetry(); + reader.save_telemetry_rate(); owner.scan_device_selected(device); } } @@ -438,6 +444,7 @@ public class AltosScanUI } public AltosScanUI(AltosUIFrame in_owner, boolean in_select_telemetry) { + super(in_owner, "Scan Telemetry", false); owner = in_owner; select_telemetry = in_select_telemetry; @@ -519,7 +526,7 @@ public class AltosScanUI rate_boxes[k].addActionListener(this); rate_boxes[k].setSelected((scanning_rate & (1 << k)) != 0); } - y_offset_rate += AltosLib.ao_telemetry_rate_max; + y_offset_rate += AltosLib.ao_telemetry_rate_max + 1; } if (select_telemetry) {