Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 148 → Rev 149

/DUBwise/src/J2ME/build.rb
18,9 → 18,15
case ARGV[0]
when "test"
screensizes=["240x320"]
# screensizes=["176x220"]
voice_modes=["en_speedy"]
when "n80"
 
screensizes=["340x400"]
voice_modes=["en_speedy"]
else
screensizes=["128x128","176x220","240x320"]
screensizes=["128x128","176x220","240x320","340x400","480x640"]
voice_modes=["no_voice","de_tts","de_64kbit_tts","en_speedy","wav"]
end
/DUBwise/src/J2ME/build.xml
2,7 → 2,7
<property name="wtk.home" value="/home/ligi/tools/WTK2.2/"/>
 
<property name="project_name" value="DUBwise"/> <!-- jar filename -->
<property name="project_version" value="0.44"/>
<property name="project_version" value="0.47"/>
 
<property file="build.props"/>
 
17,7 → 17,7
 
<property name="wtk.midp.version" value="2.0"/>
 
<property name="wtk.midpapi" value="${lib_dir}/classes.zip"/>
<property name="wtk.midpapi" value="${lib_dir}/classes_with_fileapi.zip"/>
<target name="build">
<wtkpreprocess version="2" srcdir="${src_dir}" destdir="${preprocessed_src_dir}" symbols="VERSION=${project_version},voice_mode=${voice_mode}" verbose="false"/>
42,7 → 42,7
jadfile="${build_dir}/bin/${basename}.jad"
basedir="${build_dir}/classes"
manifest="${build_dir}/bin/MANIFEST.MF"
obfuscate="true"
obfuscate="false"
preverify="true">
<fileset dir="${res_dir}/">
<include name="*"/>
/DUBwise/src/J2ME/src/DUBwiseCanvas.java
14,11 → 14,66
import javax.microedition.media.*;
import javax.microedition.media.control.*;
 
 
// for fileapi
import javax.microedition.io.*;
import javax.microedition.midlet.*;
import javax.microedition.io.file.*;
 
import java.io.*;
import java.util.*;
 
 
// end for fileapi
 
public class DUBwiseCanvas
extends Canvas
implements Runnable,DUBwiseDefinitions
{
 
// for fileapi
public final static int MAX_FILELIST_LENGTH=100;
public final static int MAX_PATH_DEPTH=10;
// String act_path="";
// String last_path="";
 
byte act_path_depth=0;
String[] act_path_arr;
 
 
public String act_path()
{
String res="";
for (int i=0;i<act_path_depth;i++)
res+=act_path_arr[i];
return res;
}
 
String[] file_list;
int file_list_length=0;
 
 
int[] act_proxy_ip={192,168,1,42,4242}; // { ip , ip , ip , ip , port }
int[] act_connection_ip={192,168,1,42,4242}; // { ip , ip , ip , ip , port }
 
 
int ipinput_pos=0;
// end for fileapi
 
public String ip_digit_zeroes(int digit)
{ return "" + digit/100 + "" + (digit/10)%10 + "" + (digit)%10; }
 
public String ip_str(int[] ip,boolean with_zeroes)
{
if(with_zeroes)
return ip_digit_zeroes(ip[0]) + "." +ip_digit_zeroes(ip[1]) + "."+ip_digit_zeroes(ip[2]) + "."+ip_digit_zeroes(ip[3]) + ":"+ip_digit_zeroes(ip[4]) ;
else
return ip[0]+"."+ip[1]+"."+ip[2]+"."+ip[3]+":"+ip[4];
}
 
int heading_offset=0;
int act_wp;
 
// name/handle for the recordStore to memorize some stuff
43,7 → 98,7
 
public boolean do_vibra=true;
public boolean do_sound=true;
public boolean do_graph=true;
public boolean do_scrollbg=true;
public boolean keep_lighton=false;
 
private Image bg_img;
50,6 → 105,7
private Image bt_img;
private Image lcd_img;
private Image load_img;
private Image symbols_img;
 
 
public boolean fullscreen=false;
65,6 → 121,15
byte act_skin=SKINID_DARK;
 
 
public final static int MAX_GRAPHS=4;
 
public final static int[] graph_colors={0x156315,0xCC1315,0xf8ef02,0x19194d};
 
public int[] graph_sources={0,1,2,3};
public String[] graph_names={"nick int","roll int","nick acc","roll acc"};
 
public int[][] graph_data;
 
public int[] nick_line_pos_data;
public int[] roll_line_pos_data;
 
87,13 → 152,11
 
boolean quit=false;
boolean rescan=true;
int bg_offset=0;
int bg_offset=0;
 
// variable to hold the current state
public int state=-1;
 
int local_max=-1;
 
int y_off=0;
104,6 → 167,7
 
String[] menu_items;
int[] menu_actions;
int act_menu_select=0;
String[] lcd_lines =null;
130,6 → 194,7
 
public void menu_keypress(int keyCode)
{
debug.log("KeyCode:"+keyCode);
switch (getGameAction (keyCode))
{
case UP:
153,20 → 218,33
 
}
 
// int lcd_top=25;
 
public void paint_lcd(Graphics g,boolean bottomup)
{
 
int y;
 
for(int i=0;i<lcd_lines.length;i++)
int lcd_top= (state==STATEID_EDIT_PARAMS?0:25);
 
int spacer_left_right=(this.getWidth()-(20*(lcd_img.getWidth()/222)))/2;
// for(int i=0;i<lcd_lines.length;i++)
int max_lines=(this.getHeight()-lcd_top)/lcd_char_height;
int display_lines=(lcd_lines.length>max_lines?max_lines:lcd_lines.length);
 
 
int lcd_off= (state==STATEID_EDIT_PARAMS?params_editor.act_y:act_menu_select)-display_lines+1;
if ( lcd_off<0) lcd_off=0;
 
for(int i=0;i<display_lines;i++)
for (int pos=0;pos<20;pos++)
{
if (bottomup)
y=this.getHeight()-(lcd_lines.length-i)*lcd_char_height;
y=this.getHeight()-(display_lines-i)*lcd_char_height;
else
y=i*lcd_char_height;
g.setClip((lcd_img.getWidth()/222)*pos,y,(lcd_img.getWidth()/222),lcd_img.getHeight());
g.drawImage(lcd_img,(lcd_img.getWidth()/222)*pos-((pos<lcd_lines[i].length()?lcd_lines[i].charAt(pos):' ')-' ')*(lcd_img.getWidth()/222),y,g.TOP | g.LEFT);
g.setClip((lcd_img.getWidth()/222)*pos+spacer_left_right,y,(lcd_img.getWidth()/222),lcd_img.getHeight());
g.drawImage(lcd_img,spacer_left_right+(lcd_img.getWidth()/222)*pos-((pos<lcd_lines[i+lcd_off].length()?lcd_lines[i+lcd_off].charAt(pos):' ')-' ')*(lcd_img.getWidth()/222),y,g.TOP | g.LEFT);
}
}
190,18 → 268,21
 
 
bt_img=Image.createImage("/bt.png");
 
symbols_img=Image.createImage("/symbols.png");
load_img=Image.createImage("/load.png");
}
catch (Exception e)
{
err+=e.toString();
}
 
lcd_char_width=lcd_img.getWidth()/222;
lcd_char_height=lcd_img.getHeight();
 
graph_data=new int[MAX_GRAPHS][bg_img.getWidth()];
 
for (int c=0;c<bg_img.getWidth();c++)
for (int d=0;d<MAX_GRAPHS;d++)
graph_data[d][c]=-1;
 
 
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()];
215,6 → 296,14
accroll_line_pos_data[c]=-1;
}
 
}
 
catch (Exception e)
{
debug.err(e.toString());
}
 
}
 
public DUBwiseCanvas(DUBwise _root)
221,10 → 310,18
{
 
 
// file
file_list= new String[MAX_FILELIST_LENGTH];
act_path_arr=new String[MAX_PATH_DEPTH];
// end file
 
 
root=_root;
 
debug = new DUBwiseDebug(this);
 
 
 
bt_scanner = new BTSearcher();
params_editor = new MKParamsEditor(this);
ufo_prober = new UFOProber();
258,7 → 355,7
act_skin=settings_arr[0];
do_sound=(settings_arr[1]==1);
do_vibra=(settings_arr[2]==1);
do_graph=(settings_arr[3]==1);
do_scrollbg=(settings_arr[3]==1);
fullscreen=(settings_arr[4]==1);
keep_lighton=(settings_arr[5]==1);
 
277,7 → 374,8
load_images();
 
chg_state((mk.force_disconnect)?STATEID_SCANNING:STATEID_MAINMENU);
// chg_state((mk.force_disconnect)?STATEID_SCANNING:STATEID_MAINMENU);
chg_state(STATEID_MAINMENU);
 
 
370,6 → 468,20
mk.motor_test(motor_test);
break;
 
case STATEID_IPINPUT:
lcd_lines[1]=ip_str(act_proxy_ip,true);
 
lcd_lines[2]="";
for(int foo=0;foo<20;foo++)
{
if (foo==ipinput_pos)
lcd_lines[2]+="^";
else
lcd_lines[2]+=" ";
}
break;
 
case STATEID_MAINMENU:
if (ufo_prober.change_notify)
{
400,6 → 512,7
}
 
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();
416,8 → 529,6
if (quit)
{
 
 
try
{
RecordStore.deleteRecordStore(RECORD_STORE_NAME);
428,7 → 539,7
settings_arr[0]=(byte)act_skin;
settings_arr[1]=(byte)(do_sound?1:0);
settings_arr[2]=(byte)(do_vibra?1:0);
settings_arr[3]=(byte)(do_graph?1:0);
settings_arr[3]=(byte)(do_scrollbg?1:0);
settings_arr[4]=(byte)(fullscreen?1:0);
settings_arr[5]=(byte)(keep_lighton?1:0);
458,22 → 569,12
if (bg_offset==-bg_img.getWidth())
bg_offset=0;
if (keep_lighton) com.nokia.mid.ui.DeviceControl.setLights(0,100);
//bt.tick();
// every state has sth to do in tick section
 
}
catch (Exception e)
{
}
 
// System.gc();
 
catch (Exception e) { }
sleeptime=1000/ 15 - (int) (System.currentTimeMillis()- loopStartTime);
 
 
if (sleeptime<0)
497,9 → 598,38
 
boolean firstrun=true;
 
public int skin_bg_color()
{
switch (act_skin)
{
case SKINID_DARK:
return 0x000000;
 
default:
case SKINID_LIGHT:
return 0xFFFFFF;
}
}
 
 
public int skin_fg_color()
{
switch (act_skin)
{
case SKINID_DARK:
return 0xFFFFFF;
default:
case SKINID_LIGHT:
return 0x000000;
}
}
 
// drawing section
public void paint(Graphics g) {
//
if (debug.showing)
{
debug.paint(g);
506,6 → 636,7
return;
}
 
if (firstrun)
{
if (fullscreen) setFullScreenMode(fullscreen);
512,6 → 643,9
firstrun=false;
}
y_off=0;
 
 
 
try {
if (mk!=null)
538,52 → 672,113
//default Font
g.setFont(f1);
 
if (state==STATEID_EDIT_PARAMS)
 
//draw background
if ((!do_scrollbg) || (state==STATEID_EDIT_PARAMS))
{
g.setColor(0x000000);
g.fillRect(0,0,this.getWidth(),this.getHeight());
g.setColor(0xdedfff);
g.fillRect(0,0,this.getWidth(),symbols_img.getHeight());
 
g.setColor(skin_bg_color());
g.fillRect(0,symbols_img.getHeight(),this.getWidth(),this.getHeight()-symbols_img.getHeight());
 
 
}
else
else
{
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);
}
 
switch (act_skin)
 
//int bar=0;
// for ( int bar=0;bar<3;bar++)
if (do_scrollbg)
for ( int bar=0;bar<this.getWidth()/(symbols_img.getWidth()/10)+1;bar++)
{
g.setClip(bar*(symbols_img.getWidth()/10),0,(symbols_img.getWidth()/10),symbols_img.getHeight());;
g.drawImage(symbols_img,bar*(symbols_img.getWidth()/10),0, g.TOP | g.LEFT);
}
 
 
g.setClip(0,0,(symbols_img.getWidth()/10),symbols_img.getHeight());;
if (mk.connected)
{
case SKINID_DARK:
g.setColor(0x2dcf20);
break;
case SKINID_LIGHT:
g.setColor(0x000000);
break;
 
if (((mk.bytes_in_count>>3)&1)==1)
g.drawImage(symbols_img,(-2)*(symbols_img.getWidth()/10),0, g.TOP | g.LEFT);
else
g.drawImage(symbols_img,(-3)*(symbols_img.getWidth()/10),0, g.TOP | g.LEFT);
 
int symbol_spacer=5;
g.setClip(symbol_spacer+(symbols_img.getWidth()/10),0,(symbols_img.getWidth()/10),symbols_img.getHeight());;
 
g.drawImage(symbols_img,symbol_spacer+(-3)*(symbols_img.getWidth()/10),0, g.TOP | g.LEFT);
g.setClip(0,0,this.getWidth(),this.getHeight());
g.setColor(0x03035a);
g.drawString("" + (mk.debug_data.UBatt()/10) + "," +(mk.debug_data.UBatt()%10)+"V" , symbol_spacer+2+2*(symbols_img.getWidth()/10),y_off,Graphics.TOP | Graphics.LEFT);
// g.drawString("Sender: " + mk.debug_data.SenderOkay(),this.getWidth()/2,y_off,Graphics.TOP | Graphics.LEFT);
g.setClip(2*symbol_spacer+2*(symbols_img.getWidth()/10) + g.getFont().stringWidth("88,8V"),0,(symbols_img.getWidth()/10),symbols_img.getHeight());;
g.drawImage(symbols_img,2*symbol_spacer+(-4)*(symbols_img.getWidth()/10) + g.getFont().stringWidth("88,8V"),0, g.TOP | g.LEFT);
 
g.setClip(0,0,this.getWidth(),this.getHeight());
 
g.drawString(""+mk.debug_data.SenderOkay() , 2+2*symbol_spacer+3*(symbols_img.getWidth()/10) + g.getFont().stringWidth("88,8V"),y_off,Graphics.TOP | Graphics.LEFT);
}
 
else
g.drawImage(symbols_img,(-1)*(symbols_img.getWidth()/10),0, g.TOP | g.LEFT);
 
// if (mk.connected)
 
// unclip
g.setClip(0,0,this.getWidth(),this.getHeight());
 
y_off+=symbols_img.getHeight();
g.setColor(skin_fg_color());
switch(state)
{
 
case STATEID_GPSVIEW:
g.drawString("GPS-Packages: " + mk.navi_data_count ,0,y_off,Graphics.TOP | Graphics.LEFT);
 
g.setStrokeStyle(Graphics.SOLID);
g.setColor(0x0000ff);
 
 
// g.fillArc(0, 0, this.getWidth(), this.getWidth(), 0,45);
 
int start_angle=(360+mk.gps_position.angle2wp(act_wp) - ((360+mk.debug_data.analog[26]-heading_offset)%360))%360;
// start_angle=0;
start_angle=(360-start_angle +90 -(45/2))%360;
 
g.fillArc(0, 0, this.getWidth(), this.getWidth(), start_angle,45);
// g.drawArc(1, 1, this.getWidth()-2, this.getWidth()-2, start_angle,45);
// g.drawArc(2, 2, this.getWidth()-4, this.getWidth()-4, start_angle ,45);
 
 
g.setColor(skin_fg_color());
 
 
 
 
g.drawString("GPS-Packages: " + mk.navi_data_count ,0,y_off,Graphics.TOP | Graphics.LEFT); g.drawString("GPS-Packages: " + mk.navi_data_count ,0,y_off,Graphics.TOP | Graphics.LEFT); g.drawString("GPS-Packages: " + mk.navi_data_count ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.drawString("Used Sats: " + mk.gps_position.Used_Sat ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.drawString("Latitude: " + mk.gps_position.Latitude_str() ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.drawString("=>: " + mk.gps_position.Latitude_min_sec() ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
 
g.drawString("Longitude: " + mk.gps_position.Longitude_str() ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.drawString("=> " + mk.gps_position.Longitude_min_sec() ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
 
 
g.drawString("Target-Lat: " + mk.gps_position.TargetLatitude ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.drawString("Target-Long: " + mk.gps_position.TargetLongitude ,0,y_off,Graphics.TOP | Graphics.LEFT);
596,13 → 791,28
g.drawString("WayPoints: " + act_wp + "/" + mk.gps_position.last_wp ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
 
g.drawString(" " + mk.gps_position.WP_Latitude_min_sec(act_wp) ,0,y_off,Graphics.TOP | Graphics.LEFT);
g.drawString("" + mk.gps_position.NameWP[act_wp] ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
 
g.drawString(" " + mk.gps_position.WP_Longitude_min_sec(act_wp) ,0,y_off,Graphics.TOP | Graphics.LEFT);
g.drawString("Lat: " + mk.gps_position.WP_Latitude_str(act_wp) ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
 
g.drawString("Long: " + mk.gps_position.WP_Longitude_str(act_wp) ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
 
 
g.drawString("Distance: " + mk.gps_position.distance2wp(act_wp) ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
 
g.drawString("Angle: " + mk.gps_position.angle2wp(act_wp) ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
 
 
g.drawString("Compas Heading: " + ((360+mk.debug_data.analog[26]-heading_offset)%360) + "(" +mk.debug_data.analog[26] +")" ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
 
 
break;
 
case STATEID_CAMMODE:
618,7 → 828,7
break;
 
case STATEID_STICKVIEW:
y_off=0;
 
for(int tmp_y=0;tmp_y<10;tmp_y++)
{
g.drawString(""+tmp_y+"=>"+mk.stick_data.stick[tmp_y],0,y_off,Graphics.TOP | Graphics.LEFT);
654,10 → 864,10
 
{
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.fillRect(this.getWidth()/(8*2)+bar*2*this.getWidth()/8,y_off+10,this.getWidth()/8,y_off+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);
g.drawString(""+motor_test[bar] ,this.getWidth()/8+bar*2*this.getWidth()/8,y_off+10,Graphics.TOP | Graphics.HCENTER);
g.drawString(""+mk.debug_data.motor_val(bar) ,this.getWidth()/8+bar*2*this.getWidth()/8,y_off+25,Graphics.TOP | Graphics.HCENTER);
}
break;
 
665,13 → 875,23
params_editor.paint(g);
break;
 
case STATEID_FILEOPEN:
y_off+=spacer;
g.drawString("act_path" + act_path() ,0,y_off,Graphics.TOP | Graphics.LEFT);
paint_menu(g);
break;
 
 
case STATEID_IPINPUT:
paint_lcd(g,true);
break;
 
case STATEID_READ_PARAMS:
paint_lcd(g,true);
 
g.setClip(this.getWidth()/2-load_img.getWidth()/6+1,this.getHeight()/2-load_img.getHeight()/8+1, 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);
// g.drawImage(bt_img,this.getWidth()/2 ,this.getHeight()/2 , g.HCENTER | g.VCENTER);
break;
 
 
695,17 → 915,9
g.setColor(0x0000CC);
g.fillRect(0,y_off,this.getWidth(),spacer1);
 
switch (act_skin)
{
case SKINID_DARK:
g.setColor(0x2dcf20);
break;
case SKINID_LIGHT:
g.setColor(0x000000);
break;
}
g.setColor(skin_fg_color());
 
 
}
if (i+rawdebug_off_y<32) //todo better style
g.drawString(mk.debug_data.names[i+rawdebug_off_y] + mk.debug_data.analog[i+rawdebug_off_y] ,0,y_off,Graphics.TOP | Graphics.LEFT);
719,14 → 931,15
break;
 
case STATEID_MAINMENU:
case STATEID_CONN_DETAILS:
g.setFont(f1);
g.drawString("Connection::",0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.setFont(f2);
g.drawString(ufo_prober.extended_name()+ " (" + (mk.connected?("open"+((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s"):"closed")+"):",0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer1;
g.drawString(" Version:" + mk.version.str ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer1;
/*
 
g.drawString(" Name:" + mk.name,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer1;
g.drawString(" URL:" + mk.mk_url,0,y_off,Graphics.TOP | Graphics.LEFT);
735,7 → 948,14
g.setFont(f1);
g.drawString("Packet Traffic:",0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.setFont(f2);*/
g.setFont(f2);
g.drawString( " in:"+mk.bytes_in_count + " bytes => " + mk.bytes_in_count/((System.currentTimeMillis()- mk.connection_start_time)/1000) + " bytes/s",0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer1;
 
g.drawString( " out:"+mk.bytes_out_count + " bytes =>" + mk.bytes_out_count/((System.currentTimeMillis()- mk.connection_start_time)/1000) + "bytes/s", 0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer1;
 
 
g.drawString( " debug:"+mk.debug_data_count+ " LCD:" + mk.lcd_data_count + " vers:" + mk.version_data_count,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer1;
g.drawString( " other:"+mk.other_data_count+" params:"+mk.params_data_count + " GPS:"+mk.navi_data_count ,0,y_off,Graphics.TOP | Graphics.LEFT);
742,9 → 962,39
y_off+=spacer1;
g.drawString( " debug_names:" + mk.debug_names_count + " angles:" + mk.angle_data_count ,0,y_off,Graphics.TOP | Graphics.LEFT);
 
break;
 
 
case STATEID_PROXY:
g.setFont(f1);
g.drawString("Host:",0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.setFont(f2);
g.drawString(" " + mk.proxy.url + "("+((mk.proxy.connected)?"open":"closed") +")",0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer1;
 
g.setFont(f1);
g.drawString("Packet Traffic:",0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.setFont(f2);
g.drawString( " in:"+mk.bytes_in_count + " bytes => " + mk.bytes_in_count/((System.currentTimeMillis()- mk.connection_start_time)/1000) + " bytes/s",0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer1;
 
g.drawString( " out:"+mk.bytes_out_count + " bytes =>" + mk.bytes_out_count/((System.currentTimeMillis()- mk.connection_start_time)/1000) + "bytes/s", 0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer1;
 
 
g.drawString( " debug:"+mk.debug_data_count+ " LCD:" + mk.lcd_data_count + " vers:" + mk.version_data_count,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer1;
g.drawString( " other:"+mk.other_data_count+" params:"+mk.params_data_count + " GPS:"+mk.navi_data_count ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer1;
g.drawString( " debug_names:" + mk.debug_names_count + " angles:" + mk.angle_data_count ,0,y_off,Graphics.TOP | Graphics.LEFT);
 
break;
 
 
case STATEID_MAINMENU:
case STATEID_SETTINGSMENU:
// falltru wanted
case STATEID_SELECT_PARAMSET:
751,12 → 1001,99
case STATEID_HANDLE_PARAMS:
case STATEID_DEVICESELECT:
 
paint_menu(g);
break;
case STATEID_FLIGHTVIEW:
 
case STATEID_GRAPH:
 
g.setStrokeStyle(Graphics.DOTTED);
g.setColor(0xe1dddd);
 
int scale=0;
if (1/line_scaler< this.getHeight()/10) scale=1;
if (10/line_scaler< this.getHeight()/10) scale=10;
if (100/line_scaler< this.getHeight()/10) scale=100;
if (1000/line_scaler< this.getHeight()/10) scale=1000;
if (10000/line_scaler< this.getHeight()/10) scale=10000;
 
 
/*
g.drawString("scale:"+scale + "line scaler" + line_scaler,0,y_off,Graphics.TOP | Graphics.LEFT);
 
 
int jump=0;
g.drawLine(0,line_middle_y,this.getWidth(),line_middle_y);
 
while (jump<this.getHeight()/2)
{
g.drawLine(0,line_middle_y - jump/line_scaler,this.getWidth(),line_middle_y - jump/line_scaler);
g.drawLine(0,line_middle_y + jump/line_scaler,this.getWidth(),line_middle_y + jump/line_scaler);
jump+=scale;
}
*/
 
 
 
 
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);
 
 
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();
}
catch (Exception e)
{
err+=e.toString();
}
 
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);
}
 
 
 
for (int d=0;d<MAX_GRAPHS;d++)
{
g.setColor(graph_colors[d]);
g.fillRect(0,y_off +spacer1/2-2 ,20,4);
g.setColor(skin_fg_color());
g.drawString(graph_names[d],23,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer1;
 
}
 
 
 
break;
 
case STATEID_FLIGHTVIEW:
 
g.setClip(this.getWidth()/2-load_img.getWidth()/6+1,this.getHeight()/2-load_img.getHeight()/8+1, load_img.getWidth()/4,load_img.getHeight()/3);;
if (( mk.LCD.init_state!=-1)||(mk.LCD.act_mk_page!=mk.LCD.act_user_page)) 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);
 
/*
// !!TODO!! check exactly which version those Datas where introduced
if (mk.version.compare(0,60)==mk.version.VERSION_PREVIOUS)
{
784,10 → 1121,15
y_off+=spacer;
g.drawString("time motor=15:" +(mk_stat.motor_stand_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer;
g.drawString("act_lcd_page:" + mk.LCD.act_mk_page + "/" + mk.LCD.pages + " ( wanted: " + mk.LCD.act_user_page +")" ,0,y_off,Graphics.TOP | Graphics.LEFT);
g.drawString("lcd:" + mk.LCD.act_mk_page + "/" + mk.LCD.pages + " ( wanted: " + mk.LCD.act_user_page + "state:" + mk.LCD.init_state +")" ,0,y_off,Graphics.TOP | Graphics.LEFT);
 
y_off+=spacer;
g.drawString("lcd-key:" + mk.LCD.act_key ,0,y_off,Graphics.TOP | Graphics.LEFT);
 
}
*/
int spacer_left_right=(this.getWidth()-(20*(lcd_img.getWidth()/222)))/2;
 
y_off=this.getHeight()-4*lcd_img.getHeight();
795,43 → 1137,22
{
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.get_act_page()[foo].charAt(x)-' ')*(lcd_img.getWidth()/222),y_off, g.TOP | g.LEFT);
g.setClip(spacer_left_right+(lcd_img.getWidth()/222)*x,y_off,(lcd_img.getWidth()/222),lcd_img.getHeight());
g.drawImage(lcd_img,spacer_left_right+(lcd_img.getWidth()/222)*x-(mk.LCD.get_act_page()[foo].charAt(x)-' ')*(lcd_img.getWidth()/222),y_off, g.TOP | g.LEFT);
 
}
y_off+=lcd_img.getHeight();
}
 
g.setClip(0,0,this.getWidth(),this.getHeight());
g.setClip(0,0,this.getWidth(),this.getHeight());
 
 
 
// draw lines
 
if (do_graph) 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);
 
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);
 
}
 
}
 
879,6 → 1200,52
}
 
 
public int pow(int val,int pow)
{
int res=1;
 
for (int p=0;p<pow;p++)
res*=val;
 
return res;
}
public int mod_decimal(int val,int mod_power,int modder,int setter,int clipper)
{
 
int res=0;
 
for (int power=0;power<4;power++)
{
 
int act_digit=(val/pow(10,power))%10;
 
int new_digit=act_digit;
if (power==mod_power)
{
if (setter!=-1)
new_digit=setter;
new_digit+=modder;
 
if(new_digit<0)
new_digit=0;
 
if(new_digit>clipper)
new_digit=clipper;
 
}
 
// new_digit=1;
res+=new_digit*pow(10,power);
}
return res;
 
 
}
 
/*********************************************** input Section **********************************************/
 
 
887,6 → 1254,9
int intro_str_pos=0;
int intro_str_delay=3;
 
 
 
public void chg_state(int next_state)
{
if (next_state!=state)act_menu_select=0;
893,6 → 1263,68
// prepare next state
switch(next_state)
{
case STATEID_FILEOPEN:
if (act_path_depth==0)
{
Enumeration drives = FileSystemRegistry.listRoots();
int tmp_i=0;
while(drives.hasMoreElements())
{
file_list[tmp_i]= (String) drives.nextElement();
tmp_i++;
if (MAX_FILELIST_LENGTH<tmp_i)
break;
}
menu_items=new String[tmp_i];
lcd_lines=new String[tmp_i];
file_list_length=tmp_i;
for(tmp_i=0;tmp_i<file_list_length;tmp_i++)
menu_items[tmp_i]=file_list[tmp_i];
 
}
else
{
 
try {
FileConnection fc = (FileConnection) Connector.open("file:///"+act_path());
Enumeration filelist = fc.list("*", true);
int tmp_i=0;
while(filelist.hasMoreElements()) {
file_list[tmp_i] = (String) filelist.nextElement();
tmp_i++;
/* fc = (FileConnection)
Connector.open("file:///CFCard/" + fileName);
if(fc.isDirectory()) {
System.out.println("\tDirectory Name: " + fileName);
} else {
System.out.println
("\tFile Name: " + fileName +
"\tSize: "+fc.fileSize());
}*/
}
menu_items=new String[tmp_i+1];
lcd_lines=new String[tmp_i+1];
file_list_length=tmp_i+1;
menu_items[0]="..";
for(tmp_i=1;tmp_i<file_list_length;tmp_i++)
menu_items[tmp_i]=file_list[tmp_i-1];
 
 
fc.close();
} catch (IOException ioe) {
System.out.println(ioe.getMessage());
}
}
 
 
break;
case STATEID_CAMMODE:
if (mVideoControl==null)
934,6 → 1366,11
 
break;
 
case STATEID_IPINPUT:
lcd_lines=new String[3];
lcd_lines[0]="Address (IP:Port): ";
break;
 
case STATEID_SCANNING:
lcd_lines=new String[4];
948,10 → 1385,11
break;
 
case STATEID_HANDLE_PARAMS:
menu_items=new String[2];
menu_items=new String[3];
menu_items[0]="write to MK";
menu_items[1]="Discard";
lcd_lines=new String[2];
menu_items[1]="don't write to MK";
menu_items[2]="discard/read again";
lcd_lines=new String[3];
 
break;
 
964,6 → 1402,7
break;
 
case STATEID_DEVICESELECT:
menu_items=new String[bt_scanner.remote_device_count+1];
for (int i=0;i<bt_scanner.remote_device_count;i++)
menu_items[i]=bt_scanner.remote_device_name[i];
974,11 → 1413,20
 
case STATEID_MAINMENU:
if (ufo_prober.is_navi())
menu_items=main_menu_items_navi;
{
menu_items=main_menu_items_navi;
menu_actions=main_menu_actions_navi;
}
else if (ufo_prober.is_mk())
menu_items=main_menu_items_mk;
else
menu_items=main_menu_items_no_connection;
{
menu_items=main_menu_items_mk;
menu_actions=main_menu_actions_mk;
}
else // no connection
{
menu_items=main_menu_items_no_connection;
menu_actions=main_menu_actions_no_connection;
}
 
lcd_lines=new String[menu_items.length];
break;
992,7 → 1440,7
menu_items[0]+=(act_skin==SKINID_DARK)?"Dark":"Light";
menu_items[1]+=(!do_sound)?"Off":"On";
menu_items[2]+=(!do_vibra)?"Off":"On";
menu_items[3]+=(!do_graph)?"Off":"On";
menu_items[3]+=(!do_scrollbg)?"Off":"On";
menu_items[4]+=(!fullscreen)?"Off":"On";
menu_items[5]+=(!keep_lighton)?"Off":"On";
 
1003,6 → 1451,11
user_intent=USER_INTENT_RAWDEBUG;
break;
 
 
case STATEID_GRAPH:
user_intent=USER_INTENT_GRAPH;
break;
 
}
 
 
1102,7 → 1555,7
debug.process_key(keyCode);
 
 
if (keyCode==KEY_STAR)
if ((keyCode==KEY_STAR) || (keyCode==113))
{
if (state==STATEID_EDIT_PARAMS)
{
1125,14 → 1578,66
}
switch(state)
{
case STATEID_IPINPUT:
if ((keyCode>=KEY_NUM0)&&(keyCode<=KEY_NUM9))
{
act_proxy_ip[ipinput_pos/4]=mod_decimal(act_proxy_ip[ipinput_pos/4],(ipinput_pos<15?2:3)-(ipinput_pos%4),0,(keyCode-KEY_NUM0),9);
 
if(ipinput_pos<19) ipinput_pos++;
if ((ipinput_pos<18)&&(((ipinput_pos+1)%4)==0))ipinput_pos++;
}
else
switch (getGameAction (keyCode))
{
case LEFT:
if(ipinput_pos>0) ipinput_pos--;
if (((ipinput_pos+1)%4)==0)ipinput_pos--;
break;
case RIGHT:
if(ipinput_pos<19) ipinput_pos++;
if(ipinput_pos<18)if (((ipinput_pos+1)%4)==0)ipinput_pos++;
break;
 
case UP:
act_proxy_ip[ipinput_pos/4]=mod_decimal(act_proxy_ip[ipinput_pos/4],(ipinput_pos<15?2:3)-(ipinput_pos%4),1,-1,9);
 
break;
 
case DOWN:
act_proxy_ip[ipinput_pos/4]=mod_decimal(act_proxy_ip[ipinput_pos/4],(ipinput_pos<15?2:3)-(ipinput_pos%4),-1,-1,9);
 
 
case FIRE:
mk.do_proxy("socket://"+ip_str(act_proxy_ip,false));
chg_state(STATEID_PROXY);
 
break;
 
}
break;
 
case STATEID_GPSVIEW:
if (keyCode == this.KEY_NUM0)
mk.set_gps_target(mk.gps_position.Latitude,mk.gps_position.Longitude);
 
 
 
if (keyCode == this.KEY_NUM1)
mk.gps_position.push_wp();
if (keyCode == this.KEY_NUM2)
chg_state(STATEID_FILEOPEN);
if (keyCode == this.KEY_NUM3)
mk.set_gps_target(mk.gps_position.LatWP[act_wp],mk.gps_position.LongWP[act_wp]);
 
if (keyCode == this.KEY_NUM4)
mk.gps_position.next_gps_format();
 
if (keyCode == this.KEY_NUM5)
heading_offset= mk.debug_data.analog[26];
 
switch (getGameAction (keyCode))
{
case UP:
1245,17 → 1750,50
break;
case STATEID_HANDLE_PARAMS:
if ( getGameAction (keyCode)==FIRE )
switch(act_menu_select)
{
case 0:
mk.write_params();
default:
chg_state(STATEID_MAINMENU);
{
switch(act_menu_select)
{
case 0:
 
mk.write_params();
break;
case 2:
mk.params.use_backup();
break;
}
chg_state(STATEID_MAINMENU);
}
else
menu_keypress(keyCode);
break;
 
case STATEID_FILEOPEN:
if ( getGameAction (keyCode)==FIRE )
{
if ((act_menu_select==0)&&(act_path_depth!=0))
{
act_path_depth--;
//act_path=act_path.substring(0,act_path.substring(0,act_path.length()-2).indexOf('/') );
 
//act_path=last_path;
}
else
{
//last_path=act_path;
if (act_path_depth==0)
act_path_arr[act_path_depth++]=file_list[act_menu_select];
else
act_path_arr[act_path_depth++]=file_list[act_menu_select-1];
}
act_menu_select=0;
chg_state(STATEID_FILEOPEN);
}
else
menu_keypress(keyCode);
break;
 
case STATEID_SETTINGSMENU:
if ( getGameAction (keyCode)==FIRE )
switch(act_menu_select)
1276,7 → 1814,7
break;
 
case SETTINGSMENU_GRAPHTOGGLE:
do_graph=!do_graph;
do_scrollbg=!do_scrollbg;
chg_state(STATEID_SETTINGSMENU);
break;
 
1301,66 → 1839,110
break;
 
case STATEID_MAINMENU:
if (keyCode == this.KEY_NUM2)
chg_state(STATEID_FILEOPEN);
 
if ( getGameAction (keyCode)==FIRE )
{
 
if (ufo_prober.is_mk())
switch(act_menu_select)
{
case MAINMENU_MK_CAMMODE:
chg_state(STATEID_CAMMODE);
break;
switch(menu_actions[act_menu_select])
{
 
case MAINMENU_MK_SETTINGSMENU:
chg_state(STATEID_SETTINGSMENU);
break;
case MAINMENU_MK_STICKS:
chg_state(STATEID_STICKVIEW);
break;
 
case MAINMENU_MK_KEYCONTROL:
chg_state(STATEID_KEYCONTROL);
break;
case MAINMENU_MK_TELEMETRY :
chg_state(STATEID_FLIGHTVIEW);
break;
case ACTIONID_CONN_DETAILS:
chg_state(STATEID_CONN_DETAILS);
break;
case ACTIONID_QUIT:
quit=true;
break;
 
case MAINMENU_MK_MOTORTEST :
chg_state(STATEID_MOTORTEST);
break;
case ACTIONID_SWITCH_NC:
mk.switch_to_navi();
break;
 
case MAINMENU_MK_PARAMS :
if (mk.watchdog.act_paramset<5)
chg_state(STATEID_READ_PARAMS);
else
chg_state(STATEID_SELECT_PARAMSET);
break;
case ACTIONID_SWITCH_FC:
mk.switch_to_fc();
break;
case ACTIONID_GRAPH:
chg_state(STATEID_GRAPH);
break;
case ACTIONID_KEYCONTROL:
chg_state(STATEID_KEYCONTROL);
break;
case ACTIONID_LCD :
chg_state(STATEID_FLIGHTVIEW);
break;
 
case ACTIONID_PROXY:
 
case MAINMENU_MK_PROXY:
mk.do_proxy("socket://192.168.1.42:2323");
break;
chg_state(STATEID_IPINPUT);
break;
case ACTIONID_DEVICESELECT:
chg_state(STATEID_SCANNING);
break;
case ACTIONID_RAWDEBUG:
chg_state(STATEID_RAWDEBUG);
break;
case ACTIONID_SETTINGS:
chg_state(STATEID_SETTINGSMENU);
break;
 
case MAINMENU_MK_DEVICESELECT:
chg_state(STATEID_SCANNING);
break;
case ACTIONID_RCDATA:
chg_state(STATEID_STICKVIEW);
break;
 
case MAINMENU_MK_RAWDEBUG:
chg_state(STATEID_RAWDEBUG);
break;
case ACTIONID_CAM:
chg_state(STATEID_CAMMODE);
break;
 
case MAINMENU_MK_QUIT:
// set quit Flag
quit=true;
break;
case ACTIONID_GPSDATA:
chg_state(STATEID_GPSVIEW);
break;
 
 
case ACTIONID_MOTORTEST :
chg_state(STATEID_MOTORTEST);
break;
 
case ACTIONID_EDIT_PARAMS:
if (mk.watchdog.act_paramset<5)
chg_state(STATEID_READ_PARAMS);
else
chg_state(STATEID_SELECT_PARAMSET);
 
break;
 
case ACTIONID_DEBUG:
debug.showing=true;
break;
}
/*
if (ufo_prober.is_mk())
switch(act_menu_select)
{
 
 
 
 
}
else if (ufo_prober.is_navi())
switch(act_menu_select)
{
case MAINMENU_NAVI_SWITCH_FC:
mk.switch_to_fc();
 
break;
 
case MAINMENU_NAVI_SETTINGS:
chg_state(STATEID_SETTINGSMENU);
1404,6 → 1986,11
chg_state(STATEID_SCANNING);
break;
 
 
case MAINMENU_NO_CONN_DEBUG:
debug.showing=true;
break;
 
case MAINMENU_NO_CONN_QUIT:
// set quit Flag
1411,9 → 1998,11
break;
 
}
} */
}
 
else menu_keypress(keyCode);
 
break;
 
case STATEID_SELECT_PARAMSET:
1437,6 → 2026,7
else
*/
 
if ( getGameAction (keyCode)==FIRE )
{
 
/DUBwise/src/J2ME/src/DUBwiseDebug.java
50,12 → 50,25
 
public void log(String str)
{
if (debug_pos==DEBUG_HISTORY_LENGTH)
debug_pos=0;
 
debug_msgs[debug_pos]=str;
debug_pos++;
// debug_msgs[debug_pos]=str;
}
 
 
public void err(String str)
{
if (debug_pos==DEBUG_HISTORY_LENGTH)
debug_pos=0;
debug_msgs[debug_pos]=str;
 
debug_msgs[debug_pos]=str;
debug_pos++;
showing=false;
paused=true;
// debug_msgs[debug_pos]=str;
}
 
public void paint (Graphics g)
/DUBwise/src/J2ME/src/DUBwiseDefinitions.java
17,9 → 17,13
public final static int STATEID_CAMMODE =12;
public final static int STATEID_READ_PARAMS =13;
public final static int STATEID_GPSVIEW =14;
public final static int STATEID_FILEOPEN =15;
public final static int STATEID_GRAPH =16;
public final static int STATEID_CONN_DETAILS =17;
public final static int STATEID_IPINPUT =18;
public final static int STATEID_PROXY =19;
 
 
 
public boolean fullscreen=false;
public int act_motor=0;
public int act_motor_increase=0;
26,44 → 30,45
public boolean motor_test_sel_all=false;
 
 
public String[] main_menu_items_no_connection= { "Tool Settings","Change Device" , "Quit " };
 
public final static int ACTIONID_SETTINGS = 0;
public final static int ACTIONID_DEVICESELECT = 1;
public final static int ACTIONID_DEBUG = 2;
public final static int ACTIONID_CONN_DETAILS = 3;
public final static int ACTIONID_SWITCH_NC = 4;
public final static int ACTIONID_SWITCH_FC = 5;
 
public final static int MAINMENU_NO_CONN_SETTINGS =0;
public final static int MAINMENU_NO_CONN_DEVICESELECT =1+MAINMENU_NO_CONN_SETTINGS ;
public final static int MAINMENU_NO_CONN_QUIT =1+MAINMENU_NO_CONN_DEVICESELECT;
public final static int ACTIONID_GRAPH = 6;
public final static int ACTIONID_LCD = 7;
public final static int ACTIONID_RAWDEBUG = 8;
public final static int ACTIONID_RCDATA = 9;
public final static int ACTIONID_KEYCONTROL = 10;
public final static int ACTIONID_MOTORTEST = 11;
public final static int ACTIONID_EDIT_PARAMS = 12;
public final static int ACTIONID_CAM = 13;
public final static int ACTIONID_PROXY = 14;
public final static int ACTIONID_GPSDATA = 15;
public final static int ACTIONID_QUIT = 100;
 
 
public String[] main_menu_items_mk={"Telemetry","Raw Debug", "view RC-data", "MK-KeyControl", "Motor Test" , "Flight Settings","Tool Settings","Remote Cam","Proxy","Change Device" , "Quit " };
public String[] main_menu_items_no_connection = { "Proxy","Tool Settings" , "Change Device", "Connection Details" , "Debug DUBwise" , "Quit " };
public int[] main_menu_actions_no_connection= { ACTIONID_PROXY, ACTIONID_SETTINGS , ACTIONID_DEVICESELECT , ACTIONID_CONN_DETAILS, ACTIONID_DEBUG , ACTIONID_QUIT};
 
 
public final static int MAINMENU_MK_TELEMETRY =0;
public final static int MAINMENU_MK_RAWDEBUG =1+MAINMENU_MK_TELEMETRY;
public final static int MAINMENU_MK_STICKS =1+MAINMENU_MK_RAWDEBUG;
public final static int MAINMENU_MK_KEYCONTROL =1+MAINMENU_MK_STICKS;
public final static int MAINMENU_MK_MOTORTEST =1+MAINMENU_MK_KEYCONTROL;
public final static int MAINMENU_MK_PARAMS =1+MAINMENU_MK_MOTORTEST;
public final static int MAINMENU_MK_SETTINGSMENU =1+MAINMENU_MK_PARAMS;
public final static int MAINMENU_MK_CAMMODE =1+MAINMENU_MK_SETTINGSMENU;
public final static int MAINMENU_MK_PROXY =1+MAINMENU_MK_CAMMODE;
public final static int MAINMENU_MK_DEVICESELECT =1+MAINMENU_MK_PROXY;
public final static int MAINMENU_MK_QUIT =1+MAINMENU_MK_DEVICESELECT;
public String[] main_menu_items_mk ={"Connection Details" , "switch to NC","Sensor Graph" , "LCD","Raw Debug", "view RC-data", "MK-KeyControl", "Motor Test" , "Flight Settings","Tool Settings","Remote Cam","Proxy","Change Device" , "Debug" , "Quit " };
 
public int[] main_menu_actions_mk = { ACTIONID_CONN_DETAILS , ACTIONID_SWITCH_NC , ACTIONID_GRAPH , ACTIONID_LCD , ACTIONID_RAWDEBUG , ACTIONID_RCDATA , ACTIONID_KEYCONTROL , ACTIONID_MOTORTEST , ACTIONID_EDIT_PARAMS , ACTIONID_SETTINGS , ACTIONID_CAM , ACTIONID_PROXY , ACTIONID_DEVICESELECT , ACTIONID_DEBUG , ACTIONID_QUIT};
 
public String[] main_menu_items_navi={"Telemetry","Raw Debug", "view GPS-Data" ,"Tool Settings","Change Device" , "Quit " };
 
public final static int MAINMENU_NAVI_TELEMETRY =0;
public final static int MAINMENU_NAVI_RAWDEBUG =1+MAINMENU_NAVI_TELEMETRY;
public final static int MAINMENU_NAVI_GPSVIEW =1+MAINMENU_NAVI_RAWDEBUG;
public final static int MAINMENU_NAVI_SETTINGS =1+MAINMENU_NAVI_GPSVIEW ;
public final static int MAINMENU_NAVI_DEVICESELECT =1+MAINMENU_NAVI_SETTINGS;
public final static int MAINMENU_NAVI_QUIT =1+MAINMENU_NAVI_DEVICESELECT;
public String[] main_menu_items_navi={"Connection Details" , "switch to FC","LCD","Raw Debug", "view GPS-Data" ,"Tool Settings","Change Device" , "Quit " };
 
public int[] main_menu_actions_navi = { ACTIONID_CONN_DETAILS , ACTIONID_SWITCH_FC , ACTIONID_LCD , ACTIONID_RAWDEBUG , ACTIONID_GPSDATA , ACTIONID_SETTINGS , ACTIONID_DEVICESELECT , ACTIONID_DEBUG , ACTIONID_QUIT};
 
 
 
 
public String[] settings_menu_items={"Skin ","Sound ","Vibra " ,"Graph ","FullScreen " ,"Keep BGLight " ,"Back" };
public String[] settings_menu_items={"Skin ","Sound ","Vibra " ,"Scrolling BG ","FullScreen " ,"Keep BGLight " ,"Back" };
public final static int SETTINGSMENU_CHANGESKIN =0;
public final static int SETTINGSMENU_SOUNDTOGGLE =1;
public final static int SETTINGSMENU_VIBRATOGGLE =2;
75,4 → 80,5
public final static int USER_INTENT_NONE=0;
public final static int USER_INTENT_RAWDEBUG=1;
public final static int USER_INTENT_PARAMS=2;
public final static int USER_INTENT_GRAPH=3;
}
/DUBwise/src/J2ME/src/MKCommunicator.java
45,8 → 45,6
String p_msg="--";
public String msg="BT_INIT";
 
 
 
// for statistics
public int debug_data_count=0;
public int debug_names_count=0;
58,6 → 56,10
public int navi_data_count=0;
 
 
public int bytes_in_count=0;
public int bytes_out_count=0;
 
 
String name;
DUBwise root;
 
75,13 → 77,15
LCD= new MKLCD(this);
watchdog=new MKWatchDog(this);
gps_position=new MKGPSPosition();
proxy =new MKProxy();
new Thread( this ).start(); // fire up main Thread
}
 
 
public void do_proxy(String proxy_url)
 
public void do_proxy(String proxy_url)
{
proxy=new MKProxy(proxy_url);
proxy.connect(proxy_url);
}
 
110,9 → 114,9
writer=connection.openOutputStream();
 
//
String magic="\rmk-mode\r";
writer.write(magic.getBytes());
writer.flush();
//String magic="\rmk-mode\r";
//writer.write(magic.getBytes());
//writer.flush();
//
 
 
182,8 → 186,7
target[1]= (0xFF)&(longitude<<16);
target[2]= (0xFF)&(longitude<<8);
target[3]= (0xFF)&(longitude);
 
send_command(0,'s',target);
// send_command(0,'s',target);
}
 
 
232,11 → 235,79
}
 
 
 
public void trigger_debug()
{
if (sending||recieving) return; // its not that important - can be dropped
int[] params=new int[0];
send_command(0,'c',params);
}
 
 
 
public void switch_to_fc()
{
 
 
while(sending||recieving)
{
try { Thread.sleep(50); }
catch (Exception e) { }
}
 
 
int[] params=new int[1];
params[0]=0;
send_command(0,'u',params);
try { Thread.sleep(50); }
catch (Exception e) { }
 
version=new MKVersion();
LCD= new MKLCD(this);
 
}
 
 
public void switch_to_navi()
 
{
while(sending||recieving)
{try { Thread.sleep(50); }
catch (Exception e) { }
}
 
 
sending=true;
try
{
writer.write( 27);
writer.write( 27);
writer.write( 0x55);
writer.write( 0xaa);
writer.write( 0);
writer.write('\r');
bytes_out_count+=6;
writer.flush();
}
catch (Exception e) { }
sending=false;
try { Thread.sleep(50); }
catch (Exception e) { }
version=new MKVersion();
LCD= new MKLCD(this);
}
 
 
public void trigger_LCD(int key)
{
while(sending||recieving)
while(sending||recieving) // check if not only sending matters
{try { Thread.sleep(50); }
catch (Exception e) { }
}
254,6 → 325,7
 
public void write_params()
{
params.update_backup();
while(sending||recieving)
{try { Thread.sleep(50); }
catch (Exception e) { }
269,9 → 341,12
// send command to FC ( add crc and pack into pseudo Base64
public void send_command(int modul,char cmd,int[] params)
{
 
// if (modul==0) return;
sending=true;
char[] send_buff=new char[5 + (params.length/3 + (params.length%3==0?0:1) )*4]; // 5=1*start_char+1*addr+1*cmd+2*crc
// char[] send_buff=new char[5 + (params.length/3 + (params.length%3==0?0:1) )*4]; // 5=1*start_char+1*addr+1*cmd+2*crc
 
char[] send_buff=new char[3 + (params.length/3 + (params.length%3==0?0:1) )*4]; // 5=1*start_char+1*addr+1*cmd+2*crc
send_buff[0]='#';
send_buff[1]=(char)modul;
send_buff[2]=cmd;
305,11 → 380,13
{
tmp_crc+=(int)send_buff[tmp_i];
writer.write(send_buff[tmp_i]);
bytes_out_count++;
}
tmp_crc%=4096;
writer.write( (char)(tmp_crc/64 + '='));
writer.write( (char)(tmp_crc%64 + '='));
writer.write('\r');
bytes_out_count+=3;
writer.flush();
}
catch (Exception e)
343,6 → 420,8
case 'V': // Version Info
version_data_count++;
version.set_by_mk_data(Decode64(data,3,6));
if (version.minor>60) // FIXME - NO good detection
root.canvas.ufo_prober.set_to_mk();
break;
case '0':
390,8 → 469,8
 
case 'w':
angle_data_count++;
root.canvas.ufo_prober.set_to_mk();
debug.log("got angle data:");
// root.canvas.ufo_prober.set_to_mk();
debug.log("got angle data");
 
break;
452,12 → 531,12
else
try{
 
/*
while(sending)
{try { Thread.sleep(50); }
catch (Exception e) { }
}
 
*/
 
recieving=true;
468,15 → 547,21
while ((input != 13)) //&&(input!=-1))
{
 
debug.log("pre read");
input = reader.read() ;
if (proxy!=null)
proxy.writer.write(input);
if (input==-1) throw new Exception("test");
debug.log("Byte rcv" + input);
proxy.write(input);
 
if (input==-1) throw new Exception("disconnect");
if (input!=-1)
{
bytes_in_count++;
data_set[pos]=input;
pos++;
}
 
}
/DUBwise/src/J2ME/src/MKGPSPosition.java
6,17 → 6,32
*
* see README for further Infos
*
* Some code taken from here:
* http://www.koders.com/java/fidFC75A641A87B51BB757E9CD3136C7886C491487F.aspx
*
* and
* http://www.movable-type.co.uk/scripts/latlong.html
*
* thanx a lot for sharing!
*
********************************************/
 
 
 
import java.lang.Math;
public class MKGPSPosition
 
{
public final byte GPS_FORMAT_DECIMAL=0;
public final byte GPS_FORMAT_MINSEC=1;
public final byte GPS_FORMAT_COUNT=2;
byte act_gps_format=GPS_FORMAT_DECIMAL;
 
public final static int MAX_WAYPOINTS=100;
 
int[] LongWP;
int[] LatWP;
 
String[] NameWP;
int last_wp=0;
 
 
30,64 → 45,279
int Angle2Target;
 
byte Used_Sat;
/**
* Holds value Math.PI.
*/
public static final double PI = Math.PI;
/**
* Holds value PI / 2.0.
*/
public static final double PI_div2 = PI / 2.0;
/**
* Holds value PI / 4.0.
*/
public static final double PI_div4 = PI / 4.0;
 
 
public void push_wp()
{
LongWP[last_wp]=Longitude;
LatWP[last_wp]=Latitude;
last_wp++;
public static final double RADIANS = PI / 180.0;
public static final double DEGREES = 180.0 / PI;
 
 
private static final double p4 = 0.161536412982230228262e2;
/**
* Holds value 0.26842548195503973794141e3.
*/
private static final double p3 = 0.26842548195503973794141e3;
/**
* Holds value 0.11530293515404850115428136e4.
*/
private static final double p2 = 0.11530293515404850115428136e4;
/**
* Holds value 0.178040631643319697105464587e4.
*/
private static final double p1 = 0.178040631643319697105464587e4;
/**
* Holds value 0.89678597403663861959987488e3.
*/
private static final double p0 = 0.89678597403663861959987488e3;
/**
* Holds value 0.5895697050844462222791e2.
*/
private static final double q4 = 0.5895697050844462222791e2;
/**
* Holds value 0.536265374031215315104235e3.
*/
private static final double q3 = 0.536265374031215315104235e3;
/**
* Holds value 0.16667838148816337184521798e4.
*/
private static final double q2 = 0.16667838148816337184521798e4;
/**
* Holds value 0.207933497444540981287275926e4.
*/
private static final double q1 = 0.207933497444540981287275926e4;
/**
* Holds value 0.89678597403663861962481162e3.
*/
private static final double q0 = 0.89678597403663861962481162e3;
 
 
 
 
 
private static double _ATAN(double X) {
if (X < 0.414213562373095048802) { /* tan(PI/8) */
return _ATANX(X);
}
else if (X > 2.414213562373095048802) { /* tan(3*PI/8) */
return PI_div2 - _ATANX(1.0 / X);
}
else {
return PI_div4 + _ATANX((X - 1.0) / (X + 1.0));
}
}
 
 
public String dec_to_min_sec(int val)
private static double _ATANX(double X) {
double XX = X * X;
return X * ((((p4 * XX + p3) * XX + p2) * XX + p1) * XX + p0)
/ (((((XX + q4) * XX + q3) * XX + q2) * XX + q1) * XX + q0);
}
 
 
 
public double aTan2(double Y, double X) {
 
//private static double ATAN2(double Y, double X) {
// return Math.atan2(Y,X); // not in CLDC 1.1
 
// X=0
if (X == 0.0) {
if (Y > 0.0) {
// mid Q1/Q2
return PI_div2;
}
else if (Y < 0.0) {
// mid Q3/Q4
return -PI_div2;
}
else {
// undefined
return 0.0;
}
}
 
// X<0
if (X < 0.0) {
if (Y >= 0.0) {
// Q2
return (PI - _ATAN(Y / -X)); // Y>=0,X<0 |Y/X|
}
else {
// Q3
return -(PI - _ATAN(Y / X)); // Y<0,X<0 |Y/X|
}
}
 
// X>0
if (X > 0.0) {
// Q1/A4
//return ATAN( Y / X);
if (Y > 0.0) {
// Q1
return _ATAN(Y / X);
}
else {
// Q4
return -_ATAN(-Y / X);
}
}
 
/* will never reach here */
return 0.0;
 
}
/*
 
 
 
double coeff_1 = Math.PI / 4d;
double coeff_2 = 3d * coeff_1;
double abs_y = Math.abs(y);
double angle;
if (x >= 0d) {
double r = (x - abs_y) / (x + abs_y);
angle = coeff_1 - coeff_1 * r;
} else {
double r = (x + abs_y) / (abs_y - x);
angle = coeff_2 - coeff_1 * r;
}
return y < 0d ? -angle : angle;
}
 
*/
public int distance2wp(int id)
{
return "" + val/10000000 + "^" + ((val%10000000)*60)/10000000 + "'" + ((((val%10000000)*60)%10000000)*60)/10000000 + "." + ((((val%10000000)*60)%10000000)*60)%10000000;
double lat1=(Latitude/10000000.0)*RADIANS;
double long1=(Longitude/10000000.0)*RADIANS;
 
double lat2=(LatWP[id]/10000000.0)*RADIANS;
double long2=(LongWP[id]/10000000.0)*RADIANS;
 
 
double dLat= (lat2-lat1);
double dLon= (long2-long1);
 
double a = Math.sin(dLat/2.0) * Math.sin(dLat/2.0) +
Math.cos(lat1) * Math.cos(lat2) *
Math.sin(dLon/2.0) * Math.sin(dLon/2.0);
 
return (int)(( 2.0 * aTan2(Math.sqrt(a), Math.sqrt(1.0-a)) )*6371008.8);
}
 
 
public String WP_Latitude_min_sec(int id)
 
 
public int angle2wp(int id)
{
// TODO reuse from distance
double lat1=(Latitude/10000000.0)*RADIANS;
double long1=(Longitude/10000000.0)*RADIANS;
 
double lat2=(LatWP[id]/10000000.0)*RADIANS;
double long2=(LongWP[id]/10000000.0)*RADIANS;
 
 
double dLat= (lat2-lat1);
double dLon= (long2-long1);
 
return "" + dec_to_min_sec(LatWP[id])+ "''N" ;
 
double y = Math.sin(dLon) * Math.cos(lat2);
double x = Math.cos(lat1)*Math.sin(lat2) - Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon);
return ((int)(aTan2(y, x)*DEGREES)+360)%360;
 
}
 
public String WP_Longitude_min_sec(int id)
 
 
public void push_wp()
{
return "" + dec_to_min_sec(LongWP[id])+ "''E" ;
LongWP[last_wp]=Longitude;
LatWP[last_wp]=Latitude;
 
last_wp++;
}
 
public void next_gps_format()
{
act_gps_format=(byte)((act_gps_format+1)%GPS_FORMAT_COUNT);
}
 
public String act_gps_format_str(int val)
{
switch(act_gps_format)
{
case GPS_FORMAT_DECIMAL:
return "" + val/10000000 + "." +val%10000000 ;
case GPS_FORMAT_MINSEC:
return "" + val/10000000 + "^" + ((val%10000000)*60)/10000000 + "'" + ((((val%10000000)*60)%10000000)*60)/10000000 + "." + ((((val%10000000)*60)%10000000)*60)%10000000;
default:
return "invalid format";
}
}
 
public String Latitude_min_sec()
public String WP_Latitude_str(int id)
{
return "" + dec_to_min_sec(Latitude)+ "''N" ;
return "" + act_gps_format_str(LatWP[id]); //+ "''N" ;
}
 
public String Longitude_min_sec()
public String WP_Longitude_str(int id)
{
return "" + dec_to_min_sec(Longitude)+ "''E" ;
return "" + act_gps_format_str(LongWP[id]); //+ "''E" ;
 
}
 
public String Latitude_str()
{
return "" + Latitude/10000000 + "." +Latitude%10000000 ;
return "" + act_gps_format_str(Latitude) ;
}
 
public String Longitude_str()
{
return "" + Longitude/10000000 + "." +Longitude%10000000 ;
return "" + act_gps_format_str(Longitude) ;
 
}
 
 
// Constructor
public MKGPSPosition()
{
 
LongWP=new int[MAX_WAYPOINTS];
LatWP=new int[MAX_WAYPOINTS];
 
NameWP=new String[MAX_WAYPOINTS];
// predefined waypoints
 
 
LongWP[0]=123230170;
LatWP[0]= 513600170 ;
NameWP[0]="Sicherer PC1";
 
LongWP[1]=123269000;
LatWP[1]= 513662670;
NameWP[1]="Sicherer PC2";
 
LongWP[2]=123475570;
LatWP[2]= 513569750 ;
NameWP[2]="Treffpunkt Seba";
 
 
last_wp=2;
}
 
private int parse_arr(int offset,int[] in_arr)
102,16 → 332,11
{
Longitude=parse_arr(0,in_arr);
Latitude=parse_arr(4,in_arr);
 
TargetLongitude=parse_arr(8,in_arr);
TargetLatitude=parse_arr(12,in_arr);
 
Distance2Target=parse_arr(16,in_arr);
Angle2Target=parse_arr(20,in_arr);
Used_Sat=(byte)in_arr[24];
 
}
 
 
 
}
/DUBwise/src/J2ME/src/MKLCD.java
81,37 → 81,48
else if ((init_state==2)&&(act_mk_page!=0))
{ init_state=3; act_key=2; }
 
if(init_state==2)act_key=2;
 
}
lcd_buf[act_mk_page][row]="";
for(int foo=0;foo<20;foo++)
lcd_buf[act_mk_page][row]+=(char)data[foo];
// if((init_state==3)&&(act_mk_page==0))
// init_state=-1;
// else
 
if (init_state==-1) // init over
{
if (act_mk_page<act_user_page)
act_key=2;
else
if (act_mk_page>act_user_page)
act_key=1;
if (act_mk_page==act_user_page)
act_key=0;
 
}
else if (init_state==3)
 
else if (row==3)
{
if (row==3)
if ((init_state==3))
{
if(act_mk_page==pages-1)
if((act_mk_page==0)||(act_mk_page==pages-1))
init_state=-1;
else
act_key=2;
 
}
 
if (init_state==-1) // init over
{
if (act_mk_page<act_user_page)
act_key=2;
else
if (act_mk_page>act_user_page)
act_key=1;
if (act_mk_page==act_user_page)
act_key=0;
}
 
}
lcd_buf[act_mk_page][row]="";
for(int foo=0;foo<20;foo++)
lcd_buf[act_mk_page][row]+=(char)data[foo];
 
}
 
boolean init=true;
/DUBwise/src/J2ME/src/MKParamsEditor.java
17,7 → 17,7
 
 
private int act_tab=0;
private int act_y=0;
public int act_y=0;
private int act_lcd_lines=10;
 
DUBwiseCanvas canvas;
/DUBwise/src/J2ME/src/MKParamsParser.java
26,9 → 26,9
public final static int[] all_lengths={58,58,65,70};
// -- end generated code --
 
*/
--- old 2
 
 
// -- start generated code --
public final static int PARAMTYPE_BYTE=0;
public final static int PARAMTYPE_BITSWITCH=1;
41,12 → 41,27
public final static int[] all_lengths={58,58,65,70,83};
// -- end generated code --
 
*/
 
 
public final static int MAX_PARAMSETS=20;
// -- start generated code --
public final static int PARAMTYPE_BYTE=0;
public final static int PARAMTYPE_BITSWITCH=1;
public final static int PARAMTYPE_STICK=2;
public final static String[][] all_tab_names={{"Altitude","Camera","Channels","Configuration","Gyro","Other","Stick","User"},{"Altitude","Camera","Channels","Configuration","Gyro","Looping","Other","Stick","User"},{"Altitude","Camera","Channels","Configuration","Coupling","Gyro","Looping","Other","Stick","User"},{"Altitude","Camera","Channels","Configuration","Coupling","Gyro","Looping","Other","Stick","User"},{"Altitude","Camera","Channels","Configuration","Coupling","Gyro","Looping","Navi","Other","Output","Stick","User"},{"Altitude","Camera","Channels","Configuration","Coupling","Gyro","Looping","Navi","Other","Output","Stick","User"}};
public final static String[][][] all_field_names={{{"Min. Accelerate","Barometric D","Setpoint","Altitude P","Gain","Z-ACC"},{"Servo control","Nick compensation","Servo min","Servo max","Refresh rate","Invert Direction"},{"Nick","Roll","Accelerate","Gier","POTI1","POTI2","POTI3","POTI4"},{"ALTITUDE_CONTROL","Switch for Setpoint","Heading Hold","Compas Active","GPS"},{"ACC/Gyro Factor","P-Rate","I-Rate"},{"Min Gas","Max Gas","Compass Effect","Voltage Warning","Distress Gas","Distress Gas Time"},{"Nick/Roll P","Nick/Roll D","Gier P"},{"Param 1","Param 2","Param 3","Param 4"}},{{"Min. Accelerate","Barometric D","Setpoint","Altitude P","Gain","Z-ACC"},{"Servo control","Nick compensation","Servo min","Servo max","Refresh rate","Invert Direction"},{"Nick","Roll","Accelerate","Gier","POTI1","POTI2","POTI3","POTI4"},{"ALTITUDE_CONTROL","Switch for Setpoint","Heading Hold","Compas Active","GPS"},{"ACC/Gyro Factor","P-Rate","I-Rate"},{"Gas Limit","Threshold","UP","DOWN","LEFT","RIGHT"},{"Min Gas","Max Gas","Compass Effect","Voltage Warning","Distress Gas","Distress Gas Time"},{"Nick/Roll P","Nick/Roll D","Gier P"},{"Param 1","Param 2","Param 3","Param 4"}},{{"Min. Accelerate","Barometric D","Setpoint","Altitude P","Gain","Z-ACC"},{"Servo control","Nick compensation","Servo min","Servo max","Refresh rate","Invert Direction"},{"Nick","Roll","Accelerate","Gier","POTI1","POTI2","POTI3","POTI4"},{"ALTITUDE_CONTROL","Switch for Setpoint","Heading Hold","Compas Active","Compas Fix","GPS","Coupling","Yaw Rate Limiter"},{"Yaw pos. feedback","Yaw neg. feedback"},{"ACC/Gyro Factor","P-Rate","I-Rate","ACC/Gyro Comp","Drift-Compensation"},{"Gas Limit","Threshold","Hysterese","TurnOver Nick","TurnOver Roll","UP","DOWN","LEFT","RIGHT"},{"Min Gas","Max Gas","Compass Effect","Voltage Warning","Distress Gas","Distress Gas Time"},{"Nick/Roll P","Nick/Roll D","Gier P"},{"Param 1","Param 2","Param 3","Param 4"}},{{"Min. Accelerate","Barometric D","Setpoint","Altitude P","Gain","Z-ACC"},{"Servo control","Nick compensation","Servo min","Servo max","Refresh rate","Invert Direction"},{"Nick","Roll","Accelerate","Gier","POTI1","POTI2","POTI3","POTI4"},{"ALTITUDE_CONTROL","Switch for Setpoint","Heading Hold","Compas Active","Compas Fix","GPS","Coupling","Yaw Rate Limiter"},{"Yaw pos. feedback","Yaw neg. feedback"},{"ACC/Gyro Factor","P-Rate","I-Rate","ACC/Gyro Comp","Drift-Compensation","Dynamic stability"},{"Gas Limit","Threshold","Hysterese","TurnOver Nick","TurnOver Roll","UP","DOWN","LEFT","RIGHT"},{"Min Gas","Max Gas","Compass Effect","Voltage Warning","Distress Gas","Distress Gas Time"},{"Nick/Roll P","Nick/Roll D","Gier P"},{"Param 1","Param 2","Param 3","Param 4","Param 5","Param 6","Param 7","Param 8"}},{{"Min. Accelerate","Barometric D","Setpoint","Altitude P","Gain","Z-ACC"},{"Servo control","Nick compensation","Servo min","Servo max","Refresh rate","Invert Direction"},{"Nick","Roll","Accelerate","Gier","POTI1","POTI2","POTI3","POTI4"},{"ALTITUDE_CONTROL","Switch for Setpoint","Heading Hold","Compas Active","Compas Fix","GPS","Coupling","Yaw Rate Limiter"},{"Yaw pos. feedback","Yaw neg. feedback"},{"ACC/Gyro Factor","P-Rate","I-Rate","ACC/Gyro Comp","Drift-Compensation","Dynamic stability"},{"Gas Limit","Threshold","Hysterese","TurnOver Nick","TurnOver Roll","UP","DOWN","LEFT","RIGHT"},{"Mode Control","GPS-Gain","GPS-P","GPS-I","GPS-D","GPS-ACC","Satelite Minimum","Stick Threhsold"},{"Min Gas","Max Gas","Compass Effect","Voltage Warning","Distress Gas","Distress Gas Time"},{"J16 Bitmask","J16 Timing","J17 Bitmask","J17 Timing"},{"Nick/Roll P","Nick/Roll D","Gier P","External Control"},{"Param 1","Param 2","Param 3","Param 4","Param 5","Param 6","Param 7","Param 8"}},{{"Min. Accelerate","Barometric D","Setpoint","Altitude P","Gain","Z-ACC","3-Way switch"},{"Servo control","Nick compensation","Servo min","Servo max","Refresh rate","Invert Direction"},{"Nick","Roll","Accelerate","Gier","POTI1","POTI2","POTI3","POTI4"},{"ALTITUDE_CONTROL","Switch for Setpoint","Heading Hold","Compas Active","Compas Fix","GPS","Coupling","Yaw Rate Limiter"},{"Yaw pos. feedback","Yaw neg. feedback"},{"ACC/Gyro Factor","P-Rate","I-Rate","ACC/Gyro Comp","Drift-Compensation","Dynamic stability"},{"Gas Limit","Threshold","Hysterese","TurnOver Nick","TurnOver Roll","UP","DOWN","LEFT","RIGHT"},{"Mode Control","GPS-Gain","GPS-P","GPS-I","GPS-D","GPS-ACC","Satelite Minimum","Stick Threhsold","Wind Correction","Speed Compensation","Operating Radius"},{"Min Gas","Max Gas","Compass Effect","Voltage Warning","Distress Gas","Distress Gas Time"},{"J16 Bitmask","J16 Timing","J17 Bitmask","J17 Timing"},{"Nick/Roll P","Nick/Roll D","Gier P","External Control"},{"Param 1","Param 2","Param 3","Param 4","Param 5","Param 6","Param 7","Param 8"}}};
public final static int[][][] all_field_positions={{{9,10,11,12,13,14},{33,34,35,36,37,304},{0,1,2,3,4,5,6,7},{64,65,66,67,69},{20,22,23},{18,19,21,24,25,26},{15,16,17},{29,30,31,32}},{{9,10,11,12,13,14},{33,34,35,36,37,328},{0,1,2,3,4,5,6,7},{64,65,66,67,69},{20,22,23},{38,39,320,321,322,323},{18,19,21,24,25,26},{15,16,17},{29,30,31,32}},{{9,10,11,12,13,14},{33,34,35,36,37,384},{0,1,2,3,4,5,6,7},{64,65,66,67,68,69,70,71},{41,42},{20,22,23,45,46},{38,39,40,43,44,376,377,378,379},{18,19,21,24,25,26},{15,16,17},{29,30,31,32}},{{9,10,11,12,13,14},{33,34,35,36,37,424},{0,1,2,3,4,5,6,7},{64,65,66,67,68,69,70,71},{41,42},{20,22,23,45,46,47},{38,39,40,43,44,416,417,418,419},{18,19,21,24,25,26},{15,16,17},{29,30,31,32,48,49,50,51}},{{9,10,11,12,13,14},{33,34,35,36,37,528},{0,1,2,3,4,5,6,7},{64,65,66,67,68,69,70,71},{41,42},{20,22,23,45,46,47},{38,39,40,43,44,520,521,522,523},{56,57,58,59,60,61,62,63},{18,19,21,24,25,26},{52,53,54,55},{15,16,17,64},{29,30,31,32,48,49,50,51}},{{9,10,11,12,13,14,548},{33,34,35,36,37,552},{0,1,2,3,4,5,6,7},{64,65,66,67,68,69,70,71},{41,42},{20,22,23,45,46,47},{38,39,40,43,44,544,545,546,547},{56,57,58,59,60,61,62,63,64,65,66},{18,19,21,24,25,26},{52,53,54,55},{15,16,17,67},{29,30,31,32,48,49,50,51}}};
public final static int[][][] all_field_types={{{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BITSWITCH},{PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK},{PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE}},{{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BITSWITCH},{PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK},{PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE}},{{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BITSWITCH},{PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK},{PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH},{PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE}},{{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BITSWITCH},{PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK},{PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH},{PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE}},{{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BITSWITCH},{PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK},{PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH},{PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE}},{{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BITSWITCH},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BITSWITCH},{PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK,PARAMTYPE_STICK},{PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH},{PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE}}};
public final static int[] all_name_positions={46,46,53,58,71,74};
public final static int[] all_lengths={58,58,65,70,83,86};
// -- end generated code --
 
 
public final static int MAX_PARAMSETS=5;
// public final static int MAX_PARAMLENGTH=100;
 
public int[][] field;
public int[][] field_bak;
public String[] names={"Paramset 1","Paramset 2","Paramset 3","Paramset 4","Paramset 5"};
 
public int act_paramset=0;
77,9 → 92,14
public MKParamsParser()
{
field=new int[MAX_PARAMSETS][];
field_bak=new int[MAX_PARAMSETS][];
for (int ii=0;ii<MAX_PARAMSETS;ii++)
field[ii]=null;
{
field[ii]=null;
field_bak[ii]=null;
}
 
}
104,7 → 124,21
 
 
 
public void use_backup()
{
for ( int i=0 ; i<field[act_paramset].length;i++)
field[act_paramset][i]=field_bak[act_paramset][i];
}
 
public void update_backup()
{
for ( int i=0 ; i<field[act_paramset].length;i++)
field_bak[act_paramset][i]=field[act_paramset][i];
 
}
 
 
 
public void set_by_mk_data(int paramset_num,int[] in_arr,MKVersion version)
{
117,9 → 151,13
length=all_lengths[version.compatible-4];
 
field[paramset_num]=new int[length];
field_bak[paramset_num]=new int[length];
 
for ( int i=0;i<length;i++)
for ( int i=0;i<length;i++)
{
field[paramset_num][i]=in_arr[i];
field_bak[paramset_num][i]=in_arr[i];
}
names[paramset_num]="" + (paramset_num+1) +": ";
for ( int i=name_start;i<length;i++)
{
/DUBwise/src/J2ME/src/MKProxy.java
5,27 → 5,46
implements Runnable
{
 
public boolean connected;
public String url;
public String err_str="none";
StreamConnection connection;
 
public java.io.InputStream reader;
public java.io.OutputStream writer;
public java.io.OutputStream writer;
 
public MKProxy(String url)
public void connect(String url_)
{
url=url_;
 
try
{
connection = (StreamConnection) Connector.open(url, Connector.READ_WRITE);
reader=connection.openInputStream();
writer=connection.openOutputStream();
connected=true;
}
 
}
catch (Exception e)
{
err_str=e.toString();
// err_str=e.toString();
// this=null;
 
connected=false;
}
 
}
 
public void write(int input)
{
if (connected)
try{ writer.write(input);
if (input==13) writer.flush();
 
}
catch(Exception e) { connected=false; }
}
public void run()
{
/DUBwise/src/J2ME/src/MKStatusVoice.java
71,7 → 71,7
try {
try {
player = Manager.createPlayer(getClass().getResourceAsStream(name+".mp3"), "audio/mp3");
player = Manager.createPlayer(getClass().getResourceAsStream(name+".mp3"), "audio/mp3");
}
catch (Exception e) {
player = Manager.createPlayer(getClass().getResourceAsStream(name+".wav"), "audio/x-wav");
90,10 → 90,7
player.start();
}
catch (Exception e) {
 
 
 
}
}
108,6 → 105,7
 
}
 
int info_from_debug_set=-1;
public void run()
{
while(true)
117,19 → 115,22
if (mk.connected&&(canvas.do_sound)&&(mk.debug_data.UBatt()!=-1)&&(!mk.force_disconnect))
{
int ubatt=mk.debug_data.UBatt();
 
start_playing(""+(ubatt/10));
wait_for_end();
 
if((ubatt%10)!=0)
if (info_from_debug_set!=mk.debug_data_count)
{
start_playing("komma");
info_from_debug_set=mk.debug_data_count;
start_playing(""+(ubatt/10));
wait_for_end();
start_playing(""+(ubatt%10));
wait_for_end();
if((ubatt%10)!=0)
{
start_playing("komma");
wait_for_end();
start_playing(""+(ubatt%10));
wait_for_end();
}
start_playing("volt");
}
start_playing("volt");
}
 
/DUBwise/src/J2ME/src/MKWatchDog.java
29,27 → 29,39
int lcd_timeout=0; // detect if we lost packets
 
public int act_paramset=0;
int conn_check_timeout=0;
 
public void run()
{
 
 
// get all params
int act_debug_name=0;
 
 
while(true)
{
 
try { Thread.sleep(30); } // 3000
try { Thread.sleep(100); } // 3000
catch (Exception e) { }
if (mk.connected&&(!mk.force_disconnect))
{
 
if (debug_data_count_buff==mk.debug_data_count)
{
mk.debug.log("timeout:" +conn_check_timeout );
conn_check_timeout++;
if (conn_check_timeout==100)
{
mk.debug.log("disconnecting");
mk.close_connections(false);
conn_check_timeout=0;
}
debug_data_count_buff=mk.debug_data_count;
}
else
conn_check_timeout=0;
 
 
if ( mk.version.major==-1 )
{
try { Thread.sleep(150); }
60,7 → 72,7
{
mk.get_params(act_paramset+1);
try { Thread.sleep(450); }
try { Thread.sleep(350); }
catch (Exception e) { }
if(mk.params.field[act_paramset]!=null)
70,13 → 82,19
{
mk.get_debug_name(act_debug_name);
try { Thread.sleep(350); }
try { Thread.sleep(150); }
catch (Exception e) { }
 
if (mk.debug_data.got_name[act_debug_name]) act_debug_name++;
}
/*else if ((mk.root.canvas.user_intent==USER_INTENT_RAWDEBUG) || (mk.root.canvas.user_intent==USER_INTENT_GRAPH) )
{
mk.trigger_debug();
try { Thread.sleep(100); }
catch (Exception e) { }
}
*/
 
112,20 → 130,23
}
*/
 
else if ((lcd_data_count_buff!=mk.lcd_data_count)||(mk.lcd_data_count==0)||(lcd_timeout==23))
else
{
lcd_timeout=0;
lcd_data_count_buff=mk.lcd_data_count;
mk.LCD.trigger_LCD();
try { Thread.sleep(50); }
catch (Exception e) { }
//debug_data_count_buff=mk.debug_data_count;
if ((lcd_data_count_buff!=mk.lcd_data_count)||(mk.lcd_data_count==0)||(lcd_timeout==23))
{
lcd_timeout=0;
lcd_data_count_buff=mk.lcd_data_count;
mk.LCD.trigger_LCD();
try { Thread.sleep(50); }
catch (Exception e) { }
//debug_data_count_buff=mk.debug_data_count;
}
else
{
lcd_timeout++;
}
}
else
{
lcd_timeout++;
}