return ignite / 32767 * 15.0;
}
- static double
- radio_setting_to_frequency(int setting, int cal) {
+ static double radio_to_frequency(int freq, int setting, int cal, int channel) {
double f;
- f = 434.550 * setting / cal;
- /* Round to nearest 50KHz */
- f = Math.floor (20.0 * f + 0.5) / 20.0;
- return f;
+ if (freq > 0)
+ f = freq / 1000.0;
+ else {
+ if (setting <= 0)
+ setting = cal;
+ f = 434.550 * setting / cal;
+ /* Round to nearest 50KHz */
+ f = Math.floor (20.0 * f + 0.5) / 20.0;
+ }
+ return f + channel * 0.100;
}
- static int
- radio_frequency_to_setting(double frequency, int cal) {
+ static int radio_frequency_to_setting(double frequency, int cal) {
double set = frequency / 434.550 * cal;
return (int) Math.floor (set + 0.5);
}
- static double
- radio_channel_to_frequency(int channel) {
- return 434.550 + channel * 0.100;
- }
-
- static int
- radio_frequency_to_channel(double frequency) {
+ static int radio_frequency_to_channel(double frequency) {
int channel = (int) Math.floor ((frequency - 434.550) / 0.100 + 0.5);
if (channel < 0)
channel = 9;
return channel;
}
+
+ static double radio_channel_to_frequency(int channel) {
+ return 434.550 + channel * 0.100;
+ }
+
+ static int[] ParseHex(String line) {
+ String[] tokens = line.split("\\s+");
+ int[] array = new int[tokens.length];
+
+ for (int i = 0; i < tokens.length; i++)
+ try {
+ array[i] = Integer.parseInt(tokens[i], 16);
+ } catch (NumberFormatException ne) {
+ return null;
+ }
+ return array;
+ }
+
+ static double meters_to_feet(double meters) {
+ return meters * (100 / (2.54 * 12));
+ }
+
+ static double meters_to_mach(double meters) {
+ return meters / 343; /* something close to mach at usual rocket sites */
+ }
+
+ static double meters_to_g(double meters) {
+ return meters / 9.80665;
+ }
+
+ static int checksum(int[] data, int start, int length) {
+ int csum = 0x5a;
+ for (int i = 0; i < length; i++)
+ csum += data[i + start];
+ return csum & 0xff;
+ }
}