X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosui%2FAltosPreferences.java;h=d4df4e163efecaf18462fc0f49fce012564f138a;hb=72a04d679d06aaad9c2b4297fefd585fc393ce2e;hp=e2a3df3b7717bb5b92f9cf150706bdc49a7ecbb3;hpb=f01096c4b42f9a4720ed0414826c2a283a992545;p=fw%2Faltos diff --git a/altosui/AltosPreferences.java b/altosui/AltosPreferences.java index e2a3df3b..d4df4e16 100644 --- a/altosui/AltosPreferences.java +++ b/altosui/AltosPreferences.java @@ -43,6 +43,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,6 +55,9 @@ class AltosPreferences { /* Log directory */ static File logdir; + /* Map directory -- hangs of logdir */ + static File mapdir; + /* Channel (map serial to channel) */ static Hashtable channels; @@ -64,6 +70,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,6 +88,9 @@ class AltosPreferences { if (!logdir.exists()) logdir.mkdirs(); } + mapdir = new File(logdir, "maps"); + if (!mapdir.exists()) + mapdir.mkdirs(); channels = new Hashtable(); @@ -91,6 +103,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 +121,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 +169,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) { @@ -202,4 +224,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; + } }