Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
403 | ligi | 1 | /********************************************* |
2 | * |
||
3 | * class representing the DebugData Structure |
||
4 | * |
||
5 | * Author: Marcus -LiGi- Bueschleb |
||
6 | * |
||
7 | * see README for further Infos |
||
8 | * |
||
9 | ********************************************/ |
||
181 | ligi | 10 | |
164 | ligi | 11 | public class MKDebugData |
12 | |||
13 | { |
||
14 | |||
208 | ligi | 15 | public int[] analog; |
502 | ligi | 16 | public String[] names; |
17 | public boolean[] got_name; |
||
208 | ligi | 18 | public int motor_complete=-1; |
19 | |||
164 | ligi | 20 | |
208 | ligi | 21 | private int i; |
22 | |||
23 | public int motor_val(int id) { return analog[12+id]; } |
||
221 | ligi | 24 | public int nick_int() { return analog[1]; } |
25 | public int roll_int() { return analog[2]; } |
||
26 | public int accnick() { return analog[3]; } |
||
27 | public int accroll() { return analog[4]; } |
||
208 | ligi | 28 | |
29 | |||
475 | ligi | 30 | public int UBatt() { return analog[9]; } |
31 | public int SenderOkay() { return analog[10]; } |
||
221 | ligi | 32 | |
475 | ligi | 33 | |
34 | |||
35 | |||
208 | ligi | 36 | public MKDebugData() |
181 | ligi | 37 | { |
502 | ligi | 38 | names=new String[32]; |
210 | ligi | 39 | analog=new int[32]; |
502 | ligi | 40 | got_name=new boolean[32]; |
210 | ligi | 41 | for (i=0;i<32;i++) |
502 | ligi | 42 | { |
181 | ligi | 43 | analog[i]=-1; |
502 | ligi | 44 | names[i]="-#"+i+"->"; |
45 | got_name[i]=false; |
||
46 | } |
||
181 | ligi | 47 | |
48 | } |
||
49 | |||
502 | ligi | 50 | public void set_names_by_mk_data(int id,int[] in_arr) |
51 | { |
||
52 | names[id]=""; |
||
53 | for (i=0;i<16;i++) |
||
54 | { |
||
55 | if ((char)in_arr[i]!=' ') |
||
56 | names[id]+=(char)in_arr[i]; |
||
57 | got_name[id]=true; |
||
58 | } |
||
59 | names[id]+=":"; |
||
60 | } |
||
61 | |||
210 | ligi | 62 | public void set_by_mk_data(int[] in_arr,MKVersion version) |
164 | ligi | 63 | { |
64 | |||
210 | ligi | 65 | if (version.compare(-1,-1)==version.VERSION_EQUAL) |
66 | return; |
||
208 | ligi | 67 | |
210 | ligi | 68 | if (version.compare(0,60)==version.VERSION_PREVIOUS) |
69 | { |
||
475 | ligi | 70 | for (i=0;i<32;i++) |
221 | ligi | 71 | { |
72 | analog[i]=(int)((in_arr[1+i*2]<<8) | in_arr[2+i*2]); |
||
73 | if ((analog[i]&(2<<14))!=0) |
||
74 | analog[i]=-(analog[i]&(0xFFFF-1))^(0xFFFF-1); |
||
75 | } |
||
210 | ligi | 76 | } |
77 | else |
||
78 | { |
||
79 | for (i=0;i<16;i++) |
||
221 | ligi | 80 | { |
81 | analog[i]=(int)((in_arr[17+i*2]<<8) | in_arr[18+i*2]); |
||
82 | if ((analog[i]&(2<<14))!=0) |
||
83 | analog[i]=-(analog[i]&(0xFFFF-1))^(0xFFFF-1); |
||
84 | } |
||
210 | ligi | 85 | } |
164 | ligi | 86 | |
208 | ligi | 87 | motor_complete=motor_val(0)+motor_val(1)+motor_val(2)+motor_val(3); |
210 | ligi | 88 | |
89 | |||
164 | ligi | 90 | } |
91 | |||
92 | |||
210 | ligi | 93 | |
164 | ligi | 94 | } |