diff options
| author | Bdale Garbee <bdale@gag.com> | 2014-09-06 13:41:36 -0600 | 
|---|---|---|
| committer | Bdale Garbee <bdale@gag.com> | 2014-09-06 13:41:36 -0600 | 
| commit | 8c212cd5bfa03f71a31d84bd0051314e77d88461 (patch) | |
| tree | 5be036b3510b8b474ad829caea20fcbc75b56839 /altoslib/AltosPreferences.java | |
| parent | e9714e34091abe657aa1b30aeda9466331aa39c1 (diff) | |
| parent | dd26ec2e706bdd29090759deeb90090a0e3b74f0 (diff) | |
Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
Conflicts:
	ao-bringup/turnon_telemega
Diffstat (limited to 'altoslib/AltosPreferences.java')
| -rw-r--r-- | altoslib/AltosPreferences.java | 33 | 
1 files changed, 33 insertions, 0 deletions
| diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index 72cfeb4b..dba57dcb 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -38,6 +38,9 @@ public class AltosPreferences {  	/* telemetry rate format preference name */  	public final static String telemetryRatePreferenceFormat = "RATE-%d"; +	/* log file format preference name */ +	public final static String logfilePreferenceFormat = "LOGFILE-%d"; +  	/* voice preference name */  	public final static String voicePreference = "VOICE"; @@ -83,6 +86,9 @@ public class AltosPreferences {  	/* Telemetry rate (map serial to telemetry format) */  	public static Hashtable<Integer, Integer> telemetry_rates; +	/* Log file (map serial to logfile name) */ +	public static Hashtable<Integer, File> logfiles; +  	/* Voice preference */  	public static boolean voice; @@ -151,6 +157,10 @@ public class AltosPreferences {  	public static int launcher_channel;  	public static void init(AltosPreferencesBackend in_backend) { + +		if (backend != null) +			return; +  		backend = in_backend;  		/* Initialize logdir from preferences */ @@ -172,6 +182,8 @@ public class AltosPreferences {  		telemetry_rates = new Hashtable<Integer,Integer>(); +		logfiles = new Hashtable<Integer,File>(); +  		voice = backend.getBoolean(voicePreference, true);  		callsign = backend.getString(callsignPreference,"N0CALL"); @@ -300,6 +312,27 @@ public class AltosPreferences {  		}  	} +	public static void set_logfile(int serial, File new_logfile) { +		synchronized(backend) { +			logfiles.put(serial, new_logfile); +			backend.putString(String.format(logfilePreferenceFormat, serial), new_logfile.getPath()); +			flush_preferences(); +		} +	} + +	public static File logfile(int serial) { +		synchronized(backend) { +			if (logfiles.containsKey(serial)) +				return logfiles.get(serial); +			String logfile_string = backend.getString(String.format(logfilePreferenceFormat, serial), null); +			if (logfile_string == null) +				return null; +			File logfile = new File(logfile_string); +			logfiles.put(serial, logfile); +			return logfile; +		} +	} +  	public static void set_scanning_telemetry(int new_scanning_telemetry) {  		synchronized (backend) {  			scanning_telemetry = new_scanning_telemetry; | 
