X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosPreferences.java;h=5f82765569dae85f0a69211c41bc0d1ed04b119f;hp=e2a3df3b7717bb5b92f9cf150706bdc49a7ecbb3;hb=573edcd7dfe10ac3251396eae88eece55d82bcb6;hpb=3fbefb3eea981d34a09496cf8abf0119de2e35bf diff --git a/altosui/AltosPreferences.java b/altosui/AltosPreferences.java index e2a3df3b..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"; @@ -43,6 +46,9 @@ class AltosPreferences { /* firmware directory preference name */ final static String firmwaredirPreference = "FIRMWARE"; + /* serial debug preference name */ + final static String serialDebugPreference = "SERIAL-DEBUG"; + /* Default logdir is ~/TeleMetrum */ final static String logdirName = "TeleMetrum"; @@ -52,9 +58,15 @@ class AltosPreferences { /* Log directory */ static File logdir; + /* Map directory -- hangs of logdir */ + static File mapdir; + /* Channel (map serial to channel) */ static Hashtable channels; + /* Telemetry (map serial to telemetry format) */ + static Hashtable telemetries; + /* Voice preference */ static boolean voice; @@ -64,6 +76,9 @@ class AltosPreferences { /* Firmware directory */ static File firmwaredir; + /* Serial debug */ + static boolean serial_debug; + public static void init(Component ui) { preferences = Preferences.userRoot().node("/org/altusmetrum/altosui"); @@ -79,9 +94,14 @@ class AltosPreferences { if (!logdir.exists()) logdir.mkdirs(); } + mapdir = new File(logdir, "maps"); + if (!mapdir.exists()) + mapdir.mkdirs(); channels = new Hashtable(); + telemetries = new Hashtable(); + voice = preferences.getBoolean(voicePreference, true); callsign = preferences.get(callsignPreference,"N0CALL"); @@ -91,6 +111,9 @@ class AltosPreferences { firmwaredir = new File(firmwaredir_string); else firmwaredir = null; + + serial_debug = preferences.getBoolean(serialDebugPreference, false); + AltosSerial.set_debug(serial_debug); } static void flush_preferences() { @@ -106,6 +129,9 @@ class AltosPreferences { public static void set_logdir(File new_logdir) { logdir = new_logdir; + mapdir = new File(logdir, "maps"); + if (!mapdir.exists()) + mapdir.mkdirs(); synchronized (preferences) { preferences.put(logdirPreference, logdir.getPath()); flush_preferences(); @@ -151,6 +177,10 @@ class AltosPreferences { return logdir; } + public static File mapdir() { + return mapdir; + } + public static void set_channel(int serial, int new_channel) { channels.put(serial, new_channel); synchronized (preferences) { @@ -167,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) { @@ -202,4 +249,17 @@ class AltosPreferences { public static File firmwaredir() { return firmwaredir; } + + public static void set_serial_debug(boolean new_serial_debug) { + serial_debug = new_serial_debug; + AltosSerial.set_debug(serial_debug); + synchronized (preferences) { + preferences.putBoolean(serialDebugPreference, serial_debug); + flush_preferences(); + } + } + + public static boolean serial_debug() { + return serial_debug; + } }