X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=ao-tools%2Faltosui%2FAltosPreferences.java;h=e2a3df3b7717bb5b92f9cf150706bdc49a7ecbb3;hp=526275635ff07b90960aa3bd74aeaa8e402a5f13;hb=81e7b43ecad666e2e2310c7c94184f888bc86585;hpb=b9623f8ef26491e9fa14e2478295fe6f5cbbd87f diff --git a/ao-tools/altosui/AltosPreferences.java b/ao-tools/altosui/AltosPreferences.java index 52627563..e2a3df3b 100644 --- a/ao-tools/altosui/AltosPreferences.java +++ b/ao-tools/altosui/AltosPreferences.java @@ -32,7 +32,7 @@ class AltosPreferences { final static String logdirPreference = "LOGDIR"; /* channel preference name */ - final static String channelPreference = "CHANNEL"; + final static String channelPreferenceFormat = "CHANNEL-%d"; /* voice preference name */ final static String voicePreference = "VOICE"; @@ -52,8 +52,8 @@ class AltosPreferences { /* Log directory */ static File logdir; - /* Telemetry channel */ - static int channel; + /* Channel (map serial to channel) */ + static Hashtable channels; /* Voice preference */ static boolean voice; @@ -80,7 +80,7 @@ class AltosPreferences { logdir.mkdirs(); } - channel = preferences.getInt(channelPreference, 0); + channels = new Hashtable(); voice = preferences.getBoolean(voicePreference, true); @@ -151,15 +151,19 @@ class AltosPreferences { return logdir; } - public static void set_channel(int new_channel) { - channel = new_channel; + public static void set_channel(int serial, int new_channel) { + channels.put(serial, new_channel); synchronized (preferences) { - preferences.putInt(channelPreference, channel); + preferences.putInt(String.format(channelPreferenceFormat, serial), new_channel); flush_preferences(); } } - public static int channel() { + public static int channel(int serial) { + if (channels.containsKey(serial)) + return channels.get(serial); + int channel = preferences.getInt(String.format(channelPreferenceFormat, serial), 0); + channels.put(serial, channel); return channel; }