summaryrefslogtreecommitdiff
path: root/altosui/AltosPreferences.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-03-24 08:08:43 +0900
committerKeith Packard <keithp@keithp.com>2011-03-24 08:08:43 +0900
commit7f5b5848ad6ef5c808638a29c3dc0101b56ed11e (patch)
treec85d6936a17ee4533cc8b41e29e59acd1e93d47c /altosui/AltosPreferences.java
parentf3e68341f6f5daaf26dd162e4f9a06c29988986a (diff)
altosui: Add telemetry format menu and preferences
Switches the TeleDongle between full and tiny telemetry packet formats, saving the last used format for each teledongle in the application preferences. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosPreferences.java')
-rw-r--r--altosui/AltosPreferences.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/altosui/AltosPreferences.java b/altosui/AltosPreferences.java
index d4df4e16..5f827655 100644
--- a/altosui/AltosPreferences.java
+++ b/altosui/AltosPreferences.java
@@ -34,6 +34,9 @@ class AltosPreferences {
/* channel preference name */
final static String channelPreferenceFormat = "CHANNEL-%d";
+ /* telemetry format preference name */
+ final static String telemetryPreferenceFormat = "TELEMETRY-%d";
+
/* voice preference name */
final static String voicePreference = "VOICE";
@@ -61,6 +64,9 @@ class AltosPreferences {
/* Channel (map serial to channel) */
static Hashtable<Integer, Integer> channels;
+ /* Telemetry (map serial to telemetry format) */
+ static Hashtable<Integer, Integer> telemetries;
+
/* Voice preference */
static boolean voice;
@@ -94,6 +100,8 @@ class AltosPreferences {
channels = new Hashtable<Integer,Integer>();
+ telemetries = new Hashtable<Integer,Integer>();
+
voice = preferences.getBoolean(voicePreference, true);
callsign = preferences.get(callsignPreference,"N0CALL");
@@ -189,6 +197,23 @@ class AltosPreferences {
return channel;
}
+ public static void set_telemetry(int serial, int new_telemetry) {
+ telemetries.put(serial, new_telemetry);
+ synchronized (preferences) {
+ preferences.putInt(String.format(telemetryPreferenceFormat, serial), new_telemetry);
+ flush_preferences();
+ }
+ }
+
+ public static int telemetry(int serial) {
+ if (telemetries.containsKey(serial))
+ return telemetries.get(serial);
+ int telemetry = preferences.getInt(String.format(telemetryPreferenceFormat, serial),
+ Altos.ao_telemetry_full);
+ telemetries.put(serial, telemetry);
+ return telemetry;
+ }
+
public static void set_voice(boolean new_voice) {
voice = new_voice;
synchronized (preferences) {