diff options
author | Keith Packard <keithp@keithp.com> | 2014-05-02 13:53:08 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2014-05-02 13:53:08 -0700 |
commit | 2dfc4bc92b11252f17103f28198a702a3fdc2b2d (patch) | |
tree | 8bceb5e35f4c40a8767da1926c0044dcfc36ee1c /altoslib | |
parent | 027b1470c7a2d007eaab5c8d49f772b0c7559b80 (diff) |
altosui: Add configuration UI for beeper tone
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib')
-rw-r--r-- | altoslib/AltosConfigData.java | 18 | ||||
-rw-r--r-- | altoslib/AltosConfigValues.java | 4 | ||||
-rw-r--r-- | altoslib/AltosConvert.java | 12 |
3 files changed, 34 insertions, 0 deletions
diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index edaf4601..750faa71 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -70,6 +70,9 @@ public class AltosConfigData implements Iterable<String> { /* HAS_APRS */ public int aprs_interval; + /* HAS_BEEP */ + public int beep; + /* Storage info replies */ public int storage_size; public int storage_erase_unit; @@ -210,6 +213,8 @@ public class AltosConfigData implements Iterable<String> { aprs_interval = -1; + beep = -1; + storage_size = -1; storage_erase_unit = -1; stored_flight = 0; @@ -286,6 +291,9 @@ public class AltosConfigData implements Iterable<String> { /* HAS_APRS */ try { aprs_interval = get_int(line, "APRS interval:"); } catch (Exception e) {} + /* HAS_BEEP */ + try { beep = get_int(line, "Beeper setting:"); System.out.printf ("beeper now %d\n", beep); } catch (Exception e) {} + /* Storage info replies */ try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {} try { storage_erase_unit = get_int(line, "Storage erase unit:"); } catch (Exception e) {} @@ -409,8 +417,13 @@ public class AltosConfigData implements Iterable<String> { if (npyro > 0) pyros = source.pyros(); + /* HAS_APRS */ if (aprs_interval >= 0) aprs_interval = source.aprs_interval(); + + /* HAS_BEEP */ + if (beep >= 0) + beep = source.beep(); } public void set_values(AltosConfigValues dest) { @@ -449,6 +462,7 @@ public class AltosConfigData implements Iterable<String> { else dest.set_pyros(null); dest.set_aprs_interval(aprs_interval); + dest.set_beep(beep); } public void save(AltosLink link, boolean remote) throws InterruptedException, TimeoutException { @@ -515,6 +529,10 @@ public class AltosConfigData implements Iterable<String> { if (aprs_interval >= 0) link.printf("c A %d\n", aprs_interval); + /* HAS_BEEP */ + if (beep >= 0) + link.printf("c b %d\n", beep); + link.printf("c w\n"); link.flush_output(); } diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index 4aa55d6a..1a9fddbf 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -76,4 +76,8 @@ public interface AltosConfigValues { public abstract int aprs_interval(); public abstract void set_aprs_interval(int new_aprs_interval); + + public abstract int beep(); + + public abstract void set_beep(int new_beep); } diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 35923ec3..4ed45c68 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -359,4 +359,16 @@ public class AltosConvert { csum += data[i + start]; return csum & 0xff; } + + public static double beep_value_to_freq(int value) { + if (value == 0) + return 4000; + return 1.0/2.0 * (24.0e6/32.0) / (double) value; + } + + public static int beep_freq_to_value(double freq) { + if (freq == 0) + return 94; + return (int) Math.floor (1.0/2.0 * (24.0e6/32.0) / freq + 0.5); + } } |