X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosui%2FAltosPreferences.java;h=7510c7c2b289e51782aef2fa8ed48df668122a4b;hb=97663f922e236f4ee7bd08277ca80d419b5cd10f;hp=8609f94e8c4f2a1b93971f11e1628a396d7fe9a2;hpb=0e3e4f9c1e6a6bf972514f12c9d622258aa2aec2;p=fw%2Faltos diff --git a/altosui/AltosPreferences.java b/altosui/AltosPreferences.java index 8609f94e..7510c7c2 100644 --- a/altosui/AltosPreferences.java +++ b/altosui/AltosPreferences.java @@ -26,7 +26,7 @@ import javax.swing.*; import javax.swing.filechooser.FileSystemView; class AltosPreferences { - static Preferences preferences; + public static Preferences preferences; /* logdir preference name */ final static String logdirPreference = "LOGDIR"; @@ -52,12 +52,18 @@ class AltosPreferences { /* serial debug preference name */ final static String serialDebugPreference = "SERIAL-DEBUG"; + /* scanning telemetry preferences name */ + final static String scanningTelemetryPreference = "SCANNING-TELEMETRY"; + + /* Launcher serial preference name */ + final static String launcherSerialPreference = "LAUNCHER-SERIAL"; + + /* Launcher channel preference name */ + final static String launcherChannelPreference = "LAUNCHER-CHANNEL"; + /* Default logdir is ~/TeleMetrum */ final static String logdirName = "TeleMetrum"; - /* UI Component to pop dialogs up */ - static Component component; - /* Log directory */ static File logdir; @@ -82,6 +88,9 @@ class AltosPreferences { /* Serial debug */ static boolean serial_debug; + /* Scanning telemetry */ + static int scanning_telemetry; + /* List of frequencies */ final static String common_frequencies_node_name = "COMMON-FREQUENCIES"; static AltosFrequency[] common_frequencies; @@ -130,6 +139,9 @@ class AltosPreferences { node.put(String.format(description_format, i), frequencies[i].description); } } + static int launcher_serial; + + static int launcher_channel; public static void init() { preferences = Preferences.userRoot().node("/org/altusmetrum/altosui"); @@ -156,6 +168,12 @@ class AltosPreferences { callsign = preferences.get(callsignPreference,"N0CALL"); + scanning_telemetry = preferences.getInt(scanningTelemetryPreference,(1 << Altos.ao_telemetry_standard)); + + launcher_serial = preferences.getInt(launcherSerialPreference, 0); + + launcher_channel = preferences.getInt(launcherChannelPreference, 0); + String firmwaredir_string = preferences.get(firmwaredirPreference, null); if (firmwaredir_string != null) firmwaredir = new File(firmwaredir_string); @@ -166,24 +184,23 @@ class AltosPreferences { AltosSerial.set_debug(serial_debug); common_frequencies = load_common_frequencies(); + } static { init(); } - static void set_component(Component in_component) { - component = in_component; - } - static void flush_preferences() { try { preferences.flush(); } catch (BackingStoreException ee) { +/* if (component != null) JOptionPane.showMessageDialog(component, preferences.absolutePath(), "Cannot save prefernces", JOptionPane.ERROR_MESSAGE); else +*/ System.err.printf("Cannot save preferences\n"); } } @@ -199,41 +216,6 @@ class AltosPreferences { } } - private static boolean check_dir(File dir) { - if (!dir.exists()) { - if (!dir.mkdirs()) { - JOptionPane.showMessageDialog(component, - dir.getName(), - "Cannot create directory", - JOptionPane.ERROR_MESSAGE); - return false; - } - } else if (!dir.isDirectory()) { - JOptionPane.showMessageDialog(component, - dir.getName(), - "Is not a directory", - JOptionPane.ERROR_MESSAGE); - return false; - } - return true; - } - - /* Configure the log directory. This is where all telemetry and eeprom files - * will be written to, and where replay will look for telemetry files - */ - public static void ConfigureLog() { - JFileChooser logdir_chooser = new JFileChooser(logdir.getParentFile()); - - logdir_chooser.setDialogTitle("Configure Data Logging Directory"); - logdir_chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - - if (logdir_chooser.showDialog(component, "Select Directory") == JFileChooser.APPROVE_OPTION) { - File dir = logdir_chooser.getSelectedFile(); - if (check_dir(dir)) - set_logdir(dir); - } - } - public static File logdir() { return logdir; } @@ -279,6 +261,18 @@ class AltosPreferences { return telemetry; } + public static void set_scanning_telemetry(int new_scanning_telemetry) { + scanning_telemetry = new_scanning_telemetry; + synchronized (preferences) { + preferences.putInt(scanningTelemetryPreference, scanning_telemetry); + flush_preferences(); + } + } + + public static int scanning_telemetry() { + return scanning_telemetry; + } + public static void set_voice(boolean new_voice) { voice = new_voice; synchronized (preferences) { @@ -328,6 +322,32 @@ class AltosPreferences { return serial_debug; } + public static void set_launcher_serial(int new_launcher_serial) { + launcher_serial = new_launcher_serial; + System.out.printf("set launcher serial to %d\n", new_launcher_serial); + synchronized (preferences) { + preferences.putInt(launcherSerialPreference, launcher_serial); + flush_preferences(); + } + } + + public static int launcher_serial() { + return launcher_serial; + } + + public static void set_launcher_channel(int new_launcher_channel) { + launcher_channel = new_launcher_channel; + System.out.printf("set launcher channel to %d\n", new_launcher_channel); + synchronized (preferences) { + preferences.putInt(launcherChannelPreference, launcher_channel); + flush_preferences(); + } + } + + public static int launcher_channel() { + return launcher_channel; + } + public static Preferences bt_devices() { return preferences.node("bt_devices"); }