altos/lisp: Fix uninitialized values in ao_lisp_make_const
[fw/altos] / altoslib / AltosTelemetryConfiguration.java
1 /*
2  * Copyright © 2011 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 package org.altusmetrum.altoslib_11;
20
21
22 public class AltosTelemetryConfiguration extends AltosTelemetryStandard {
23         int     device_type;
24         int     flight;
25         int     config_major;
26         int     config_minor;
27         int     apogee_delay;
28         int     main_deploy;
29         int     v_batt;
30         int     flight_log_max;
31         String  callsign;
32         String  version;
33
34         public AltosTelemetryConfiguration(int[] bytes) {
35                 super(bytes);
36
37                 device_type    = uint8(5);
38                 flight         = uint16(6);
39                 config_major   = uint8(8);
40                 config_minor   = uint8(9);
41                 v_batt         = uint16(10);
42                 apogee_delay   = uint16(10);
43                 main_deploy    = uint16(12);
44                 flight_log_max = uint16(14);
45                 callsign       = string(16, 8);
46                 version        = string(24, 8);
47         }
48
49         public void update_state(AltosState state) {
50                 super.update_state(state);
51                 state.set_device_type(device_type);
52                 state.set_flight(flight);
53                 state.set_config(config_major, config_minor, flight_log_max);
54                 if (device_type == AltosLib.product_telegps)
55                         state.set_battery_voltage(AltosConvert.tele_gps_voltage(v_batt));
56                 else
57                         state.set_flight_params(apogee_delay, main_deploy);
58
59                 state.set_callsign(callsign);
60                 state.set_firmware_version(version);
61         }
62 }