altosui: Catch attempt to set radio frequency to 0.0 -- use default
authorKeith Packard <keithp@keithp.com>
Wed, 28 Mar 2012 04:48:43 +0000 (21:48 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 28 Mar 2012 04:48:43 +0000 (21:48 -0700)
Monitor idle was setting the frequency to 0, which takes a while with
the new native radio frequency setting code. Don't do that, instead
pull out the preferred frequency for that, as is done in other places
where a frequency of 0.0 is used.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosSerial.java

index ff1a91a5dedb1206e95376cff310bbad31b7b7bf..dffc74ea25be0a831dc7a415810b48954fddf779 100644 (file)
@@ -380,6 +380,8 @@ public class AltosSerial implements Runnable {
                                        int cal) {
                if (debug)
                        System.out.printf("set_radio_frequency %7.3f (freq %b) (set %b) %d\n", frequency, has_frequency, has_setting, cal);
+               if (frequency == 0)
+                       return;
                if (has_frequency)
                        set_radio_freq((int) Math.floor (frequency * 1000));
                else if (has_setting)
@@ -390,6 +392,8 @@ public class AltosSerial implements Runnable {
 
        public void set_radio_frequency(double in_frequency) throws InterruptedException, TimeoutException {
                frequency = in_frequency;
+               if (frequency == 0.0)
+                       frequency = AltosPreferences.frequency(device.getSerial());
                config_data();
                set_radio_frequency(frequency,
                                    config_data.radio_frequency != 0,