summaryrefslogtreecommitdiff
path: root/altoslib
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-01-10 21:48:12 -0800
committerKeith Packard <keithp@keithp.com>2013-01-10 21:48:12 -0800
commit1ed6b13e87c1cc2d6618b6ba3a293ea6e3b5752e (patch)
tree10adf6f3c6b6c1ed2bf7540a9972fe72253cfa81 /altoslib
parentacff2f466031fd1a8533fc315411c3734a8bacc6 (diff)
parentd409417ff8e9ed9d406bf1c04542a4ecb574768b (diff)
Merge remote-tracking branch 'origin/micropeak-logging'
Diffstat (limited to 'altoslib')
-rw-r--r--altoslib/AltosPreferences.java21
-rw-r--r--altoslib/AltosSpeed.java6
-rw-r--r--altoslib/AltosUnitsListener.java22
-rw-r--r--altoslib/Makefile.am1
4 files changed, 47 insertions, 3 deletions
diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java
index 47196d6e..e50b9b5c 100644
--- a/altoslib/AltosPreferences.java
+++ b/altoslib/AltosPreferences.java
@@ -367,6 +367,8 @@ public class AltosPreferences {
set_common_frequencies(new_frequencies);
}
+ static LinkedList<AltosUnitsListener> units_listeners;
+
public static boolean imperial_units() {
synchronized(backend) {
return AltosConvert.imperial_units;
@@ -379,5 +381,24 @@ public class AltosPreferences {
backend.putBoolean(unitsPreference, imperial_units);
flush_preferences();
}
+ if (units_listeners != null) {
+ for (AltosUnitsListener l : units_listeners) {
+ l.units_changed(imperial_units);
+ }
+ }
+ }
+
+ public static void register_units_listener(AltosUnitsListener l) {
+ synchronized(backend) {
+ if (units_listeners == null)
+ units_listeners = new LinkedList<AltosUnitsListener>();
+ units_listeners.add(l);
+ }
+ }
+
+ public static void unregister_units_listener(AltosUnitsListener l) {
+ synchronized(backend) {
+ units_listeners.remove(l);
+ }
}
}
diff --git a/altoslib/AltosSpeed.java b/altoslib/AltosSpeed.java
index af63ed17..4e2daf5a 100644
--- a/altoslib/AltosSpeed.java
+++ b/altoslib/AltosSpeed.java
@@ -21,19 +21,19 @@ public class AltosSpeed extends AltosUnits {
public double value(double v) {
if (AltosConvert.imperial_units)
- return AltosConvert.meters_to_feet(v);
+ return AltosConvert.meters_to_mph(v);
return v;
}
public String show_units() {
if (AltosConvert.imperial_units)
- return "ft/s";
+ return "mph";
return "m/s";
}
public String say_units() {
if (AltosConvert.imperial_units)
- return "feet per second";
+ return "miles per hour";
return "meters per second";
}
diff --git a/altoslib/AltosUnitsListener.java b/altoslib/AltosUnitsListener.java
new file mode 100644
index 00000000..50a00cdf
--- /dev/null
+++ b/altoslib/AltosUnitsListener.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosLib;
+
+public interface AltosUnitsListener {
+ public void units_changed(boolean imperial_units);
+}
diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am
index 0086bc65..1b03c925 100644
--- a/altoslib/Makefile.am
+++ b/altoslib/Makefile.am
@@ -69,6 +69,7 @@ AltosLib_JAVA = \
$(SRC)/AltosTelemetryRecordSensor.java \
$(SRC)/AltosTelemetryRecordMegaSensor.java \
$(SRC)/AltosTelemetryRecordMegaData.java \
+ $(SRC)/AltosUnitsListener.java \
$(SRC)/AltosMs5607.java \
$(SRC)/AltosIMU.java \
$(SRC)/AltosMag.java \