Rev 31 |
Blame |
Last modification |
View Log
| RSS feed
/*********************************************
*
* class representing the DebugData Structure
*
* Author: Marcus -LiGi- Bueschleb
*
* see README for further Infos
*
********************************************/
public class MKDebugData
{
public int[] analog
;
public String[] names
;
public boolean[] got_name
;
public int motor_complete=-
1;
private int i
;
public int motor_val
(int id
) { return analog
[12+id
]; }
public int nick_int
() { return analog
[0]; }
public int roll_int
() { return analog
[1]; }
public int accnick
() { return analog
[2]; }
public int accroll
() { return analog
[3]; }
public int UBatt
() { return analog
[9]; }
public int SenderOkay
() { return analog
[10]; }
public MKDebugData
()
{
names=
new String[32];
analog=
new int[32];
got_name=
new boolean[32];
for (i=
0;i
<32;i++
)
{
analog
[i
]=-
1;
names
[i
]=
"-#"+i+
"->";
got_name
[i
]=
false;
}
}
public void set_names_by_mk_data
(int id,
int[] in_arr
)
{
names
[id
]=
"";
for (i=
0;i
<16;i++
)
{
if ((char)in_arr
[i
]!=
' ')
names
[id
]+=
(char)in_arr
[i
];
got_name
[id
]=
true;
}
names
[id
]+=
":";
}
public void set_by_mk_data
(int[] in_arr,MKVersion version
)
{
if (version.
compare(-
1,-
1)==version.
VERSION_EQUAL)
return;
if (version.
compare(0,
60)==version.
VERSION_PREVIOUS)
{
for (i=
0;i
<32;i++
)
{
//analog[i]=(int)((in_arr[1+i*2]<<8) | in_arr[2+i*2]);
analog
[i
]=
(int)((in_arr
[3+i
*2]<<8) | in_arr
[2+i
*2]);
if ((analog
[i
]&(1<<15))!=
0)
analog
[i
]=-
(analog
[i
]&(0xFFFF-
1))^
(0xFFFF-
1);
}
}
else
{
for (i=
0;i
<16;i++
)
{
analog
[i
]=
(int)((in_arr
[17+i
*2]<<8) | in_arr
[18+i
*2]);
if ((analog
[i
]&(1<<15))!=
0)
analog
[i
]=-
(analog
[i
]&(0xFFFF-
1))^
(0xFFFF-
1);
}
}
motor_complete=motor_val
(0)+motor_val
(1)+motor_val
(2)+motor_val
(3);
}
}