Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 230 → Rev 231

/branches/ligi_j2me/README
35,6 → 35,9
* 0.24 - adding some GFX
* 0.25 - adding Graph ( Nick int;Roll int; nick acc ;roll acc)
* 0.26 - more Visuals
* 0.27 - implemented motor_test
* 0.28 - Icon
* 0.29 - ressources for 176x220 / Ress differencing
*
* Online Link to this Document:
* http://mikrocontroller.cco-ev.de/mikroviewvc/FlightCtrl/branches/ligi_j2me/README?view=markup
63,19 → 66,31
- ANT
Usage:
KEY 1..X to select device
KEY UP to go Page up in MK-LCD
KEY DOWN to go Page up in MK-LCD
KEY # toggle Fullscreen
KEY * to Quit
General:
KEY # toggle Fullscreen
KEY * to Quit
 
Device selection Screen:
KEY 1..X to select device
Main Screen:
KEY UP to go Page up in MK-LCD
KEY DOWN to go Page up in MK-LCD
KEY RIGHT - go to MotorTest
MotorTest Screen
UP/DOWN increas/decrease speed of actual motor
LEFT prev motor ( if first go to main screen )
RIGHT next motor
Tested on:
SE - K800i
Nokia - N95
SE - W800i
Nokia 6234
Nokia N80 ( Font is too Big - but API worx)
6230i ( without copter )
N95 ( without copter )
Nokia - 6234
Nokia - N80 ( Font is too Big - but API worx)
Nokia - 6230i ( without copter )
 
ToDo:
- Proxying to TCP/IP ( GPRS / UMTS / WLAN ( e.g. N80) .. )
/branches/ligi_j2me/build.props
0,0 → 1,2
screensize=176x220
 
/branches/ligi_j2me/build.xml
3,7 → 3,9
 
<property name="project_name" value="MKMiniMidlet"/> <!-- jar filename -->
 
<property name="res_dir" location="${basedir}/res"/>
<property file="build.props"/>
 
<property name="res_dir" location="${basedir}/res/${screensize}"/>
<property name="build_dir" location="${basedir}/build/"/>
<property name="lib_dir" location="${basedir}/lib/"/>
<property name="src_dir" location="${basedir}/src/"/>
17,23 → 19,23
<target name="build">
<wtkbuild destdir="${build_dir}/classes" srcdir="${src_dir}" target="1.1" preverify="true"/>
<wtkjad
jadfile="${build_dir}/bin/${project_name}.jad"
jarfile="${build_dir}/bin/${project_name}.jar"
jadfile="${build_dir}/bin/${project_name}_${screensize}.jad"
jarfile="${build_dir}/bin/${project_name}_${screensize}.jar"
update="false"
manifest="${build_dir}/bin/MANIFEST.MF"
name="${project_name}"
vendor="LiGi"
version="0.26">
version="0.29">
<attribute name="MIDletX-No-Command" value="true"/>
 
<midlet name="${project_name}" class="${project_name}" />
<attribute name="MIDlet-Icon" value="i.png"/>
<midlet name="${project_name}" class="${project_name}" icon="i.png" />
<!-- !!TODO!! Remove Icon JAD entry if no icon is there -->
</wtkjad>
<wtkpackage
jarfile="${build_dir}/bin/${project_name}.jar"
jadfile="${build_dir}/bin/${project_name}.jad"
jarfile="${build_dir}/bin/${project_name}_${screensize}.jar"
jadfile="${build_dir}/bin/${project_name}_${screensize}.jad"
basedir="${build_dir}/classes"
manifest="${build_dir}/bin/MANIFEST.MF"
obfuscate="true"
50,14 → 52,11
<target name="clean">
<delete dir="${build_dir}"/>
<delete dir="${res_dir}"/>
 
<tstamp/>
<mkdir dir="${build_dir}"/>
<mkdir dir="${build_dir}/classes"/>
<mkdir dir="${build_dir}/bin"/>
<mkdir dir="${res_dir}"/>
</target>
 
/branches/ligi_j2me/res/bg.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/branches/ligi_j2me/res/load.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/branches/ligi_j2me/res/lcd.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/branches/ligi_j2me/res/bt.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/branches/ligi_j2me/res/176x220/bg.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/branches/ligi_j2me/res/176x220/bt.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/branches/ligi_j2me/res/176x220/i.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/branches/ligi_j2me/res/176x220/lcd.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/branches/ligi_j2me/res/176x220/load.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/branches/ligi_j2me/res/240x320/bg.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/branches/ligi_j2me/res/240x320/bt.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/branches/ligi_j2me/res/240x320/i.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/branches/ligi_j2me/res/240x320/lcd.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/branches/ligi_j2me/res/240x320/load.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/branches/ligi_j2me/src/BTSearcher.java
28,37 → 28,20
 
public final int MAX_DEVICES=10;
 
 
public RemoteDevice[] remote_devices;
public int remote_device_count=0;
public String[] remote_device_name;
public String[] remote_device_mac;
 
 
public void search_again()
{
try
{
remote_device_count=0;
searching=true;
m_DscrAgent.startInquiry(DiscoveryAgent.GIAC,this);
}
catch (BluetoothStateException ex)
{
error=true;
err_log+="Problem in searching the blue tooth devices\n" + ex;
}
 
}
 
public BTSearcher()
{
 
remote_devices=new RemoteDevice[MAX_DEVICES];
remote_device_name=new String[MAX_DEVICES];
remote_device_mac=new String[MAX_DEVICES];
 
 
remote_device_count=0;
try
{
//First get the local device and obtain the discovery agent.
65,6 → 48,7
m_LclDevice = LocalDevice.getLocalDevice();
m_DscrAgent= m_LclDevice.getDiscoveryAgent();
m_DscrAgent.startInquiry(DiscoveryAgent.GIAC,this);
}
catch (BluetoothStateException ex)
{
72,17 → 56,32
err_log+="Problem in searching the blue tooth devices\n" + ex;
}
search_again();
}
 
 
public void inquiryCompleted(int transID) {
 
try {
for(int i=0;i<remote_device_count;i++)
{
remote_device_name[i]=remote_devices[i].getFriendlyName(true);
remote_device_mac[i]=remote_devices[i].getBluetoothAddress();
 
}
}
catch (Exception e)
{
err_log+="Problem in searching the blue tooth devices";
}
searching=false;
}
 
 
public void search_again()
{
}
 
//Called when device is found during inquiry
public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod)
{
90,9 → 89,7
{
if (remote_device_count!=(MAX_DEVICES-1))
{
 
remote_device_name[remote_device_count]=btDevice.getFriendlyName(true);
remote_device_mac[remote_device_count]=btDevice.getBluetoothAddress();
remote_devices[remote_device_count]=btDevice;
remote_device_count++;
}
}
/branches/ligi_j2me/src/MKCommunicator.java
1,23 → 1,15
/*********************************************************************************************************************************
* *
* Abstaction Layer to Communicate via J2ME and Bluetooth with the FlightCtrl of the MikroKopter Project (www.mikrokopter.de ) *
* *
* Author: Marcus -LiGi- Bueschleb *
* Project-Start: 9/2007 *
* Version: 0.07 *
* Mailto: ligi@smart4mobile.de *
* Licence: Creative Commons / Non Commercial *
* Big Up: Holger&Ingo *
* ChangeLog: *
* 0.01 - initial Version ( initialize connection / main Thread with reading data from MK) *
* 0.02 - reconnect after connection loss ( e.g. switching on/off ) *
* 0.03 - added send_command ( with CRC ) *
* 0.04 - added decode64 to decode 'pseudo' BASE64 *
* 0.05 - added get_version *
* 0.06 - added parsing of DebugData *
* 0.07 - Code-(Doc&&Cleanup) && initial svn commit *
* *
*********************************************************************************************************************************/
/**********************************************************************************************
*
* Abstaction Layer to Communicate via J2ME and Bluetooth with the FlightCtrl of the MikroKopter Project (www.mikrokopter.de )
*
* Author: Marcus -LiGi- Bueschleb
* Project-Start: 9/2007
* Version: 0.07
* Mailto: ligi@smart4mobile.de
* Licence: Creative Commons / Non Commercial
* Big Up: Holger&Ingo
*
************************************************************************************************/
import javax.microedition.io.*;
import java.io.*;
134,6 → 126,12
}
 
 
public void motor_test(int[] params)
{
send_command(0,'t',params);
}
 
 
// send command to FC ( add crc and pack into pseudo Base64
public void send_command(int modul,char cmd,int[] params)
{
144,9 → 142,9
for(int param_pos=0;param_pos<(params.length/3 + (params.length%3==0?0:1)) ;param_pos++)
{
int a = (param_pos<params.length)?params[param_pos]:0;
int b = ((param_pos+1)<params.length)?params[param_pos+1]:0;
int c = ((param_pos+2)<params.length)?params[param_pos+2]:0;
int a = (param_pos*3<params.length)?params[param_pos*3]:0;
int b = ((param_pos*3+1)<params.length)?params[param_pos*3+1]:0;
int c = ((param_pos*3+2)<params.length)?params[param_pos*3+2]:0;
 
send_buff[3+param_pos*4] = (char)((a >> 2)+'=' );
send_buff[3+param_pos*4+1] = (char)('=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4)));
/branches/ligi_j2me/src/MKMiniCanvas.java
1,13 → 1,13
/*********************************************************************************************************************************
* *
* minimal canvas to test Abstraction layer on various Phones *
* *
* Author: Marcus -LiGi- Bueschleb *
* Project-Start: 9/2007 *
* Mailto: ligi@smart4mobile.de *
* Licence: Creative Commons / Non Commercial *
* Big Up: Holger&Ingo *
*********************************************************************************************************************************/
/***************************************************************
*
* minimal canvas to test Abstraction layer on various Phones
*
* Author: Marcus -LiGi- Bueschleb
* Project-Start: 9/2007
* Mailto: ligi@smart4mobile.de
* Licence: Creative Commons / Non Commercial
* Big Up: Holger&Ingo
***************************************************************/
 
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
14,8 → 14,8
 
 
public class MKMiniCanvas
extends Canvas
implements Runnable
extends Canvas
implements Runnable
{
 
45,63 → 45,63
public int line_middle_y;
 
public MKMiniCanvas(MKMiniMidlet _root)
{
{
 
root=_root;
root=_root;
 
try
{
lcd_img=Image.createImage("/lcd.png");
bt_img=Image.createImage("/bt.png");
bg_img=Image.createImage("/bg.jpg");
load_img=Image.createImage("/load.png");
}
catch (Exception e)
{
err+=e.toString();
}
try
{
lcd_img=Image.createImage("/lcd.png");
bt_img=Image.createImage("/bt.png");
bg_img=Image.createImage("/bg.jpg");
load_img=Image.createImage("/load.png");
}
catch (Exception e)
{
err+=e.toString();
}
 
nick_line_pos_data=new int[bg_img.getWidth()];
roll_line_pos_data=new int[bg_img.getWidth()];
accnick_line_pos_data=new int[bg_img.getWidth()];
accroll_line_pos_data=new int[bg_img.getWidth()];
nick_line_pos_data=new int[bg_img.getWidth()];
roll_line_pos_data=new int[bg_img.getWidth()];
accnick_line_pos_data=new int[bg_img.getWidth()];
accroll_line_pos_data=new int[bg_img.getWidth()];
for (int c=0;c<bg_img.getWidth();c++)
{
nick_line_pos_data[c]=-1;
roll_line_pos_data[c]=-1;
accnick_line_pos_data[c]=-1;
accroll_line_pos_data[c]=-1;
}
for (int c=0;c<bg_img.getWidth();c++)
{
nick_line_pos_data[c]=-1;
roll_line_pos_data[c]=-1;
accnick_line_pos_data[c]=-1;
accroll_line_pos_data[c]=-1;
}
// mk = new MKCommunicator("btspp://000BCE016B5B:1");
//connect_mk("btspp://000BCE016B4F:1");
// mk = new MKCommunicator("btspp://000BCE016B5B:1");
//connect_mk("btspp://000BCE016B4F:1");
 
try
{
RecordStore recStore = RecordStore.openRecordStore("bturl", true );
try
{
RecordStore recStore = RecordStore.openRecordStore("bturl", true );
 
if (recStore.getNumRecords()==1)
{
byte[] recData = new byte[recStore.getRecordSize(1)];
int len = recStore.getRecord(1, recData, 0);
rescan=false;
connect_mk(new String(recData, 0, len));
}
}
catch (Exception e)
if (recStore.getNumRecords()==1)
{
err+=e.toString();
byte[] recData = new byte[recStore.getRecordSize(1)];
int len = recStore.getRecord(1, recData, 0);
rescan=false;
connect_mk(new String(recData, 0, len));
}
}
catch (Exception e)
{
err+=e.toString();
}
 
if (mk==null) bt_scanner = new BTSearcher();
if (mk==null) bt_scanner = new BTSearcher();
new Thread(this).start();
new Thread(this).start();
 
}
}
 
boolean quit=false;
boolean rescan=true;
117,6 → 117,9
 
while(true)
{
repaint();
serviceRepaints();
 
long loopStartTime = System.currentTimeMillis();
long sleeptime=0;
// ticked thing
123,11 → 126,33
frame_pos++;
 
 
switch(state)
{
case STATEID_MOTORTEST:
 
if (motor_test_sel_all)
for (int m=0;m<4;m++)
{
motor_test[m]+=act_motor_increase;
if (motor_test[m]<0)motor_test[m]=0;
}
else
{
motor_test[act_motor]+=act_motor_increase;
if (motor_test[act_motor]<0)motor_test[act_motor]=0;
}
 
mk.motor_test(motor_test);
break;
}
 
try {
nick_line_pos_data[-bg_offset] = mk.debug_data.nick_int();
roll_line_pos_data[-bg_offset] = mk.debug_data.roll_int();
accnick_line_pos_data[-bg_offset] = mk.debug_data.accnick();
accroll_line_pos_data[-bg_offset] = mk.debug_data.accroll();
nick_line_pos_data[-bg_offset] = mk.debug_data.nick_int();
roll_line_pos_data[-bg_offset] = mk.debug_data.roll_int();
accnick_line_pos_data[-bg_offset] = mk.debug_data.accnick();
accroll_line_pos_data[-bg_offset] = mk.debug_data.accroll();
}
catch (Exception e)
{
161,23 → 186,29
}
if (rescan)
{
if (mk!=null) mk.close_connections(true);
mk=null;
bt_scanner.search_again();
if (mk!=null) mk.close_connections(true);
mk=null;
bt_scanner.search_again();
}
 
rescan=false;
bg_offset--;
if (bg_offset==-bg_img.getWidth())
bg_offset=0;
com.nokia.mid.ui.DeviceControl.setLights(0,100);
//bt.tick();
// every state has sth to do in tick section
try {
rescan=false;
bg_offset--;
if (bg_offset==-bg_img.getWidth())
bg_offset=0;
com.nokia.mid.ui.DeviceControl.setLights(0,100);
//bt.tick();
// every state has sth to do in tick section
}
catch (Exception e)
{
}
 
// System.gc();
repaint();
serviceRepaints();
// System.gc();
 
sleeptime=1000/ 15 - (int) (System.currentTimeMillis()- loopStartTime);
184,12 → 215,12
if (sleeptime<0)
sleeptime=100; // everyone has fi sleep
sleeptime=100; // everyone has fi sleep
try { Thread.sleep(sleeptime); }
catch (Exception e)
{
err="Problem Sleeping ";
err="Problem Sleeping ";
}
 
}
197,131 → 228,157
 
 
public int state=-1;
public final static int STATEID_MOTORTEST=2;
 
int local_max=-1;
 
int[] motor_test = {0,0,0,0};
 
// drawing section
public void paint(Graphics g) {
 
try {
if (mk!=null)
{
line_middle_y=this.getHeight()/2;
if (local_max<Math.abs(mk.debug_data.nick_int()))
local_max=Math.abs(mk.debug_data.nick_int());
if (local_max<Math.abs(mk.debug_data.roll_int()))
local_max=Math.abs(mk.debug_data.roll_int());
if (local_max<Math.abs(mk.debug_data.accnick()))
local_max=Math.abs(mk.debug_data.accnick());
if (local_max<Math.abs(mk.debug_data.accroll()))
local_max=Math.abs(mk.debug_data.accroll());
line_scaler= local_max/(this.getHeight()/2)+1;
}
int spacer=(g.getFont().getHeight());
g.setColor(0xFFFFFF);
g.fillRect(0,0,this.getWidth(),this.getHeight());
g.drawImage(bg_img,bg_offset,0, g.TOP | g.LEFT);
if (bg_offset+bg_img.getWidth()<this.getWidth())
g.drawImage(bg_img,bg_offset+bg_img.getWidth(),0, g.TOP | g.LEFT);
if (mk!=null)
{
line_middle_y=this.getHeight()/2;
if (local_max<Math.abs(mk.debug_data.nick_int()))
local_max=Math.abs(mk.debug_data.nick_int());
if (local_max<Math.abs(mk.debug_data.roll_int()))
local_max=Math.abs(mk.debug_data.roll_int());
if (local_max<Math.abs(mk.debug_data.accnick()))
local_max=Math.abs(mk.debug_data.accnick());
if (local_max<Math.abs(mk.debug_data.accroll()))
local_max=Math.abs(mk.debug_data.accroll());
line_scaler= local_max/(this.getHeight()/2)+1;
}
int spacer=(g.getFont().getHeight());
g.setColor(0xFFFFFF);
g.fillRect(0,0,this.getWidth(),this.getHeight());
g.drawImage(bg_img,bg_offset,0, g.TOP | g.LEFT);
 
g.setColor(0x000000);
if (bg_offset+bg_img.getWidth()<this.getWidth())
g.drawImage(bg_img,bg_offset+bg_img.getWidth(),0, g.TOP | g.LEFT);
 
 
 
 
switch(state)
{
case STATEID_MOTORTEST:
for (int bar=0;bar<4;bar++)
{
g.setColor(((bar==act_motor)|motor_test_sel_all)?0x44CC44:0x4444DD);
g.fillRect(this.getWidth()/(8*2)+bar*2*this.getWidth()/8,10,this.getWidth()/8,20+motor_test[bar]);
g.setColor(0x000000);
g.drawString(""+motor_test[bar] ,this.getWidth()/8+bar*2*this.getWidth()/8,10,Graphics.TOP | Graphics.HCENTER);
if(bar!=4) g.drawString(""+mk.debug_data.motor_val(bar) ,this.getWidth()/8+bar*2*this.getWidth()/8,30,Graphics.TOP | Graphics.HCENTER);
}
break;
 
default:
g.setColor(0x000000);
if (mk==null)
{
if (mk==null)
{
 
if (bt_scanner.searching)
{
if (bt_scanner.searching)
{
 
g.drawString("scanning for BT-Devices",this.getWidth()/2,this.getHeight()/2+load_img.getHeight()/8,Graphics.TOP | Graphics.HCENTER);
g.drawString("scanning for BT-Devices",this.getWidth()/2,this.getHeight()/2+load_img.getHeight()/8,Graphics.TOP | Graphics.HCENTER);
 
g.setClip(this.getWidth()/2-load_img.getWidth()/6,this.getHeight()/2-load_img.getHeight()/8, load_img.getWidth()/4,load_img.getHeight()/3);;
g.drawImage(load_img,this.getWidth()/2-load_img.getWidth()/8 - ((((frame_pos/3)%12)%4)*(load_img.getWidth()/4)) ,this.getHeight()/2-load_img.getHeight()/6- ((((frame_pos/3)%12)/4)*(load_img.getHeight()/3)), g.TOP | g.LEFT);
g.drawImage(bt_img,this.getWidth()/2 ,this.getHeight()/2 , g.HCENTER | g.VCENTER);
}
else
{
g.drawString("Press key 0-"+(bt_scanner.remote_device_count-1) + " to continue" ,0,0,Graphics.TOP | Graphics.LEFT);
for (int i=0;i<bt_scanner.remote_device_count;i++)
g.drawString("#"+i+">" + bt_scanner.remote_device_name[i]+"("+bt_scanner.remote_device_mac[i]+")",0,spacer+spacer*i,Graphics.TOP | Graphics.LEFT);
g.setClip(this.getWidth()/2-load_img.getWidth()/6,this.getHeight()/2-load_img.getHeight()/8, load_img.getWidth()/4,load_img.getHeight()/3);;
g.drawImage(load_img,this.getWidth()/2-load_img.getWidth()/8 - ((((frame_pos/3)%12)%4)*(load_img.getWidth()/4)) ,this.getHeight()/2-load_img.getHeight()/6- ((((frame_pos/3)%12)/4)*(load_img.getHeight()/3)), g.TOP | g.LEFT);
g.drawImage(bt_img,this.getWidth()/2 ,this.getHeight()/2 , g.HCENTER | g.VCENTER);
}
else
{
g.drawString("Press key 0-"+(bt_scanner.remote_device_count-1) + " to continue" ,0,0,Graphics.TOP | Graphics.LEFT);
for (int i=0;i<bt_scanner.remote_device_count;i++)
g.drawString("#"+i+">" + bt_scanner.remote_device_name[i]+"("+bt_scanner.remote_device_mac[i]+")",0,spacer+spacer*i,Graphics.TOP | Graphics.LEFT);
}
}
 
 
 
 
}
else // MK is connected
{
int y_off=0;
}
else // MK is connected
{
int y_off=0;
 
g.drawString(mk.version.str+"(d:"+mk.debug_data_count+ " l:" + mk.lcd_data_count+ " v:" + mk.version_data_count+" o:"+mk.other_data_count+")",0,y_off,Graphics.TOP | Graphics.LEFT);
g.drawString(mk.version.str+"(d:"+mk.debug_data_count+ " l:" + mk.lcd_data_count+ " v:" + mk.version_data_count+" o:"+mk.other_data_count+")",0,y_off,Graphics.TOP | Graphics.LEFT);
 
y_off+=spacer;
y_off+=spacer;
 
g.drawString("n:"+mk.debug_data.nick_int() + " r:"+mk.debug_data.roll_int() + " an:"+mk.debug_data.accnick() + " ar:"+mk.debug_data.accroll() ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.drawString("n:"+mk.debug_data.nick_int() + " r:"+mk.debug_data.roll_int() + " an:"+mk.debug_data.accnick() + " ar:"+mk.debug_data.accroll() ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
 
g.drawString("m1:"+mk.debug_data.motor_val(0) + " m2:"+mk.debug_data.motor_val(1)+" m3:"+mk.debug_data.motor_val(2) + " m4:"+mk.debug_data.motor_val(3) ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.drawString("m1:"+mk.debug_data.motor_val(0) + " m2:"+mk.debug_data.motor_val(1)+" m3:"+mk.debug_data.motor_val(2) + " m4:"+mk.debug_data.motor_val(3) ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
 
if (mk.connected)
{
g.drawString("time conn:" +((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s" ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.drawString("time motor>15:" +(mk_stat.motor_on_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.drawString("time motor=15:" +(mk_stat.motor_stand_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT);
}
if (mk.connected)
{
g.drawString("time conn:" +((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s" ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.drawString("time motor>15:" +(mk_stat.motor_on_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.drawString("time motor=15:" +(mk_stat.motor_stand_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT);
}
 
 
y_off=this.getHeight()-4*19;
y_off=this.getHeight()-4*lcd_img.getHeight();
 
for ( int foo=0;foo<4;foo++)
{
for (int x=0;x<20;x++)
{
g.setClip(12*x,y_off,12,19);
g.drawImage(lcd_img,12*x-(mk.LCD.LCD_str[foo].charAt(x)-' ')*(lcd_img.getWidth()/95),y_off, g.TOP | g.LEFT);
for ( int foo=0;foo<4;foo++)
{
for (int x=0;x<20;x++)
{
g.setClip((lcd_img.getWidth()/222)*x,y_off,(lcd_img.getWidth()/222),lcd_img.getHeight());
g.drawImage(lcd_img,(lcd_img.getWidth()/222)*x-(mk.LCD.LCD_str[foo].charAt(x)-' ')*(lcd_img.getWidth()/222),y_off, g.TOP | g.LEFT);
 
}
y_off+=19;
}
y_off+=lcd_img.getHeight();
}
 
g.setClip(0,0,this.getWidth(),this.getHeight());
 
}
 
g.setClip(0,0,this.getWidth(),this.getHeight());
 
 
 
}
// draw lines
}
// draw lines
 
for ( int x=0;x<this.getWidth();x++)
for ( int x=0;x<this.getWidth();x++)
 
{
{
 
int p= (((-bg_offset+x-this.getWidth()-5)));
if (p<1)
p+=bg_img.getWidth();
p%=(bg_img.getWidth()-1);
int p= (((-bg_offset+x-this.getWidth()-5)));
if (p<1)
p+=bg_img.getWidth();
p%=(bg_img.getWidth()-1);
 
g.setColor(0x156315);
draw_graph_part(g,x,nick_line_pos_data[p]/line_scaler,nick_line_pos_data[p+1]/line_scaler);
g.setColor(0xCC1315);
draw_graph_part(g,x,roll_line_pos_data[p]/line_scaler,roll_line_pos_data[p+1]/line_scaler);
g.setColor(0xf8ef02);
draw_graph_part(g,x,accnick_line_pos_data[p]/line_scaler,accnick_line_pos_data[p+1]/line_scaler);
g.setColor(0x19194d);
draw_graph_part(g,x,accroll_line_pos_data[p]/line_scaler,accroll_line_pos_data[p+1]/line_scaler);
g.setColor(0x156315);
draw_graph_part(g,x,nick_line_pos_data[p]/line_scaler,nick_line_pos_data[p+1]/line_scaler);
g.setColor(0xCC1315);
draw_graph_part(g,x,roll_line_pos_data[p]/line_scaler,roll_line_pos_data[p+1]/line_scaler);
g.setColor(0xf8ef02);
draw_graph_part(g,x,accnick_line_pos_data[p]/line_scaler,accnick_line_pos_data[p+1]/line_scaler);
g.setColor(0x19194d);
draw_graph_part(g,x,accroll_line_pos_data[p]/line_scaler,accroll_line_pos_data[p+1]/line_scaler);
 
}
}
 
}
 
} catch (Exception e) {}
}
 
private void connect_mk(String url)
343,41 → 400,99
/*********************************************** input Section **********************************************/
// keys
public boolean fullscreen=false;
public int act_motor=0;
public int act_motor_increase=0;
public boolean motor_test_sel_all=false;
 
public void chg_state(int _state)
{
state=_state;
}
 
 
public void keyReleased(int keyCode)
{
switch(state)
{
case STATEID_MOTORTEST:
act_motor_increase=0;
break;
}
 
}
 
public void keyPressed(int keyCode)
{
if ((mk==null)&&(keyCode >= this.KEY_NUM0) && (keyCode < this.KEY_NUM0+bt_scanner.remote_device_count))
connect_mk("btspp://"+bt_scanner.remote_device_mac[keyCode-this.KEY_NUM0] + ":1");
else
switch(state)
{
switch (keyCode)
{
case STATEID_MOTORTEST:
switch (getGameAction (keyCode))
{
case UP:
act_motor_increase=-1;
break;
case KEY_STAR:
mk.other_data_count=23;
quit=true;
break;
case DOWN:
act_motor_increase=1;
break;
 
case KEY_POUND:
//rescan=true;
fullscreen=!fullscreen;
setFullScreenMode(fullscreen);
break;
}
switch (getGameAction (keyCode))
case FIRE:
motor_test_sel_all=!motor_test_sel_all;
break;
 
case LEFT:
act_motor--;
if (act_motor<0) {act_motor=0; chg_state(-1); }
break;
 
case RIGHT:
act_motor++;
act_motor%=4;
break;
}
 
break;
 
default:
if ((mk==null)&&(keyCode >= this.KEY_NUM0) && (keyCode < this.KEY_NUM0+bt_scanner.remote_device_count))
connect_mk("btspp://"+bt_scanner.remote_device_mac[keyCode-this.KEY_NUM0] + ":1");
else
{
case UP:
mk.LCD.LCD_PREVPAGE();
break;
switch (keyCode)
{
case DOWN:
mk.LCD.LCD_NEXTPAGE();
break;
case KEY_STAR:
mk.other_data_count=23;
quit=true;
break;
 
case KEY_POUND:
//rescan=true;
fullscreen=!fullscreen;
setFullScreenMode(fullscreen);
break;
}
switch (getGameAction (keyCode))
{
case UP:
mk.LCD.LCD_PREVPAGE();
break;
case DOWN:
mk.LCD.LCD_NEXTPAGE();
break;
 
case RIGHT:
state=STATEID_MOTORTEST;
break;
}
}
 
}
return;
}