import javax.swing.filechooser.FileSystemView;
class AltosPreferences {
- static Preferences preferences;
+ public static Preferences preferences;
/* logdir preference name */
final static String logdirPreference = "LOGDIR";
/* 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;
/* 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;
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");
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);
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");
}
}
}
}
- 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;
}
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) {
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");
}