Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 381 → Rev 382

/DUBwise/trunk/j2me/src/BTSearcher.java
50,12 → 50,7
 
remote_device_count=0;
}
 
public void search()
{
searching=true;
remote_device_count=0;
try
{
//First get the local device and obtain the discovery agent.
70,9 → 65,9
log("Problem in searching the blue tooth devices\n" + ex);
}
 
}
 
 
public void inquiryCompleted(int transID) {
 
try {
/DUBwise/trunk/j2me/src/DUBwise.java
8,10 → 8,13
*
************************************************************************/
 
 
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
 
//#if j2memap=="on"
import com.eightmotions.map.MapDisplay;
import com.eightmotions.util.UtilMidp;
//#endif
public class DUBwise
extends MIDlet
 
29,22 → 32,53
display.vibrate(duration);
}
 
//#if j2memap=="on"
MapDisplay m_map;
Canvas map_canvas;
//#endif
 
protected void startApp()
throws MIDletStateChangeException
{
if (loaded)
{
System.out.println("app already loaded");
display.setCurrent(canvas);
return; // when allready done -> do not do it again
}
 
if (loaded)return;
display = Display.getDisplay(this);
canvas=new DUBwiseCanvas(this);
// m_map.init();
// Display.getDisplay(this).setCurrent(m_map.getCanvas());
 
// fire up canvas
display.setCurrent(canvas);
loaded=true;
//#if j2memap=="on"
UtilMidp.checkMIDP(this); //Initialise the utility library...
m_map=new MapDisplay();
m_map.setModeProxy(true);
map_canvas=m_map.getCanvas();
//#endif
 
display = Display.getDisplay(this);
canvas=new DUBwiseCanvas(this);
 
// fire up canvas
display.setCurrent(canvas);
loaded=true;
// System.out.println("DUBwise start done");
}
 
public void quit() { notifyDestroyed(); }
protected void pauseApp() {} // not needed right now
protected void destroyApp(boolean arg0) { }
public void quit() {
destroyApp(true);
notifyDestroyed();
}
protected void pauseApp() {
quit();
System.out.println("app paused");
}
 
protected void destroyApp(boolean arg0)
{
}
 
}
/DUBwise/trunk/j2me/src/DUBwiseCanvas.java
9,18 → 9,87
 
import javax.microedition.lcdui.*;
 
import javax.microedition.media.*;
import javax.microedition.media.control.*;
//#if j2memap=="on"
import com.eightmotions.map.*;
import com.eightmotions.util.UtilMidp;
//#endif
 
//#if jsr179=="on"
import javax.microedition.location.*;
//#endif
 
//#if openlapi=="on"
import com.openlapi.*;
//#endif
 
import javax.microedition.rms.*;
import java.io.*;
 
 
import org.ligi.ufo.MKFirmwareFlasher;
import org.ligi.ufo.DUBwiseDefinitions;
import org.ligi.ufo.DUBwiseLangDefs;
import org.ligi.ufo.MKCommunicator;
import org.ligi.ufo.MKFirmwareHelper;
 
 
public class DUBwiseCanvas
extends Canvas
implements Runnable,org.ligi.ufo.DUBwiseDefinitions , DUBwiseUIDefinitions,org.ligi.ufo.DUBwiseLangDefs
implements Runnable,DUBwiseDefinitions , DUBwiseUIDefinitions,DUBwiseLangDefs
 
//#if (location=="on")&&(cldc11=="on")
,LocationListener
//#endif
{
 
//#if (location=="on")&&(cldc11=="on")
public void providerStateChanged(javax.microedition.location.LocationProvider p ,int i )
{
}
public void locationUpdated(LocationProvider lp, Location loc)
{
try
{
Coordinates coords = loc.getQualifiedCoordinates();
if (coords != null)
{
phone_long = coords.getLongitude();
phone_lat = coords.getLatitude();
if (mk!=null)
{
mk.lat=(long)phone_lat*10000000;
mk.lon=(long)phone_long*10000000;
 
}
// Start thread for handling the new coordinates
// (...)
}
else
{
phone_lat=-1.0;
phone_long=-1.0;
 
 
}
}
catch (Exception e)
{
// handle the exception
// (...)
}
}
 
//#endif
//#expand public final static byte version_patch=%VERSION_PATCH%;
//#expand public final static byte version_minor=%VERSION_MINOR%;
//#expand public final static byte version_major=%VERSION_MAJOR%;
 
public final static String version_str="" +version_major + "." + version_minor +"" +(char)('a'+version_patch) ;
 
 
public final static int[] param_menu_items={STRINGID_EDIT_SETTINGS,STRINGID_COPY_TO_MOBILE,STRINGID_LOAD_FROM_MOBILE,STRINGID_REINITIALIZE_ALL,STRINGID_BACK};
public final static byte[] param_menu_actions={ACTIONID_SELECT_PARAMS,ACTIONID_PARAM_COPY_MOBILE,ACTIONID_PARAM_LOAD_MOBILE,ACTIONID_RESET_PARAMS,ACTIONID_MAINMENU};
 
36,28 → 105,37
public final static byte[] back_to_conndetails_actions={ACTIONID_BACK_TO_CONNDETAILS};
 
 
 
public int[] beta_unlock_code={Canvas.KEY_NUM2,Canvas.KEY_NUM3,Canvas.KEY_NUM8,Canvas.KEY_NUM2};
 
int beta_unlock_pos=0;
 
//#if fileapi=="on"
DUBwiseFileAccess file_access;
//#endif
 
 
 
MixerManager mixer_manager;
MotorTester motor_tester;
 
String act_input_str=" ";
// for dual use of states
boolean select_paramset4edit;
 
//#if (location=="on")&&(cldc11=="on")
Criteria cr= null;
 
LocationProvider lp= null;
Coordinates c=null;
 
 
//#if jsr179=="on"
//#endif
 
 
javax.microedition.location.Criteria cr= null;
 
javax.microedition.location.LocationProvider lp= null;
 
 
//#endif
 
String act_msg="";
boolean read_paramset_intension_save;
boolean ipinput4proxy;
70,17 → 148,54
int canvas_height=100;
 
 
 
int heading_offset=0;
int act_wp;
 
long key_bitfield=0;
 
 
boolean debug_overlay=false;
 
public long keyCode2mask(int keyCode)
{
if ((keyCode>=KEY_NUM0)&&(keyCode<=KEY_NUM9))
return 1<<(keyCode-KEY_NUM0);
else
switch (getGameAction( keyCode ))
{
case UP:
return 1<<10;
case DOWN:
return 1<<11;
case LEFT:
return 1<<12;
case RIGHT:
return 1<<13;
case FIRE:
return 1<<14;
}
// log("unmapped key");
return 0; // cant translate
}
 
//#if bluetooth=="on"
private BTSearcher bt_scanner;
//#endif
 
public org.ligi.ufo.MKCommunicator mk=null;
public MKCommunicator mk=null;
// private MKStatistics mk_stat=null;
private MKParamsEditor act_editor=null;
 
/*
private MKParamsEditor params_editor=null;
private MKParamsEditor settings_editor=null;
private MKParamsEditor motor_tester=null;
 
*/
 
public MKFirmwareFlasher firmware_flasher=null;
public DUBwiseDebug debug=null;
public FirmwareLoader fw_loader=null;
 
95,8 → 210,8
 
private DUBwise root;
public DUBwiseSettings settings;
// public UFOProber mk.ufo_prober;
 
 
private Image bg_img;
private Image lcd_img;
private Image symbols_img;
108,14 → 223,18
private Image err_img;
 
 
int max_lines;
private Image icon_img;
 
 
byte max_lines;
 
 
/*
public byte act_motor=0;
public byte act_motor_increase=0;
public boolean motor_test_sel_all=false;
*/
 
 
/* Graph Vars */
public final static int GRAPH_COUNT=4;
// public final static int[] graph_colors={0x156315,0xCC1315,0xf8ef02,0x19194d};
156,13 → 275,13
int spacer_medium=0;
int spacer_large=0;
 
int[] motor_test = {0,0,0,0};
// int[] motor_test = {0,0,0,0};
 
String[] menu_items;
byte[] menu_actions;
int act_menu_select=0;
int[] act_menu_select_bak;
byte act_menu_select=0;
byte[] act_menu_select_bak;
String[] lcd_lines =null;
 
 
218,7 → 337,7
public void setup_conn_menu()
{
tmp_menu_init(7);
tmp_menu_init(10);
 
if (mk.connected)
{
242,36 → 361,51
 
public void setup_main_menu()
{
tmp_menu_init(20);
tmp_menu_init(30);
 
tmp_menu_add(l(STRINGID_SETTINGS),ACTIONID_SETTING_OPTIONS);
tmp_menu_add(l(STRINGID_CONN),ACTIONID_CONN_DETAILS);
 
 
if (settings.dev_mode)
{
tmp_menu_add(l(STRINGID_SELECT_FIRMWARE),ACTIONID_SELECT_FIRMWARE);
tmp_menu_add("UPDATE_DUBWISE",ACTIONID_UPDATE_DUBWISE);
// tmp_menu_add(l(STRINGID_SELECT_FIRMWARE),ACTIONID_SELECT_FIRMWARE);
// tmp_menu_add("UPDATE_DUBWISE",ACTIONID_UPDATE_DUBWISE);
// tmp_menu_add("Follow Me",ACTIONID_SHOWPHONEGPS);
 
tmp_menu_add("File Open",ACTIONID_SELECT_DUBWISEDIR);
tmp_menu_add(l(STRINGID_DEBUG),ACTIONID_DEBUG);
}
 
 
if (settings.expert_mode)
tmp_menu_add(l(STRINGID_DEBUG),ACTIONID_DEBUG);
 
 
 
// only mk
if (mk.ufo_prober.is_mk())
if (mk.is_mk())
{
tmp_menu_add(l(STRINGID_MOTORTEST),ACTIONID_MOTORTEST);
tmp_menu_add(l(STRINGID_KEYCONTROL),ACTIONID_KEYCONTROL);
tmp_menu_add(l(STRINGID_RCDATA),ACTIONID_RCDATA);
tmp_menu_add(l(STRINGID_FLIGHTSETTINGS),ACTIONID_PARAM_MENU);
tmp_menu_add(l(STRINGID_GRAPH),ACTIONID_GRAPH);
 
tmp_menu_add("Mixer",ACTIONID_SELECT_MIXER);
}
 
if ( mk.is_rangeextender()|| mk.is_followme() )
{
tmp_menu_add(l(STRINGID_LCD),ACTIONID_LCD);
tmp_menu_add(l(STRINGID_DEBUG_VALUES),ACTIONID_RAWDEBUG);
}
 
// mk & navi
if ( mk.ufo_prober.is_navi()||mk.ufo_prober.is_mk() )
 
if ( mk.is_navi()||mk.is_mk() )
{
 
tmp_menu_add(l(STRINGID_COCKPIT),ACTIONID_HORIZON);
tmp_menu_add(l(STRINGID_LCD),ACTIONID_LCD);
}
278,14 → 412,25
 
 
 
if (( mk.ufo_prober.is_navi()||mk.ufo_prober.is_mk()||mk.ufo_prober.is_mk3mag() ))
if (( mk.is_navi()||mk.is_mk()||mk.is_mk3mag() ))
tmp_menu_add(l(STRINGID_DEBUG_VALUES),ACTIONID_RAWDEBUG);
 
 
// only navi
if ( mk.ufo_prober.is_navi())
if ( mk.is_navi())
{
if (settings.dev_mode) tmp_menu_add("Follow Me",ACTIONID_SHOWPHONEGPS);
 
 
//#if j2memap=="on"
tmp_menu_add("Map",ACTIONID_MAP);
//#endif
 
 
//#if (location=="on")&&(cldc11=="on")
tmp_menu_add("Follow Me",ACTIONID_SHOWPHONEGPS);
//#endif
 
tmp_menu_add(l(STRINGID_VIEW_GPS),ACTIONID_GPSDATA);
if (mk.gps_position.ErrorCode!=0) tmp_menu_add(l(STRINGID_VIEW_ERRORS),ACTIONID_NC_ERRORS);
tmp_menu_add(l(STRINGID_SWITCH_FC),ACTIONID_SWITCH_FC);
293,16 → 438,16
 
}
 
if (mk.ufo_prober.is_mk()||mk.ufo_prober.is_mk3mag() )
if (mk.is_mk()||mk.is_mk3mag() )
tmp_menu_add(l(STRINGID_SWITCH_NAVI),ACTIONID_SWITCH_NC);
 
 
//if ((settings.expert_mode)&& ( mk.ufo_prober.is_navi()||mk.ufo_prober.is_mk()||mk.ufo_prober.is_mk3mag()||mk.ufo_prober.is_incompatible() ))
if (settings.expert_mode)
if ((settings.expert_mode)||mk.is_mk())
tmp_menu_add(l(STRINGID_FLASH_FIRMWARE),ACTIONID_FLASH);
if (settings.dev_mode&& mk.ufo_prober.is_mk() )
if (settings.dev_mode&& mk.is_mk() )
tmp_menu_add(l(STRINGID_REMOTE_CAM),ACTIONID_CAM);
 
if (!settings.expert_mode)
313,7 → 458,6
tmp_menu_use();
}
 
 
public void setup_menu(String[] items , byte[] actions)
{
if ((menu_items==null)||(act_menu_select>=menu_items.length))
355,6 → 499,9
paint_lcd(g);
}
 
 
// int selected_fw=
 
public void menu_keypress(int keyCode)
{
debug.log("Menu with KeyCode:"+keyCode);
364,7 → 511,7
if (act_menu_select!=0)
act_menu_select--;
else
act_menu_select=menu_items.length-1;
act_menu_select=(byte)(menu_items.length-1);
break;
case DOWN:
378,6 → 525,19
switch(state)
{
 
case STATEID_SELECT_MIXER:
if (act_menu_select<menu_items.length-1)
mk.set_mixer_table(mixer_manager.bytes(act_menu_select));
else
chg_state(STATEID_MAINMENU);
 
break;
 
case STATEID_SELECT_FIRMWARE:
 
fw_loader.menu_fire(act_menu_select);
break;
case STATEID_SELECT_COMPORT:
if (act_menu_select<menu_items.length)
connect_mk("comm:"+menu_items[act_menu_select]+";baudrate=57600","com"+act_menu_select);
411,13 → 571,13
{
mk.params.act_paramset=act_menu_select;
chg_state(STATEID_HANDLE_PARAMS);
//success_msg="Params saved";
//act_msg="Params saved";
}
else
{
mk.write_params(act_menu_select);
nextstate=STATEID_HANDLE_PARAMS;
success_msg="saved in slot " + (act_menu_select+1) ;
act_msg="saved in slot " + (act_menu_select+1) ;
chg_state(STATEID_SUCCESS_MSG); // TODO - ground too optimistic way ;-)
}
 
467,7 → 627,7
int y;
// int lcd_top= (state==STATEID_EDIT_PARAMS?0:25);
//int lcd_top= 25;
max_lines=(canvas_height-25/*lcd_top*/)/lcd_char_height;
max_lines=(byte)((canvas_height-25/*lcd_top*/)/lcd_char_height);
int spacer_left_right=(canvas_width-(20*(lcd_img.getWidth()/222)))/2;
// for(int i=0;i<lcd_lines.length;i++)
 
474,7 → 634,10
int display_lines=(lcd_lines.length>max_lines?max_lines:lcd_lines.length);
 
 
lcd_off= (((state==STATEID_EDIT_PARAMS)&&(!params_editor.select_mode))?params_editor.act_y:act_menu_select)-display_lines+1;
lcd_off=act_menu_select-display_lines+1;
if (((act_editor!=null)&&(!act_editor.select_mode)))
lcd_off=act_editor.act_y-display_lines+1;
 
if ( lcd_off<0) lcd_off=0;
 
for(int i=0;i<display_lines;i++)
525,6 → 688,7
{
try
{
icon_img=Image.createImage("/i.png");
symbols_img=Image.createImage("/symbols.png");
symbols_img_tile_height=symbols_img.getHeight()/3;
symbols_img_tile_width=symbols_img.getWidth()/10;
546,7 → 710,7
 
public void load_strings()
{
System.out.println("loading strings");
// System.out.println("loading strings");
localized_strings=new String[STRING_COUNT];
try {
554,9 → 718,8
for (int i=0;i<STRING_COUNT;i++)
{
System.out.println("s"+i);
String tmp_s="";
String tmp_b="";
String tmp_s=""; // temp string to use
String tmp_b=""; // backup string ( if string isnt present in selected lang - e.g. same as in english )
char ch=0;
 
int act_l=0;
563,15 → 726,15
while ( (ch=(char)in.read())!='\n')
{
if (ch==';')
{
act_l++;
tmp_s="";
}
act_l++;
else
{
// "backup" str
if (act_l==0)
tmp_b+=ch;
// normal str
if (act_l==act_lang)
tmp_s+=ch;
}
578,11 → 741,12
}
 
 
if (tmp_s.equals(""))
localized_strings[i]=tmp_b;
else
localized_strings[i]=tmp_s;
System.out.println("s"+localized_strings[i]);
 
}
}
catch (Exception e) { System.out.println("str_load err"+e);}
592,47 → 756,51
// construct
public DUBwiseCanvas(DUBwise _root)
{
 
int foo=0;
 
//
load_strings();
 
act_menu_select_bak=new int[STATEID_COUNT];
act_menu_select_bak=new byte[STATEID_COUNT];
 
for (int i=0;i<STATEID_COUNT;i++)
act_menu_select_bak[i]=0;
 
//#if fileapi=="on"
file_access=new DUBwiseFileAccess(this);
//#endif
 
 
root=_root;
 
mk = new org.ligi.ufo.MKCommunicator();
mixer_manager = new MixerManager();
settings = new DUBwiseSettings(this);
 
try {
settings.load();
}
catch ( Exception e) {}
 
//#if voice_mode!="no_voice"
status_voice=new MKStatusVoice(mk,this);
//#endif
load_global_images();
 
settings = new DUBwiseSettings(this);
settings.load();
load_global_images();
debug = new DUBwiseDebug(this);
 
//#if bluetooth=="on"
bt_scanner = new BTSearcher();
//#endif
 
 
//#if voice_mode!="no_voice"
status_voice=new MKStatusVoice(this);
//#endif
// mk.gps_position.act_speed_format=settings.speed_format;
/// mk.gps_position.act_gps_format= settings.gps_format;
 
chg_state(STATEID_MAINMENU);
 
new Thread(this).start();
 
if (settings.connection_url!="")
connect_mk(settings.connection_url,settings.connection_name);
}
 
public void refresh_dynamic_menues()
640,8 → 808,11
if (state==STATEID_MAINMENU)
chg_state(STATEID_MAINMENU); // reload mainmenu ( changed content )
if (state==STATEID_CONN_DETAILS)
chg_state(STATEID_CONN_DETAILS); // reload mainmenu ( changed content )
chg_state(STATEID_CONN_DETAILS); // reload con details ( changed content )
}
 
 
 
/****************************** Thread ******************/
// ticking runnable Section
649,6 → 820,20
{
while(true)
{
if ((firmware_flasher!=null))
{
if (mk!=null)
{
mk.close_connections(true);
mk=null;
}
if (!firmware_flasher.started)
firmware_flasher.start();
}
 
if ( key_bitfield==(keyCode2mask(KEY_NUM1)|keyCode2mask(KEY_NUM3)))
debug_overlay=!debug_overlay;
 
try {
 
 
662,86 → 847,155
frame_pos++;
 
// handle Device Change
if (mk.ufo_prober.change_notify)
if (mk!=null)
{
mk.ufo_prober.change_notify=false;
if ((mk.ufo_prober.is_incompatible())&&(settings.instant_error_show))
if (mk.mixer_change_notify)
{
mk.error_str=l(STRINGID_INCOMPATIBLEDEVICE);
chg_state(STATEID_ERROR_MSG);
nextstate=STATEID_MAINMENU;
if (mk.mixer_change_success)
{
act_msg="Mixer Write OK";
chg_state(STATEID_SUCCESS_MSG);
}
else
{
act_msg="Mixer Write Fail";
chg_state(STATEID_ERROR_MSG);
}
mk.mixer_change_notify=false;
}
else
refresh_dynamic_menues();
 
// handle Device Change
if (mk.change_notify)
{
mk.change_notify=false;
if ((mk.is_incompatible())&&(settings.instant_error_show))
{
act_msg=l(STRINGID_INCOMPATIBLEDEVICE);
chg_state(STATEID_ERROR_MSG);
}
else
refresh_dynamic_menues();
if (state==STATEID_ERROR_MSG)
chg_state(STATEID_MAINMENU);
}
if (mk.disconnect_notify)
{
mk.disconnect_notify=false;
if (!mk.mk_url.equals("")&&(settings.instant_error_show))
{
if (settings.instant_error_show)
{
nextstate=STATEID_MAINMENU;
act_msg=l(STRINGID_DISCONNECT);
chg_state( STATEID_ERROR_MSG);
}
if (settings.do_vibra)
root.vibrate(100);
}
}
if (mk.is_navi())
{
if ((last_navi_error==0)&&(mk.gps_position.ErrorCode!=0))
{
if (settings.instant_error_show)
{
nextstate=state;
act_msg=null;
chg_state( STATEID_ERROR_MSG);
}
if (settings.do_vibra)
root.vibrate(100);
}
else
if ((last_navi_error!=0)&&(mk.gps_position.ErrorCode==0)&&(state== STATEID_ERROR_MSG))
chg_state(nextstate);
else if (last_navi_error!=mk.gps_position.ErrorCode)
act_msg=null;
last_navi_error=(byte)mk.gps_position.ErrorCode;
}
}
 
if (mk.disconnect_notify)
switch(state)
{
mk.disconnect_notify=false;
if (settings.instant_error_show)
 
//#if fileapi=="on"
case STATEID_FILEOPEN:
file_access.refresh_if_dirty();
break;
//#endif
 
 
case STATEID_GET_AVRSIG:
if (firmware_flasher.job_done)
{
nextstate=STATEID_MAINMENU;
mk.error_str=l(STRINGID_DISCONNECT);
chg_state( STATEID_ERROR_MSG);
fw_loader=new FirmwareLoader(firmware_flasher.avr_sig,this);
firmware_flasher.exit_bootloader();
firmware_flasher=null;
chg_state(STATEID_SELECT_FIRMWARE);
}
if (settings.do_vibra)
root.vibrate(100);
}
break;
 
if (mk.ufo_prober.is_navi())
{
if ((last_navi_error==0)&&(mk.gps_position.ErrorCode!=0))
case STATEID_FLASHING:
if (firmware_flasher.job_done)
{
 
if (settings.instant_error_show)
if (firmware_flasher.success)
{
nextstate=state;
mk.error_str=null;
chg_state( STATEID_ERROR_MSG);
nextstate=STATEID_MAINMENU;
act_msg="Flashing OK";
chg_state(STATEID_SUCCESS_MSG);
}
if (settings.do_vibra)
root.vibrate(100);
else
{
nextstate=STATEID_MAINMENU;
act_msg="Flashing Fail";
chg_state(STATEID_ERROR_MSG);
}
}
else
if ((last_navi_error!=0)&&(mk.gps_position.ErrorCode==0)&&(state== STATEID_ERROR_MSG))
chg_state(nextstate);
else if (last_navi_error!=mk.gps_position.ErrorCode)
mk.error_str=null;
last_navi_error=(byte)mk.gps_position.ErrorCode;
}
break;
 
 
switch(state)
{
//#if (location=="on")&&(cldc11=="on")
 
 
//#if jsr179=="on"
case STATEID_SHOWPHONEGPS:
 
try
{
Class.forName("javax.microedition.location.LocationProvider");
// Class.forName("javax.microedition.location.LocationProvider");
 
if ((cr==null)||(lp==null))
if ((lp==null))
// if ((cr==null)||(lp==null))
{
javax.microedition.location.Criteria cr= new javax.microedition.location.Criteria();
cr.setHorizontalAccuracy(500);
//Criteria cr= new Criteria();
//cr.setHorizontalAccuracy(500);
// Get an instance of the provider
javax.microedition.location.LocationProvider lp= javax.microedition.location.LocationProvider.getInstance(cr);
// LocationProvider lp= LocationProvider.getInstance(cr);
lp= LocationProvider.getInstance(null);
lp.setLocationListener(this, 1, -1, -1);
 
}
// Request the location, setting a one-minute timeout
 
javax.microedition.location.Location l = lp.getLocation(60);
javax.microedition.location.Coordinates c = l.getQualifiedCoordinates();
else if (false){
 
Location l = lp.getLocation(10);
c = l.getQualifiedCoordinates();
 
 
 
/* low crit
 
Criteria crit2 = new Criteria();
764,11 → 1018,15
phone_long = c.getLongitude();
//#endif
}
}
}
catch (Exception e)
{
mk.error_str="Phone GPS Problem";
chg_state(STATEID_ERROR_MSG);
debug.log("Follow ME Err" );
debug.log("-" + e );
debug.log("-" + e.getMessage() );
// act_msg="Phone GPS Problem";
// chg_state(STATEID_ERROR_MSG);
}
776,19 → 1034,24
//#endif
case STATEID_SELECT_FIRMWARE:
if ((menu_items.length==0)&&(fw_loader.got_list))
setup_menu(fw_loader.names,null);
break;
 
 
// if ((menu_items.length==0)&&(fw_loader.got_list))
// setup_menu(fw_loader.names,null);
break;
case STATEID_RESET_PARAMS:
 
if (mk.bootloader_finish_ok)
// if (mk.bootloader_finish_ok)
if (firmware_flasher.job_done)
{
mk.params.reset();
mk.watchdog.act_paramset=0;
// mk.params.reset();
//mk.watchdog.act_paramset=0;
nextstate=STATEID_PARAM_MENU;
success_msg=l(STRINGID_PARAMRESETOK);
act_msg=l(STRINGID_PARAMRESETOK);
firmware_flasher.exit_bootloader();
firmware_flasher=null;
chg_state(STATEID_SUCCESS_MSG);
}
break;
810,7 → 1073,7
{
cam_img=null;
debug.log("get snap\n");
cam_raw = mVideoControl.getSnapshot(null);
//xda cam_raw = mVideoControl.getSnapshot(null);
try { Thread.sleep(4000); }
838,7 → 1101,7
 
case STATEID_ERROR_MSG:
lcd_lines[0]=""+mk.error_str;
lcd_lines[0]=""+act_msg;
break;
 
847,7 → 1110,7
if (param_masswrite_write_pos==5)
{
nextstate=STATEID_PARAM_MENU;
success_msg=l(STRINGID_PARAMWRITEOK);
act_msg=l(STRINGID_PARAMWRITEOK);
chg_state(STATEID_SUCCESS_MSG);
}
else
907,7 → 1170,7
// chg_state(STATEID_COPY_PARAMS);
 
nextstate=STATEID_PARAM_MENU;
success_msg="Parameter Copy OK";
act_msg="Parameter Copy OK";
chg_state(STATEID_SUCCESS_MSG);
}
927,7 → 1190,7
if (mk.params.found_incompatible)
{
mk.error_str="incompatible params";
act_msg="incompatible params";
chg_state(STATEID_ERROR_MSG);
}
936,7 → 1199,7
 
case STATEID_MOTORTEST:
 
/*
if (motor_test_sel_all)
for (int m=0;m<4;m++)
{
951,7 → 1214,8
if (motor_test[act_motor]>255) motor_test[act_motor]=255;
}
 
mk.motor_test(motor_test);
mk.motor_test(motor_test);*/
mk.motor_test(motor_tester.engine_field);
break;
 
case STATEID_STRINGINPUT:
1031,13 → 1295,14
 
//#if devicecontrol=="on"
 
try {
Class.forName("com.nokia.mid.ui.DeviceControl");
if (settings.keep_lighton) com.nokia.mid.ui.DeviceControl.setLights(0,100);
if (mk.connected&&settings.keep_lighton) com.nokia.mid.ui.DeviceControl.setLights(0,100);
 
}
catch (Exception e) { }
catch (Exception e)
{
// cannot do anything helpfull here
}
//#endif
sleeptime=1000/ 15 - (int) (System.currentTimeMillis()- loopStartTime);
1113,8 → 1378,11
}
 
 
Font font_medium,font_small,font_large;
 
 
 
boolean regenerate_fonts=true;
// drawing sections
public void paint(Graphics g) {
1121,7 → 1389,6
canvas_width=this.getWidth();
canvas_height=this.getHeight();
 
 
if (debug.showing)
{
debug.paint(g);
1128,32 → 1395,46
return;
}
 
 
if (firstrun)
{
if (settings.fullscreen) setFullScreenMode(settings.fullscreen);
firstrun=false;
}
if (regenerate_fonts)
{
if (settings.big_fonts)
{
font_small = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_LARGE);
font_medium = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_LARGE);
font_large = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE);
 
}
else
{
font_small = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
font_medium = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
font_large = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE);
}
spacer_medium=(font_medium.getHeight());
spacer_small=(font_small.getHeight());
spacer_large=(font_large.getHeight());
regenerate_fonts=false;
}
 
y_off=0;
try {
 
 
 
Font font_medium = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
Font font_small = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
Font font_large = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE);
 
spacer_medium=(font_medium.getHeight());
spacer_small=(font_small.getHeight());
spacer_large=(font_large.getHeight());
 
//default Font
g.setFont(font_medium);
 
 
//draw background
if (settings.do_scrollbg)
if ((settings.do_scrollbg)&&(bg_img!=null))
{
g.setColor(0xFFFFFF);
g.fillRect(0,0,canvas_width,canvas_height);
1180,80 → 1461,86
{
g.setClip(bar*(symbols_img_tile_width),0,(symbols_img_tile_width),symbols_img_tile_height);;
g.drawImage(symbols_img,bar*(symbols_img_tile_width),0, g.TOP | g.LEFT);
 
}
 
int symbol_left=0;
int symbol_spacer=5;
 
g.setClip(symbol_left,0,symbols_img_tile_width,symbols_img_tile_height);;
if (mk.connected)
symbol_paint(g,symbol_left,(((mk.stats.bytes_in>>3)&1)==1)?2:3,0);
 
else
if (mk!=null)
{
if (mk.mk_url.startsWith("btspp://"))
symbol_paint(g,symbol_left,1,0);
int symbol_left=0;
int symbol_spacer=5;
 
}
// g.drawImage(symbols_img,(-1)*(symbols_img.getWidth()/10),0, g.TOP | g.LEFT);
g.setClip(symbol_left,0,symbols_img_tile_width,symbols_img_tile_height);;
if (mk.connected)
symbol_paint(g,symbol_left,(((mk.stats.bytes_in>>3)&1)==1)?2:3,0);
 
 
 
symbol_left+=6*(symbols_img_tile_width)/4;
 
 
if ((mk.ufo_prober.is_navi()||mk.ufo_prober.is_mk()))
{
 
symbol_paint(g,symbol_left,4,0);
symbol_left+=5 *(symbols_img_tile_width)/4;
 
if ((mk.UBatt()/100)!=0)
else
{
symbol_paint(g,symbol_left,(mk.UBatt()/100),1);
symbol_left+=(symbols_img_tile_width);
if (mk.mk_url.startsWith("btspp://"))
symbol_paint(g,symbol_left,1,0);
}
 
symbol_paint(g,symbol_left,(mk.UBatt()/10)%10,1);
symbol_left+=(2*symbols_img_tile_width/3);
symbol_paint(g,symbol_left,9,0);
symbol_left+=(2*symbols_img_tile_width/3);
symbol_paint(g,symbol_left,(mk.UBatt())%10,1);
// g.drawImage(symbols_img,(-1)*(symbols_img.getWidth()/10),0, g.TOP | g.LEFT);
symbol_left+=6*(symbols_img_tile_width)/4;
 
 
// g.drawString("" + (mk.UBatt()/10) + "," +(mk.UBatt()%10)+"V" , symbol_left,y_off,Graphics.TOP | Graphics.LEFT);
 
 
//symbol_left+= g.getFont().stringWidth("88,8V");//;
/*
symbol_paint(g,symbol_left,6,0);
symbol_left+=5*(symbols_img_tile_width)/4;
*/
if (mk.UBatt()!=-1)
{
symbol_paint(g,symbol_left,4,0);
symbol_left+=5 *(symbols_img_tile_width)/4;
if ((mk.UBatt()/100)!=0)
{
symbol_paint(g,symbol_left,(mk.UBatt()/100),1);
symbol_left+=(symbols_img_tile_width);
}
symbol_paint(g,symbol_left,(mk.UBatt()/10)%10,1);
symbol_left+=(2*symbols_img_tile_width/3);
symbol_paint(g,symbol_left,9,0);
symbol_left+=(2*symbols_img_tile_width/3);
symbol_paint(g,symbol_left,(mk.UBatt())%10,1);
symbol_left+=6*(symbols_img_tile_width)/4;
// g.drawString("" + (mk.UBatt()/10) + "," +(mk.UBatt()%10)+"V" , symbol_left,y_off,Graphics.TOP | Graphics.LEFT);
//symbol_left+= g.getFont().stringWidth("88,8V");//;
/*
symbol_paint(g,symbol_left,6,0);
symbol_left+=5*(symbols_img_tile_width)/4;
*/
}
if (mk.SenderOkay()>0)
{
symbol_paint(g,symbol_left,6,0);
symbol_left+=5*(symbols_img_tile_width)/4;
/*symbol_paint(g,symbol_left,(mk.SenderOkay())/100,1);
symbol_left+=(symbols_img_tile_width);
symbol_paint(g,symbol_left,(mk.SenderOkay()/10)%10,1);
symbol_left+=(symbols_img_tile_width);*/
}
// symbol_paint(g,symbol_left,(mk.SenderOkay())%10,1);
//symbol_left+=6*(symbols_img_tile_width)/4;
/*symbol_paint(g,symbol_left,(mk.SenderOkay())/100,1);
symbol_left+=(symbols_img_tile_width);
// g.drawString(""+mk.SenderOkay() ,symbol_left,y_off,Graphics.TOP | Graphics.LEFT);
//symbol_left+= g.getFont().stringWidth("8")+symbol_spacer_medium; //,0,(symbols_img.getWidth()/10)+2;
 
symbol_paint(g,symbol_left,(mk.SenderOkay()/10)%10,1);
symbol_left+=(symbols_img_tile_width);*/
}
// symbol_paint(g,symbol_left,(mk.SenderOkay())%10,1);
//symbol_left+=6*(symbols_img_tile_width)/4;
 
// g.drawString(""+mk.SenderOkay() ,symbol_left,y_off,Graphics.TOP | Graphics.LEFT);
 
//symbol_left+= g.getFont().stringWidth("8")+symbol_spacer_medium; //,0,(symbols_img.getWidth()/10)+2;
 
 
 
 
if (mk.ufo_prober.is_navi())
if (mk.is_navi())
{
if (mk.gps_position.ErrorCode!=0)
{
1260,44 → 1547,47
symbol_paint(g,symbol_left,7,0);
symbol_left+=5*(symbols_img_tile_width)/4;
}
 
if ((mk.gps_position.NCFlags&2)!=0)
{
symbol_paint(g,symbol_left,8,0);
symbol_left+=5*(symbols_img_tile_width)/4;
}
 
 
if ((mk.gps_position.NCFlags&4)!=0)
{
symbol_paint(g,symbol_left,0,2);
symbol_left+=5*(symbols_img_tile_width)/4;
}
 
if ((mk.gps_position.NCFlags&8)!=0)
{
symbol_paint(g,symbol_left,0,2);
symbol_left+=5*(symbols_img_tile_width)/4;
}
}
 
if (mk.SatsInUse()!=-1)
{
symbol_paint(g,symbol_left,5,0);
symbol_left+=5*(symbols_img_tile_width)/4;
 
symbol_paint(g,symbol_left,(mk.gps_position.SatsInUse)%10,1);
symbol_paint(g,symbol_left,(mk.SatsInUse())%10,1);
symbol_left+=6*(symbols_img_tile_width)/4;
 
}
 
}
 
 
// unclip
} // if mk!=null
// unclip
g.setClip(0,0,canvas_width,canvas_height);
 
y_off+=symbols_img_tile_height;
graph_height=(canvas_height-y_off)/2;
line_middle_y=graph_height+y_off;
1305,6 → 1595,12
switch(state)
{
//#if j2memap=="on"
case STATEID_MAP:
 
root.m_map.paint(g);
break;
//#endif
case STATEID_HORIZON:
 
g.setStrokeStyle(Graphics.SOLID);
1353,7 → 1649,7
g.fillArc((canvas_width-nick_size)/2- nick_pixels_x, horizon_middle-nick_size/2+ nick_pixels_y, nick_size, nick_size, 0,360);
 
 
if (mk.ufo_prober.is_navi())
if (mk.is_navi())
{
g.setColor(0xCC2233);
g.fillArc((canvas_width-nick_size)/2- nick_pixels_x, horizon_middle-nick_size/2+ nick_pixels_y, nick_size, nick_size, -mk.gps_position.CompasHeading-45/2 +90 +mk.stats.heading_start,45);
1401,7 → 1697,7
 
 
g.setFont(font_small);
if (mk.ufo_prober.is_navi())
if (mk.is_navi())
g.drawString("avg:" + mk.stats.avg_speed() + " max:"+ mk.stats.max_speed,10-c,y_off-c,Graphics.BOTTOM | Graphics.LEFT);
g.drawString(" max:"+ mk.stats.max_alt/10,canvas_width-10-c,y_off-c,Graphics.BOTTOM | Graphics.RIGHT);
1411,7 → 1707,7
g.setFont(font_large);
if (mk.ufo_prober.is_navi())
if (mk.is_navi())
g.drawString("" + mk.gps_position.GroundSpeed_str() ,10-c*3,y_off-c*3,Graphics.BOTTOM | Graphics.LEFT);
else
if (settings.horizon_display_flytime) g.drawString("" + mk.stats.flying_time()+"s" ,10-c*3,y_off-c*3,Graphics.BOTTOM | Graphics.LEFT);
1419,7 → 1715,7
if (settings.horizon_display_altitude) g.drawString( mk.Alt_formated()/* + "/"+status_voice.last_alt*/ ,canvas_width-10-c*3,y_off-c*3,Graphics.BOTTOM | Graphics.RIGHT);
y_off-=spacer_large;
if (mk.ufo_prober.is_navi()&&(settings.horizon_display_flytime))
if (mk.is_navi()&&(settings.horizon_display_flytime))
{
g.setFont(font_medium);
g.drawString("" + mk.stats.flying_time()+"s" ,10-c*2,y_off-c*2,Graphics.BOTTOM | Graphics.LEFT);
1429,7 → 1725,23
break;
 
case STATEID_DUBWISE_VALUES:
 
g.setFont(font_small);
 
//#if voice_mode!="no_voice"
g.drawString("voice_loop_cnt"+status_voice.loop_cnt ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_small;
 
g.drawString("voice_volts_cnt"+ status_voice.volts_play_cnt ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_small;
 
g.drawString("do volts sound"+ settings.do_volts_sound ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_small;
//#endif
break;
case STATEID_DATABUFF:
 
g.setFont(font_small);
 
int lines2paint=(((canvas_height-y_off)/spacer_small));
1557,16 → 1869,27
 
break;
 
case STATEID_GET_AVRSIG:
case STATEID_RESET_PARAMS:
case STATEID_FLASHING:
g.setFont(font_small);
int msg_pos=0;
while (mk.flash_msgs[msg_pos]!=null)
g.drawString("Initializing Bootloader" ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_small;
 
if ((frame_pos%3)!=0) g.drawString("Please Wait!" ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_small;
 
while (firmware_flasher.flash_msgs[msg_pos]!=null)
{
g.drawString(mk.flash_msgs[msg_pos] ,0,y_off,Graphics.TOP | Graphics.LEFT);
g.drawString(firmware_flasher.flash_msgs[msg_pos] ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_small;
msg_pos++;
}
 
g.drawString("mk:" + (mk==null) ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_small;
 
break;
 
case STATEID_CAMMODE:
1573,8 → 1896,12
 
if (cam_img!=null)
g.drawImage(cam_img,0,0,g.TOP | g.LEFT);
g.drawString("condition: " + cam_condition() ,0,y_off,Graphics.TOP | Graphics.LEFT);
g.drawString("condition: stick" +settings.remote_cam_stick + " (act:" +mk.stick_data.stick[settings.remote_cam_stick] +",thres:100) =>" + cam_condition() ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_medium;
 
 
 
y_off+=spacer_medium;
g.drawString("width " + cam_img.getWidth(),0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_medium;
g.drawString("height " + cam_img.getHeight(),0,y_off,Graphics.TOP | Graphics.LEFT);
1620,7 → 1947,13
break;
 
case STATEID_MOTORTEST:
// case STATEID_MOTORTEST:
// motor_tester.paint(g);
 
 
/*
 
for (int bar=0;bar<4;bar++)
 
{
1632,10 → 1965,17
}
g.setColor(skin_fg_color());
g.drawString(""+mk.debug_data.analog[2]+"<->"+mk.debug_data.analog[3] ,0,canvas_height-30,Graphics.TOP | Graphics.LEFT);
 
 
 
break;
*/
case STATEID_EDIT_PARAMS:
case STATEID_SETTINGSMENU:
case STATEID_MOTORTEST:
 
case STATEID_EDIT_PARAMS:
params_editor.paint(g);
act_editor.paint(g);
 
break;
 
 
1649,16 → 1989,30
//#endif
 
 
//#if (location=="on")&&(cldc11=="on")
 
 
case STATEID_SHOWPHONEGPS:
//#if cldc11=="on"
 
y_off+=spacer_medium;
g.drawString("lat" + phone_lat ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_medium;
g.drawString("long" + phone_long ,0,y_off,Graphics.TOP | Graphics.LEFT);
//#endif
 
 
y_off+=spacer_medium;
g.drawString("cr" + (cr!=null) ,0,y_off,Graphics.TOP | Graphics.LEFT);
 
y_off+=spacer_medium;
g.drawString("LocationProvider" + (lp!=null) ,0,y_off,Graphics.TOP | Graphics.LEFT);
 
y_off+=spacer_medium;
g.drawString("Coordinates" + (c!=null) ,0,y_off,Graphics.TOP | Graphics.LEFT);
 
break;
 
 
//#endif
case STATEID_SELECT_MIXER:
case STATEID_SELECT_FIRMWARE:
case STATEID_SELECT_COMPORT:
case STATEID_PARAM_MENU:
1717,7 → 2071,7
g.drawString(" Name:" + mk.name,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_small;
 
g.drawString(" "+mk.ufo_prober.extended_name()+ " (" + (mk.connected?("open"+((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s"):"closed")+"):",0,y_off,Graphics.TOP | Graphics.LEFT);
g.drawString(" "+mk.extended_name()+ " (" + (mk.connected?("open"+((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s"):"closed")+"):",0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_small;
g.drawString(" Software Version:" + mk.version.version_str ,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_small;
1739,9 → 2093,10
g.drawString( ">>in:"+mk.stats.bytes_in+ " bytes => " + mk.stats.bytes_in/mk.conn_time_in_s() + " bytes/s",0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_small;
 
g.drawString( " crcFail:"+mk.stats.crc_fail +" unknown:" +mk.stats.other_data_count,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_small;
 
 
 
g.drawString( " debug:"+mk.stats.debug_data_count+ " LCD:" + mk.stats.lcd_data_count + " vers:" + mk.stats.version_data_count,0,y_off,Graphics.TOP | Graphics.LEFT);
y_off+=spacer_small;
g.drawString( " rc:"+mk.stats.stick_data_count+" params:"+mk.stats.params_data_count + " GPS:"+mk.stats.navi_data_count ,0,y_off,Graphics.TOP | Graphics.LEFT);
1748,8 → 2103,8
y_off+=spacer_small;
g.drawString( " debug_names:" + mk.stats.debug_names_count + " angles:" + mk.stats.angle_data_count ,0,y_off,Graphics.TOP | Graphics.LEFT);
 
y_off+=spacer_small;
g.drawString( " other:"+mk.stats.other_data_count,0,y_off,Graphics.TOP | Graphics.LEFT);
//y_off+=spacer_small;
// g.drawString( " other:"+mk.stats.other_data_count,0,y_off,Graphics.TOP | Graphics.LEFT);
 
y_off+=spacer_small+3;
g.drawString( "<<out:"+mk.stats.bytes_out + " bytes =>" + mk.stats.bytes_out/mk.conn_time_in_s() + "bytes/s", 0,y_off,Graphics.TOP | Graphics.LEFT);
1777,11 → 2132,7
 
break;
 
case STATEID_SETTINGSMENU:
 
settings_editor.paint(g);
break;
 
// falltru wanted
case STATEID_SETTING_OPTIONS:
case STATEID_MAINMENU:
1889,8 → 2240,9
 
if (p<mk.debug_buff_lastset)
 
draw_graph_part(g,x,mk.debug_buff[p][gr]/line_scaler,mk.debug_buff[p+1][gr]/line_scaler);
// draw_graph_part(g,x,mk.debug_buff[p][gr]/line_scaler,mk.debug_buff[p+1][gr]/line_scaler);
 
g.drawLine(x,line_middle_y-mk.debug_buff[p][gr]/line_scaler,x+1,line_middle_y-mk.debug_buff[p+1][gr]/line_scaler);
// System.out.println("--p"+p + "gr " + gr + " l " + mk.debug_buff.length +" ls:" + mk.debug_buff_lastset );
}
1974,9 → 2326,32
 
} catch (Exception e) { System.out.println("error in paint " + e);}
 
 
if (debug_overlay)
{
 
for(int debug_line=0;debug_line<5;debug_line++)
for ( int bar=0;bar<canvas_width/(symbols_img.getWidth()/10)+1;bar++)
{
g.setClip(bar*(symbols_img_tile_width),canvas_height-(debug_line+1)*symbols_img_tile_height,(symbols_img_tile_width),symbols_img_tile_height);;
g.drawImage(symbols_img,bar*(symbols_img_tile_width),canvas_height-(debug_line+1)*symbols_img_tile_height, g.TOP | g.LEFT);
}
 
g.setColor(0);
g.setClip(0,0,canvas_width,canvas_height);
g.drawString("freeMemory:" + Runtime.getRuntime().freeMemory() ,0,canvas_height-spacer_small,Graphics.TOP | Graphics.LEFT);
g.drawString("totalMemory:" + Runtime.getRuntime().totalMemory() ,0,canvas_height-2*spacer_small,Graphics.TOP | Graphics.LEFT);
 
g.drawString("state:" + state ,0,canvas_height-3*spacer_small,Graphics.TOP | Graphics.LEFT);
g.drawString("key_bitfield:" + key_bitfield ,0,canvas_height-4*spacer_small,Graphics.TOP | Graphics.LEFT);
 
}
 
 
}
Player mPlayer;
VideoControl mVideoControl;
//xda Player mPlayer;
//xda VideoControl mVideoControl;
Image cam_img;
Image last_cam_img;
int cam_img_seq=0;
1990,31 → 2365,12
mk.connect_to(url,name);
}
 
/*
public void draw_graph_part(Graphics g,int x,int y1,int y2)
{
 
g.drawLine(x,line_middle_y-y1,x+1,line_middle_y-y2);
/*
if ( canvas_width>200)
{
g.fillRect(x,line_middle_y-y1,1,1 );
if (y1>y2)
g.fillRect(x,line_middle_y-y1,1,y1-y2);
else
g.fillRect(x,line_middle_y-y2,1,y2-y1);
 
}
else
{
g.fillRect(x,line_middle_y-y1,1,1 );
if (y1>y2)
g.fillRect(x,line_middle_y-y1,1,y1-y2);
else
g.fillRect(x,line_middle_y-y2,1,y2-y1);
}
*/
}
*/
 
 
/*********************************************** input Section **********************************************/
2026,20 → 2382,53
// int intro_str_pos=0;
// int intro_str_delay=3;
// boolean init_bootloader=false;
String success_msg="";
 
 
 
 
 
public void chg_state(byte next_state)
{
if ((next_state!=STATEID_ERROR_MSG)&&(next_state!=STATEID_SETTINGSMENU))
settings_editor = null;
params_editor = null;
//#if bluetooth=="on"
if (next_state!=STATEID_DEVICESELECT)
bt_scanner=null;
//#endif
if (firmware_flasher!=null)
{
firmware_flasher.exit_bootloader();
firmware_flasher=null;
}
 
if ((mk==null))
{
if ((next_state!=STATEID_SELECT_FIRMWARE)&&(next_state!=STATEID_FLASHING))
{
mk = new MKCommunicator();
settings.process_all_settings(); // TODO remove
if (settings.connection_url!="")
connect_mk(settings.connection_url,settings.connection_name);
}
 
}
else
{
mk.watchdog.resend_timeout=0;
 
mk.destroy_debug_buff();
mk.user_intent=USER_INTENT_NONE;
mk.set_debug_interval(mk.default_abo);
mk.set_gpsosd_interval(mk.default_abo);
}
if (next_state!=STATEID_ERROR_MSG)
{
act_editor = null;
motor_tester=null;
}
 
err_img=null;
// graph_data=null;
mk.destroy_debug_buff();
mk.user_intent=USER_INTENT_NONE;
mk.set_debug_interval(100);
mk.set_gpsosd_interval(100);
 
act_menu_select_bak[state]=act_menu_select;
act_menu_select=act_menu_select_bak[next_state];
 
2058,20 → 2447,31
switch(next_state)
 
{
// case STATEID_COPY_PARAMS:
//break;
 
case STATEID_MOTORTEST:
motor_tester=new MotorTester();
act_editor=new MKParamsEditor(this,motor_tester,STATEID_MAINMENU);
break;
 
case STATEID_SELECT_MIXER:
setup_menu(DUBwiseHelper.combine_str_arr(mixer_manager.names,new String[] {"back"}),null);
break;
 
 
case STATEID_SETTING_OPTIONS:
setup_menu(setting_options_menu_items,setting_options_menu_actions);
break;
 
case STATEID_SHOWPHONEGPS:
mk.user_intent=USER_INTENT_FOLLOWME;
break;
 
case STATEID_GPSVIEW:
 
mk.user_intent=USER_INTENT_GPSOSD;
break;
case STATEID_SELECT_FIRMWARE:
fw_loader=new FirmwareLoader();
setup_menu(new String[0],new byte[0]);
setup_menu(fw_loader.names,null);
break;
 
 
2079,7 → 2479,7
case STATEID_ERROR_MSG:
lcd_lines=new String[1];
lcd_lines[0]=""+((next_state==STATEID_SUCCESS_MSG)?success_msg:mk.error_str);
lcd_lines[0]=act_msg;
try
{
err_img=Image.createImage("/preflight.jpg");
2091,7 → 2491,7
break;
case STATEID_EDIT_PARAMS:
params_editor = new MKParamsEditor(this,mk.params,STATEID_HANDLE_PARAMS);
act_editor = new MKParamsEditor(this,mk.params,STATEID_HANDLE_PARAMS);
break;
case STATEID_STRINGINPUT:
lcd_lines=new String[2];
2104,20 → 2504,36
break;
case STATEID_RESET_PARAMS:
 
mk.bootloader_intension_flash=false;
firmware_flasher=new MKFirmwareFlasher(settings.connection_url,MKFirmwareHelper.BOOTLOADER_INTENSION_RESET_PARAMS);
 
 
/* mk.bootloader_intension_flash=false;
mk.bl_retrys=0;
mk.init_bootloader=true;
mk.init_bootloader=true;*/
break;
 
case STATEID_FLASHING:
 
firmware_flasher=new MKFirmwareFlasher(settings.connection_url,MKFirmwareHelper.BOOTLOADER_INTENSION_FLASH_FIRMWARE);
firmware_flasher.in=fw_loader.get_input_str();
 
/*
mk.bootloader_intension_flash=true;
mk.bl_retrys=0;
mk.init_bootloader=true;
*/
break;
 
case STATEID_GET_AVRSIG:
 
firmware_flasher=new MKFirmwareFlasher(settings.connection_url,MKFirmwareHelper.BOOTLOADER_INTENSION_GET_SIG);
 
 
break;
 
//#if fileapi=="on"
case STATEID_FILEOPEN:
file_access.trigger();
file_access.dirty=true;
break;
//#endif
 
2132,9 → 2548,11
 
case STATEID_ABOUT:
lcd_lines=credits;
lcd_lines[1]=" ufo-lib: " + mk.lib_version_str();
act_menu_select=max_lines-1;
lcd_lines[CREDITS_VERSION]= "Version: V" + version_str;
lcd_lines[CREDITS_VERSION+1]="Lib Vers.: " + mk.lib_version_str();
act_menu_select=(byte)(max_lines-1);
break;
 
case STATEID_CONN_DETAILS:
setup_conn_menu();//conn_details_menu_items,conn_details_menu_actions);
break;
2147,6 → 2565,7
setup_menu(onlyback_menu_items,back_to_conndetails_actions);
break;
case STATEID_CAMMODE:
/*xda
mk.user_intent=USER_INTENT_RCDATA;
if (mVideoControl==null)
try
2172,8 → 2591,8
{
debug.log(e.toString());
}
*/
 
 
break;
case STATEID_KEYCONTROL:
mk.user_intent= USER_INTENT_EXTERNAL_CONTROL;
2210,7 → 2629,9
lcd_lines[2]="found";
 
mk.close_connections(true);
bt_scanner.search();
 
bt_scanner = new BTSearcher();
 
break;
//#endif
 
2247,8 → 2668,8
break;
 
case STATEID_SETTINGSMENU:
if (settings_editor==null)
settings_editor = new MKParamsEditor(this,settings,STATEID_MAINMENU);
// if (settings_editor==null)
act_editor = new MKParamsEditor(this,settings,STATEID_MAINMENU);
 
break;
 
2258,8 → 2679,8
 
case STATEID_HORIZON:
// mk.user_intent=USER_INTENT_GRAPH;
if (mk.ufo_prober.is_navi())
mk.set_debug_interval(3);
if (mk.is_navi())
mk.set_debug_interval(mk.secondary_abo);
break;
 
case STATEID_GRAPH:
2284,8 → 2705,9
break;
 
}
mk.watchdog.resend_timeout=0;
 
 
 
// switch state
state=next_state;
} // void chg_state
2294,11 → 2716,18
public void keyReleased(int keyCode)
{
if (state==STATEID_MAP)
key_bitfield=0;
else
key_bitfield&=(0xFFFFFFFF)^keyCode2mask(keyCode);
 
switch(state)
{
case STATEID_MOTORTEST:
act_motor_increase=0;
break;
/*
case STATEID_MOTORTEST:
act_motor_increase=0;
break;
*/
case STATEID_KEYCONTROL:
if (keyCode==KEY_POUND)
2379,10 → 2808,68
double phone_long=0.0;
//#endif
 
//#if j2memap=="on"
 
Marker ufo_marker,home_marker;
//#endif
public void process_action(byte actionid)
{
switch(actionid)
{
 
case ACTIONID_SELECT_MIXER:
chg_state(STATEID_SELECT_MIXER);
break;
 
case ACTIONID_SELECT_DUBWISEDIR:
chg_state(STATEID_FILEOPEN);
break;
 
//#if j2memap=="on"
case ACTIONID_MAP:
 
 
int default_zoom=14; // TODO calc of distance - kopter<>home
 
try {
 
 
 
// ufo_marker=new Marker(UtilMidp.parseFloat(""+(mk.gps_position.Longitude/10000000d)),UtilMidp.parseFloat(""+(mk.gps_position.Latitude/10000000d)));
 
ufo_marker=new Marker(UtilMidp.parseFloat(mk.gps_position.gps_format_str(mk.gps_position.Longitude,GPS_FORMAT_DECIMAL)),UtilMidp.parseFloat(mk.gps_position.gps_format_str(mk.gps_position.Latitude,GPS_FORMAT_DECIMAL)));
ufo_marker.iconImage=icon_img;
ufo_marker.m_type=MarkerStyle.ICON_IMAGE;
ufo_marker.name="Kopter";
ufo_marker.description="This is the Kopter!";
 
root.m_map.m_listMyPlaces.addElement(ufo_marker);
 
root.m_map.gotoLonLat(UtilMidp.parseFloat(mk.gps_position.gps_format_str(mk.gps_position.Longitude,GPS_FORMAT_DECIMAL)),UtilMidp.parseFloat(mk.gps_position.gps_format_str(mk.gps_position.Latitude,GPS_FORMAT_DECIMAL)) ,default_zoom);
}
catch(Exception e) {}
 
 
//#if location=="on"
//#if cldc11=="on"
if (!((phone_lat==0.0)&&(phone_long==0.0)))try {
 
home_marker=new Marker(UtilMidp.parseFloat(""+phone_long),UtilMidp.parseFloat(""+phone_lat));
home_marker.name="HomePos";
home_marker.description="This is home!";
root.m_map.m_listMyPlaces.addElement(home_marker);
 
 
root.m_map.gotoLonLat(UtilMidp.parseFloat(""+phone_long) ,UtilMidp.parseFloat(""+phone_lat),default_zoom);
 
}
catch(Exception e) {}
//#endif
//#endif
 
chg_state(STATEID_MAP);
break;
//#endif
case ACTIONID_SETTING_LOADFANCY:
settings.load_fancy_defaults();
break;
2421,7 → 2908,7
// params_version
if ( mk.params.params_version!=din.readInt())
{
mk.error_str=l(STRINGID_PARAMSINCOMPATIBLE);
act_msg=l(STRINGID_PARAMSINCOMPATIBLE);
chg_state(STATEID_ERROR_MSG);
break;
}
2441,7 → 2928,7
}
catch (Exception e)
{
mk.error_str=l(STRINGID_NOPARAMSONMOBILE);
act_msg=l(STRINGID_NOPARAMSONMOBILE);
chg_state(STATEID_ERROR_MSG);
}
 
2449,6 → 2936,7
break;
case ACTIONID_SELECT_FIRMWARE:
fw_loader=new FirmwareLoader(116,this);
chg_state(STATEID_SELECT_FIRMWARE);
break;
case ACTIONID_PARAM_COPY_MOBILE:
2461,7 → 2949,7
break;
case ACTIONID_PARAM_WRITE_OK:
success_msg=l(STRINGID_PARAMWRITEOK);
act_msg=l(STRINGID_PARAMWRITEOK);
chg_state(STATEID_SUCCESS_MSG);
break;
case ACTIONID_HORIZON:
2481,12 → 2969,10
 
case ACTIONID_RESET_PARAMS:
chg_state(STATEID_RESET_PARAMS);
// state=STATEID_FLASHING;
 
break;
 
case ACTIONID_FLASH:
chg_state(STATEID_FLASHING);
chg_state(STATEID_GET_AVRSIG);
break;
case ACTIONID_DATABUFF:
2494,7 → 2980,7
break;
case ACTIONID_NC_ERRORS:
mk.error_str=null;
act_msg=null;
chg_state(STATEID_ERROR_MSG);
break;
 
2605,7 → 3091,7
 
case ACTIONID_WRITE_PARAMS:
mk.write_params(mk.params.act_paramset);
success_msg=l(STRINGID_SAVEDSETTINGS); // too optimistic
act_msg=l(STRINGID_SAVEDSETTINGS); // too optimistic
nextstate=STATEID_HANDLE_PARAMS;
chg_state(STATEID_SUCCESS_MSG);
break;
2612,7 → 3098,7
 
case ACTIONID_UNDO_PARAMS:
mk.params.use_backup();
success_msg=l(STRINGID_SETTINGSUNDOOK); // too optimistic
act_msg=l(STRINGID_SETTINGSUNDOOK); // too optimistic
nextstate=STATEID_HANDLE_PARAMS;
chg_state(STATEID_SUCCESS_MSG);
 
2623,7 → 3109,8
break;
 
case ACTIONID_DEBUG:
debug.showing=true;
chg_state(STATEID_DUBWISE_VALUES);
// debug.showing=true;
break;
 
case ACTIONID_TRAFFIC:
2653,25 → 3140,86
}
 
 
 
 
 
public void pointerDragged (int pointer_x, int pointer_y)
{
if ((pointer_x>canvas_width) || (pointer_y>canvas_height)) return; // bugfix/workaround - pointer in offscreen - e.g. wtk when not in fullscreen
 
System.out.println("p_y: " + pointer_y + "ch:" + canvas_height);
byte act_pointer_row;
if (lcd_lines.length>max_lines)
act_pointer_row=(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*max_lines))/lcd_img.getHeight() +lcd_off );
else
act_pointer_row=(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight() );
 
if ((act_pointer_row>=lcd_lines.length)||(act_pointer_row<0)) return;
 
switch(state)
{
case STATEID_PARAM_MENU:
case STATEID_CONN_DETAILS:
case STATEID_HANDLE_PARAMS:
case STATEID_FILEOPEN:
case STATEID_TRAFFIC:
case STATEID_SELECT_COMPORT:
case STATEID_MAINMENU:
case STATEID_SETTING_OPTIONS:
case STATEID_SELECT_PARAMSET:
case STATEID_DEVICESELECT:
case STATEID_SELECT_MIXER:
 
act_menu_select=act_pointer_row;
}
}
 
public void pointerPressed (int pointer_x, int pointer_y)
{
 
if ((pointer_x>canvas_width) || (pointer_y>canvas_height)) return; // bugfix - pointer in offscreen - e.g. wtk when not in fullscreen
 
byte act_pointer_row;
 
if (lcd_lines.length>max_lines)
act_pointer_row=(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*max_lines))/lcd_img.getHeight() +lcd_off );
else
act_pointer_row=(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight() );
 
 
if (pointer_y<lcd_img.getHeight())
keyPressed(KEY_STAR);
else
{ if (act_pointer_row<0) return;
 
if (pointer_y>canvas_height-lcd_img.getHeight()*lcd_lines.length)
switch(state)
{
case STATEID_SETTINGSMENU:
case STATEID_EDIT_PARAMS:
case STATEID_MOTORTEST:
act_editor.pointer_press(pointer_x,act_pointer_row );
break;
/*
 
settings_editor.pointer_press(pointer_x,(pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight()) ;
// settings_editor.pointer_press(pointer_x,(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight())) ;
settings_editor.pointer_press(pointer_x,act_pointer_row );
break;
 
case STATEID_EDIT_PARAMS:
params_editor.pointer_press(pointer_x,(pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight()) ;
 
// params_editor.pointer_press(pointer_x,(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight()) );
 
params_editor.pointer_press(pointer_x,act_pointer_row );
break;
 
 
 
motor_tester.pointer_press(pointer_x,act_pointer_row );
 
break;
*/
case STATEID_LCD:
if (pointer_x<(canvas_width/2))
keyPressed(getKeyCode(LEFT));
2678,6 → 3226,8
else
keyPressed(getKeyCode(RIGHT));
break;
 
case STATEID_SELECT_MIXER:
case STATEID_PARAM_MENU:
case STATEID_CONN_DETAILS:
case STATEID_HANDLE_PARAMS:
2688,19 → 3238,27
case STATEID_SETTING_OPTIONS:
case STATEID_SELECT_PARAMSET:
case STATEID_DEVICESELECT:
 
// if (pointer_y>canvas_height-lcd_img.getHeight()*menu_items.length)
// {
if (lcd_lines.length>max_lines)
act_menu_select=(pointer_y-(canvas_height-lcd_img.getHeight()*max_lines))/lcd_img.getHeight() +lcd_off ;
/*
if (lcd_lines.length>max_lines)
act_menu_select=(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*max_lines))/lcd_img.getHeight() +lcd_off );
else
act_menu_select=(pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight() ;
keyPressed(getKeyCode(FIRE));
act_menu_select=(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight() );
*/
 
if (act_menu_select!=act_pointer_row)
act_menu_select=act_pointer_row;
else
keyPressed(getKeyCode(FIRE));
//}
break;
}
}
}
 
 
2709,8 → 3267,28
public void keyPressed(int keyCode)
{
if (keyCode==this.KEY_NUM9)
mk.set_debug_interval(1);
 
 
key_bitfield|=keyCode2mask(keyCode);
 
if ((state==STATEID_MAINMENU)&&(keyCode==beta_unlock_code[beta_unlock_pos++]))
{
if (beta_unlock_pos==beta_unlock_code.length)
{
beta_unlock_pos=0;
nextstate=state;
act_msg="Hi Betatester" ;
chg_state(STATEID_SUCCESS_MSG);
settings.set_betatester();
return;
}
 
}
else
beta_unlock_pos=0;
 
 
 
if (last_keycode==keyCode)
repeat_keycode++;
else
2723,14 → 3301,22
// key-actions common in all states
debug.process_key(keyCode);
 
if ( key_bitfield==(keyCode2mask(KEY_NUM0)|keyCode2mask(KEY_STAR)))
{
chg_state(STATEID_MAINMENU);
return;
}
 
if (state!=STATEID_MAP)
{
if (((keyCode==KEY_STAR) || (keyCode==settings.key_back) )&&(state!=STATEID_KEYCONTROL))//&&(state!= STATEID_STRINGINPUT))
{
chg_state(STATEID_MAINMENU);
return;
}
}
 
 
if (((keyCode==KEY_POUND)||(keyCode==settings.key_fullscreen))&&(state!=STATEID_KEYCONTROL))
{
settings.toggle_fullscreen();
2741,7 → 3327,11
// key actions per state
switch(state)
{
 
//#if j2memap=="on"
case STATEID_MAP:
root.m_map.keyPressed(keyCode);
break;
//#endif
case STATEID_SUCCESS_MSG:
chg_state(nextstate);
break;
2972,7 → 3562,10
break;
 
 
/*
case STATEID_MOTORTEST:
motor_tester.keypress(keyCode,getGameAction (keyCode));
 
switch (getGameAction (keyCode))
{
case UP:
2998,10 → 3591,11
break;
}
 
 
break;
*/
 
 
 
/*
case STATEID_HANDLsE_PARAMS:
3017,6 → 3611,9
break;
*/
 
case STATEID_SELECT_MIXER:
 
case STATEID_SELECT_FIRMWARE:
case STATEID_SETTING_OPTIONS:
case STATEID_MAINMENU:
case STATEID_SELECT_PARAMSET:
3038,10 → 3635,10
menu_keypress(keyCode);
break;
 
 
 
case STATEID_MOTORTEST:
case STATEID_EDIT_PARAMS:
case STATEID_SETTINGSMENU:
settings_editor.keypress(keyCode,getGameAction (keyCode)) ;
act_editor.keypress(keyCode,getGameAction (keyCode)) ;
break;
 
// handle menue
3048,11 → 3645,11
// case STATEID_SELECT_SPEED_FORMAT:
// case STATEID_SELECT_GPS_FORMAT:
 
 
/*
case STATEID_EDIT_PARAMS:
params_editor.keypress(keyCode,getGameAction (keyCode)) ;
break;
 
*/
case STATEID_LCD:
 
if ((keyCode >= this.KEY_NUM0) && (keyCode <= this.KEY_NUM9))
/DUBwise/trunk/j2me/src/DUBwiseFileAccess.java
25,6 → 25,8
String[] act_path_arr;
 
 
public boolean dirty=true;
 
public String act_path()
{
String res="";
32,6 → 34,12
res+=act_path_arr[i];
return res;
}
public void refresh_if_dirty()
{
if (dirty) trigger();
dirty=false;
}
 
String[] file_list;
int file_list_length=0;
65,7 → 73,7
}
canvas.act_menu_select=0;
//chg_state(STATEID_FILEOPEN);
trigger();
dirty=true;
}
 
 
100,12 → 108,14
{
 
try {
FileConnection fc = (FileConnection) Connector.open("file:///"+act_path());
Enumeration filelist = fc.list("*", true);
FileConnection fc = (FileConnection) Connector.open("file:///"+act_path()+"DUBwise");
// Enumeration filelist = fc.list("*", true);
fc.mkdir();
Enumeration filelist = fc.list();//"*", true);
int tmp_i=0;
while(filelist.hasMoreElements()) {
file_list[tmp_i] = (String) filelist.nextElement();
tmp_i++;
while(filelist.hasMoreElements()) {
file_list[tmp_i] = (String) filelist.nextElement();
tmp_i++;
/* fc = (FileConnection)
Connector.open("file:///CFCard/" + fileName);
if(fc.isDirectory()) {
/DUBwise/trunk/j2me/src/DUBwiseHelper.java
19,6 → 19,17
{ return "" + digit/100 + "" + (digit/10)%10 + "" + (digit)%10; }
 
 
public final static String[] combine_str_arr(String[] arr1 , String[] arr2)
{
String[] res=new String[arr1.length+arr2.length];
for (int pos=0;pos<res.length;pos++)
if (pos<arr1.length)
res[pos]=arr1[pos];
else
res[pos]=arr2[pos-arr1.length];
return res;
}
 
public final static String pound_progress(int val,int max)
{
String res="" + (val+1) + "/" + max + " |";
/DUBwise/trunk/j2me/src/DUBwiseSettings.java
17,10 → 17,9
implements org.ligi.ufo.DUBwiseDefinitions,DUBwiseUIDefinitions,org.ligi.ufo.DUBwiseLangDefs
{
// name/handle for the recordStore to memorize some stuff
private final static String RECORD_STORE_NAME="DUBSETT_V4";
private final static String RECORD_STORE_NAME="DUBSETT_V5";
 
/* all settings hold here */
//holds id of actual skin
public byte act_skin=SKINID_DARK;
 
public int key_back;
29,42 → 28,40
 
public int voice_delay;
public int voice_volume;
 
 
public byte graph_interval=1;
 
 
public byte graph_interval;
public int remote_cam_stick;
 
public String connection_name="";
public String connection_url="";
 
public boolean do_vibra=true;
public boolean do_sound=true;
public boolean do_volts_sound=true;
public boolean do_altimeter_sound=true;
public boolean do_vibra;
public boolean do_sound;
public boolean do_volts_sound;
public boolean do_altimeter_sound;
 
public boolean big_fonts;
 
public byte altsteps;
 
public boolean horizon_invert_nick=true;
public boolean horizon_invert_roll=true;
public boolean horizon_display_altitude=true;
public boolean horizon_display_flytime=true;
public boolean horizon_invert_nick;
public boolean horizon_invert_roll;
public boolean horizon_display_altitude;
public boolean horizon_display_flytime;
 
public boolean fullscreen=false;
public boolean do_scrollbg=false;
public boolean expert_mode=false;
public boolean dev_mode=false;
public boolean fullscreen;
public boolean do_scrollbg;
public boolean expert_mode;
public boolean dev_mode;
public boolean betatester_mode;
 
public boolean reload_settings;
public boolean instant_error_show;
 
 
public boolean reload_settings=false;
public boolean instant_error_show=false;
 
public boolean graph_legend;
public boolean graph_scale;
 
 
 
 
//#if devicecontrol=="on"
public boolean keep_lighton=false;
//#endif
73,26 → 70,9
int[] act_conn_ip=default_ip; // { ip , ip , ip , ip , port }
 
 
// public byte gps_format=GPS_FORMAT_DECIMAL;
// public byte speed_format=SPEED_FORMAT_KMH;
/* end of all settings hold here */
 
 
int[] settings_field;
 
public int get_field_from_act(int pos) { return settings_field[pos];}
public void set_field_from_act(int pos,int val){
 
settings_field[pos]=val;
field2setting(pos,val);
}
 
public void toggle_fullscreen()
{
// fullscreen=!fullscreen;
set_field_from_act(1,settings_field[1]^1);
// if (fullscreen)canvas.setFullScreenMode(true);
}
 
public final static int SETTINGS_POS_SKIN =0;
public final static int SETTINGS_POS_BITFIELD1 =1;
public final static int SETTINGS_POS_GPS_FORMAT =2;
112,9 → 92,42
public final static int SETTINGS_POS_GRAPHINTERVAL =16;
public final static int SETTINGS_POS_BITFIELD3 =17;
public final static int SETTINGS_POS_ALTSTEPS =18;
public final static int SETTINGS_POS_CAMSTICK =19;
 
public final static int SETTINGS_POS_PRIMARYABO =20;
public final static int SETTINGS_POS_SECONDARYABO =21;
public final static int SETTINGS_POS_DEFAULTABO =22;
public final static int SETTINGS_FIELD_LENGTH =23;
 
 
 
int[] settings_field;
 
public int get_field_from_act(int pos) { return settings_field[pos];}
public void set_field_from_act(int pos,int val){
 
settings_field[pos]=val;
field2setting(pos,val);
}
 
public void toggle_fullscreen()
{
// fullscreen=!fullscreen;
set_field_from_act(1,settings_field[1]^1);
// if (fullscreen)canvas.setFullScreenMode(true);
}
 
public void set_betatester()
{
settings_field[SETTINGS_POS_BITFIELD3]|=2;
}
 
public void field2setting(int pos,int val)
{
try {
boolean new_fullscreen=fullscreen;
boolean new_do_scrollbg=do_scrollbg;
 
switch (pos)
{
case SETTINGS_POS_ALTSTEPS:
127,148 → 140,133
graph_interval=(byte)val;
break;
 
}
 
if (pos==SETTINGS_POS_LANG)
{
canvas.act_lang=(byte)val;
canvas.load_strings();
}
case SETTINGS_POS_BITFIELD1:
new_fullscreen=((val&1)!=0);
new_do_scrollbg=((val&2)!=0);
 
do_sound=((val&4)!=0);
do_vibra=((val&8)!=0);
expert_mode=((val&16)!=0);
//#if devicecontrol=="on"
keep_lighton=((val&32)!=0);
//#endif
graph_legend=((val&64)!=0);
graph_scale=((val&128)!=0);
 
if (pos==SETTINGS_POS_SKIN)
{
act_skin=(byte)val;
canvas.load_skin_images();
}
break;
 
if ((pos==SETTINGS_POS_BITFIELD1)&&((val&1)==1)&&(!fullscreen))
{
fullscreen=true;
canvas.setFullScreenMode(fullscreen);
}
case SETTINGS_POS_BITFIELD2:
do_volts_sound=((val&1)!=0);
reload_settings=((val&2)!=0);
do_altimeter_sound=((val&4)!=0);
horizon_invert_roll=((val&8)!=0);
horizon_invert_nick=((val&16)!=0);
horizon_display_flytime=((val&32)!=0);
horizon_display_altitude=((val&64)!=0);
dev_mode=((val&128)!=0);
break;
 
if ((pos==SETTINGS_POS_BITFIELD1)&&((val&1)==0)&&(fullscreen))
{
fullscreen=false;
canvas.setFullScreenMode(fullscreen);
}
case SETTINGS_POS_BITFIELD3:
instant_error_show=((val&1)!=0);
betatester_mode=((val&2)!=0);
big_fonts=((val&4)!=0);
canvas.regenerate_fonts=true;
break;
 
if ((pos==SETTINGS_POS_BITFIELD1)&&((val&2)==2)&&(!do_scrollbg))
{
do_scrollbg=true;
canvas.load_skin_images();
}
case SETTINGS_POS_GPS_FORMAT:
canvas.mk.gps_position.act_gps_format=(byte)val;
break;
case SETTINGS_POS_SPEED_FORMAT:
canvas.mk.gps_position.act_speed_format=(byte)val;
break;
case SETTINGS_POS_EXTERN_NICK:
default_extern_control[EXTERN_CONTROL_NICK]=(byte)val;
break;
case SETTINGS_POS_EXTERN_ROLL:
default_extern_control[EXTERN_CONTROL_ROLL]=(byte)val;
break;
case SETTINGS_POS_EXTERN_GIER:
default_extern_control[EXTERN_CONTROL_GIER]=(byte)val;
break;
case SETTINGS_POS_EXTERN_GAS:
default_extern_control[EXTERN_CONTROL_GAS]=(byte)val;
break;
case SETTINGS_POS_EXTERN_HIGHT:
default_extern_control[EXTERN_CONTROL_HIGHT]=(byte)val;
break;
 
if ((pos==SETTINGS_POS_BITFIELD1)&&((val&2)==0)&&(do_scrollbg))
{
do_scrollbg=false;
canvas.load_skin_images();
}
case SETTINGS_POS_KEY_BACK:
key_back=val;
break;
case SETTINGS_POS_KEY_FULL:
key_fullscreen=val;
break;
case SETTINGS_POS_KEY_CLEAR:
key_clear=val;
break;
case SETTINGS_POS_CAMSTICK:
remote_cam_stick=val;
break;
 
if (pos==SETTINGS_POS_BITFIELD1)
do_sound=((val&4)!=0);
case SETTINGS_POS_LANG:
canvas.act_lang=(byte)val;
canvas.load_strings();
break;
 
if (pos==SETTINGS_POS_BITFIELD1)
do_vibra=((val&8)!=0);
case SETTINGS_POS_SKIN:
act_skin=(byte)val;
canvas.load_skin_images();
break;
 
if (pos==SETTINGS_POS_BITFIELD1)
expert_mode=((val&16)!=0);
 
if (pos==SETTINGS_POS_BITFIELD1)
keep_lighton=((val&32)!=0);
 
if (pos==SETTINGS_POS_BITFIELD1)
graph_legend=((val&64)!=0);
 
if (pos==SETTINGS_POS_BITFIELD1)
graph_scale=((val&128)!=0);
 
 
 
if (pos==SETTINGS_POS_GPS_FORMAT)
canvas.mk.gps_position.act_gps_format=(byte)val;
 
if (pos==SETTINGS_POS_SPEED_FORMAT)
canvas.mk.gps_position.act_speed_format=(byte)val;
 
if (pos==SETTINGS_POS_EXTERN_NICK)
default_extern_control[EXTERN_CONTROL_NICK]=(byte)val;
 
if (pos==SETTINGS_POS_EXTERN_ROLL)
default_extern_control[EXTERN_CONTROL_ROLL]=(byte)val;
 
if (pos==SETTINGS_POS_EXTERN_GIER)
default_extern_control[EXTERN_CONTROL_GIER]=(byte)val;
 
if (pos==SETTINGS_POS_EXTERN_GAS)
default_extern_control[EXTERN_CONTROL_GAS]=(byte)val;
 
if (pos==SETTINGS_POS_EXTERN_HIGHT)
default_extern_control[EXTERN_CONTROL_HIGHT]=(byte)val;
 
 
if (pos==SETTINGS_POS_KEY_BACK)
key_back=val;
 
if (pos==SETTINGS_POS_KEY_FULL)
key_fullscreen=val;
 
if (pos==SETTINGS_POS_KEY_CLEAR)
key_clear=val;
 
if (pos==12)
remote_cam_stick=val;
 
 
if(pos==SETTINGS_POS_VOICEVOLUME)
{
voice_volume=val;
case SETTINGS_POS_VOICEVOLUME:
voice_volume=val;
//#if voice_mode!="no_voice"
canvas.status_voice.volume=voice_volume;
canvas.status_voice.volume=voice_volume;
//#endif
}
if(pos==SETTINGS_POS_VOICEDELAY)
{
voice_delay=val;
break;
case SETTINGS_POS_VOICEDELAY:
voice_delay=val;
//#if voice_mode!="no_voice"
canvas.status_voice.delay=voice_delay;
canvas.status_voice.delay=voice_delay;
//#endif
}
break;
 
if (pos==SETTINGS_POS_BITFIELD2)
do_volts_sound=((val&1)!=0);
 
if (pos==SETTINGS_POS_BITFIELD2)
reload_settings=((val&2)!=0);
case SETTINGS_POS_PRIMARYABO:
canvas.mk.primary_abo=val;
break;
case SETTINGS_POS_SECONDARYABO:
canvas.mk.secondary_abo=val;
break;
case SETTINGS_POS_DEFAULTABO:
canvas.mk.default_abo=val;
break;
 
if (pos==SETTINGS_POS_BITFIELD2)
do_altimeter_sound=((val&4)!=0);
}
 
if (new_fullscreen!=fullscreen)
{
fullscreen=new_fullscreen;
canvas.setFullScreenMode(fullscreen);
}
 
if (pos==SETTINGS_POS_BITFIELD2)
horizon_invert_roll=((val&8)!=0);
 
if (pos==SETTINGS_POS_BITFIELD2)
horizon_invert_nick=((val&16)!=0);
if (new_do_scrollbg!=do_scrollbg)
{
do_scrollbg=new_do_scrollbg;
canvas.load_skin_images();
}
 
if (pos==SETTINGS_POS_BITFIELD2)
horizon_display_flytime=((val&32)!=0);
 
if (pos==SETTINGS_POS_BITFIELD2)
horizon_display_altitude=((val&64)!=0);
 
if (pos==SETTINGS_POS_BITFIELD2)
dev_mode=((val&128)!=0);
 
 
if (pos==SETTINGS_POS_BITFIELD3)
instant_error_show=((val&1)!=0);
 
/*
/* snippet to extract default fields
String ts="";
for ( int i=0;i<SETTINGS_FIELD_LENGTH;i++)
ts+=","+settings_field[i];
275,15 → 273,15
 
System.out.println(ts);
*/
}
catch (Exception e) { }
 
 
}
 
public int[] plain_defaults={0,0,0,0,42,42,42,1,1,-4242,-4242,-4242,0,10,0,0,7,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
public int[] fancy_defaults={0,255,0,0,42,42,42,1,1,-4242,-4242,-4242,150,10,5,0,7,1,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
public int[] plain_defaults={0,0,0,0,42,42,42,1,1,-4242,-4242,-4242,0,10,0,0,7,0,7,0,10,30,1000};
public int[] fancy_defaults={0,255,0,0,42,42,42,1,1,-4242,-4242,-4242,150,10,5,0,7,1,10,0,1,3,100};
 
 
 
public void process_all_settings()
{
for ( int i=0;i<SETTINGS_FIELD_LENGTH;i++)
305,14 → 303,9
public byte[] default_extern_control;//=default_extern_keycontrol ;
 
 
/* end of all settings hold here */
public int[] _tab_stringids={STRINGID_USERINTERFACE,STRINGID_UNITS,STRINGID_KEYCONTROL,STRINGID_SPECIALKEYS,STRINGID_GRAPH,STRINGID_SOUND,STRINGID_COCKPIT,STRINGID_TIMING,STRINGID_OTHER};
 
// public String[] _tab_names={"User Interface","GPS","Keycontrol","Special Keys","Graph","Voice","Other" };
 
 
public int[] _tab_stringids={STRINGID_USERINTERFACE,STRINGID_UNITS,STRINGID_KEYCONTROL,STRINGID_SPECIALKEYS,STRINGID_GRAPH,STRINGID_SOUND,STRINGID_COCKPIT,STRINGID_OTHER};
 
 
public int[][] _field_stringids ={
{
STRINGID_LANGUAGE,
319,9 → 312,10
STRINGID_SKIN,
STRINGID_FULLSCREEN,
STRINGID_SCROLLBG
//#if devicecontrol=="on"
//#if devicecontrol=="on"
,STRINGID_PERMALIGHT
//#endif
//#endif
,STRINGID_BIGFONTS
},
{STRINGID_SPEEDFORMAT,STRINGID_GPSFORMAT},
{STRINGID_NICK ,STRINGID_ROLL,STRINGID_GIER,STRINGID_GASINCREASE,STRINGID_HEIGHTINCREASE },
329,12 → 323,13
{STRINGID_LEGEND,STRINGID_SCALEGRID,STRINGID_GRAPHINTERVAL},
{STRINGID_SOUND,STRINGID_VOLTS,STRINGID_DELAYINS,STRINGID_ALTIMETER,STRINGID_ALTSTEPS,STRINGID_VOLUME},
{STRINGID_SHOWALTITUDE,STRINGID_SHOWFLIGHTTIME,STRINGID_INVERTROLL,STRINGID_INVERTNICK},
{STRINGID_PRIMARYABO,STRINGID_SECONDARYABO,STRINGID_DEFAULTABO}, ////
{STRINGID_INSTANTERRORSHOW,STRINGID_VIBRA,STRINGID_REMOTECAMSTICK,STRINGID_ALWAYSRELOADPARAMS,STRINGID_EXPERTMODE,STRINGID_DEVMODE}};
 
 
 
 
public int[][] _choice_stringids={ {STRINGID_LANG0,STRINGID_LANG1}, /* FIXME - make dynamic */{ STRINGID_DARK,STRINGID_LIGHT } , {STRINGID_KMH,STRINGID_MPH,STRINGID_CMS},{STRINGID_DECIMAL,STRINGID_MINSEC} } ;
public int[][] _choice_stringids={ {STRINGID_LANG0,STRINGID_LANG1,STRINGID_LANG2}, /* FIXME - make dynamic */{ STRINGID_DARK,STRINGID_LIGHT } , {STRINGID_KMH,STRINGID_MPH,STRINGID_CMS},{STRINGID_DECIMAL,STRINGID_MINSEC} } ;
 
 
 
341,28 → 336,30
public int[][] _field_positions= {
{SETTINGS_POS_LANG,SETTINGS_POS_SKIN,8,9
//#if devicecontrol=="on"
 
,13
//#endif
} , {2,3 } , {4,5,6,7,8} , {9,10,11},{SETTINGS_POS_BITFIELD1*8 +6,SETTINGS_POS_BITFIELD1*8 +7, SETTINGS_POS_GRAPHINTERVAL} ,
{10,SETTINGS_POS_BITFIELD2*8+0,SETTINGS_POS_VOICEDELAY,SETTINGS_POS_BITFIELD2*8+2,SETTINGS_POS_ALTSTEPS,SETTINGS_POS_VOICEVOLUME },
, SETTINGS_POS_BITFIELD3*8+2
} , {2,3} , {4,5,6,7,8} , {9,10,11},{SETTINGS_POS_BITFIELD1*8 +6,SETTINGS_POS_BITFIELD1*8 +7, SETTINGS_POS_GRAPHINTERVAL} ,
{SETTINGS_POS_BITFIELD1*8+2,SETTINGS_POS_BITFIELD2*8+0,SETTINGS_POS_VOICEDELAY,SETTINGS_POS_BITFIELD2*8+2,SETTINGS_POS_ALTSTEPS,SETTINGS_POS_VOICEVOLUME },
{SETTINGS_POS_BITFIELD2*8+6,SETTINGS_POS_BITFIELD2*8+5,SETTINGS_POS_BITFIELD2*8+3,SETTINGS_POS_BITFIELD2*8+4},
{SETTINGS_POS_BITFIELD3*8+0,SETTINGS_POS_BITFIELD1*8+3,12,SETTINGS_POS_BITFIELD2*8+1,SETTINGS_POS_BITFIELD1*8+4,SETTINGS_POS_BITFIELD2*8+7}
 
{SETTINGS_POS_PRIMARYABO,SETTINGS_POS_SECONDARYABO,SETTINGS_POS_DEFAULTABO},
{SETTINGS_POS_BITFIELD3*8+0,SETTINGS_POS_BITFIELD1*8+3,SETTINGS_POS_CAMSTICK,SETTINGS_POS_BITFIELD2*8+1,SETTINGS_POS_BITFIELD1*8+4,SETTINGS_POS_BITFIELD2*8+7}
};
public int[][] _field_types={ {PARAMTYPE_CHOICE+0,PARAMTYPE_CHOICE+1,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH
//#if devicecontrol=="on"
,PARAMTYPE_BITSWITCH
//#endif
,PARAMTYPE_BITSWITCH
} , {PARAMTYPE_CHOICE+2,PARAMTYPE_CHOICE+3} , {PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE}, {PARAMTYPE_KEY,PARAMTYPE_KEY,PARAMTYPE_KEY} , {PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BYTE},
{PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BYTE,PARAMTYPE_BITSWITCH,PARAMTYPE_BYTE,PARAMTYPE_BYTE} ,
{PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH},
{PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE},
{PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_STICK,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH}
};
DUBwiseCanvas canvas;
 
 
 
public final static int SETTINGS_FIELD_LENGTH=42;
public DUBwiseSettings(DUBwiseCanvas _canvas)
{
canvas= _canvas;
369,16 → 366,7
settings_field=new int[SETTINGS_FIELD_LENGTH];
default_extern_control=new byte[11];
// set defaults
settings_field[4]=42; // nick
settings_field[5]=42; // roll
settings_field[6]=42; // gier
settings_field[7]=1; // gas
settings_field[8]=1; // hight
 
settings_field[9]=-4242; // no key
settings_field[10]=-4242; // no key
settings_field[11]=-4242; // no key
 
settings_field=plain_defaults;
}
public void load()
385,8 → 373,6
{
tab_stringids=_tab_stringids;
 
// tab_names=_tab_names;
 
field_positions=_field_positions;
field_types=_field_types;
 
393,44 → 379,34
choice_stringids=_choice_stringids;
 
field_stringids=_field_stringids;
//choice_strings=new String[_choice_strings.length+1][];
/*
// FIXME
choice_strings[0]=new String[2];
choice_strings[0][0]="English";
choice_strings[0][1]="Deutsch";
for ( int i=1; i<_choice_strings.length+1;i++)
{
choice_strings[i]=new String[_choice_strings[i-1].length+1];
for ( int ii=0; ii<_choice_strings[i-1].length;ii++)
choice_strings[i][ii]=canvas.l(_choice_strings[i-1][ii]);
}
*/
// choice_strings=_choice_strings;
try
{
RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME , true );
RecordStore recStore= RecordStore.openRecordStore(RECORD_STORE_NAME, false);
 
if (recStore.getNumRecords()==1)
{
ByteArrayInputStream bin = new ByteArrayInputStream(recStore.getRecord(1));
DataInputStream din = new DataInputStream( bin );
 
DataInputStream din = new DataInputStream( new ByteArrayInputStream(recStore.getRecord(1)) );
 
connection_url=din.readUTF();
connection_name=din.readUTF();
// reserve utf's
din.readUTF();
din.readUTF();
din.readUTF();
byte str_count=din.readByte();
for (int str_i=0;str_i<str_count;str_i++)
switch(str_i)
{
case 0:
connection_url=din.readUTF();
break;
case 1:
connection_name=din.readUTF();
break;
}
 
byte field_count=din.readByte();
for (int field_i=0;field_i<field_count;field_i++)
settings_field[field_i]=din.readInt();
 
 
for ( int i=0;i<SETTINGS_FIELD_LENGTH;i++)
settings_field[i]=din.readInt();
 
for ( int i=0;i<5;i++)
 
{
act_proxy_ip[i]=din.readInt();
act_conn_ip[i]=din.readInt();
464,16 → 440,14
ByteArrayOutputStream bout = new ByteArrayOutputStream();
DataOutputStream dout = new DataOutputStream( bout );
 
dout.writeByte(2);
dout.writeUTF(connection_url);
dout.writeUTF(connection_name);
 
dout.writeUTF("");
dout.writeUTF("");
dout.writeUTF("");
 
 
dout.writeByte(SETTINGS_FIELD_LENGTH);
for ( int i=0;i<SETTINGS_FIELD_LENGTH;i++)
dout.writeInt(settings_field[i]);
 
for ( int i=0;i<5;i++)
{
dout.writeInt(act_proxy_ip[i]);
/DUBwise/trunk/j2me/src/DUBwiseUIDefinitions.java
49,10 → 49,16
public final static byte STATEID_SELECT_FIRMWARE =34;
public final static byte STATEID_SHOWPHONEGPS =35;
public final static byte STATEID_SETTING_OPTIONS =36;
public final static byte STATEID_COUNT =37;
public final static byte STATEID_MAP =37;
public final static byte STATEID_GET_AVRSIG =38;
public final static byte STATEID_SELECT_MIXER =39;
public final static byte STATEID_DUBWISE_VALUES =40;
 
 
public final static byte STATEID_COUNT =41;
 
 
 
public final static byte ACTIONID_SETTINGS = 0;
public final static byte ACTIONID_DEVICESELECT = 1;
public final static byte ACTIONID_DEBUG = 2;
99,6 → 105,9
public final static byte ACTIONID_SETTING_OPTIONS = 43;
public final static byte ACTIONID_SETTING_LOADPLAIN = 44;
public final static byte ACTIONID_SETTING_LOADFANCY = 45;
public final static byte ACTIONID_MAP = 46;
public final static byte ACTIONID_SELECT_DUBWISEDIR = 47;
public final static byte ACTIONID_SELECT_MIXER = 48;
 
public final static byte ACTIONID_QUIT = 100;
 
125,17 → 134,19
final static byte SKINID_LIGHT = 1;
 
 
 
final static byte CREDITS_VERSION=7;
final static String[] credits= {
//#expand "About DUBwise v%VERSION%",
"##### DUBwise ######",
"",
"",
"Digital UFO",
"Broadcasting With ",
"Byteelligent Service",
"Intelligent Service",
"Equipment",
"",
"2007-2008 by ",
"",
"",
"",
"(cc) 2007-2009 by ",
"Marcus LiGi B"+(char)(252)+"schleb",
"mailto:ligi"+"@"+"ligi.de",
"",
145,18 → 156,33
" -Noncommercial",
" -Share Alike",
" -No Violence",
" ",
"",
"Links:",
" www.ligi.de",
" www.mikrokopter.com",
"",
"Credits: ",
" -HolgerB&IngoB",
" (MikroKopter)",
" -CaScAdE",
" (Graphics/Testing)",
" -Orion8",
" (Inspiration)",
" -Joko",
" (Testing)",
" -Speedy",
" (Graphics/Sounds)",
" -Jamiro",
"",
"More Infos:",
" www.ligi.de",
" www.mikrokopter.com"};
" (Icon)",
" -SelectaT",
" (Sounds)",
" -JiPsi",
" (french translat.)",
" -kmpec",
" (Test-Device)",
"####################"
 
};
 
public final static char[] idle_seq={'.','_','-','='};
/DUBwise/trunk/j2me/src/FirmwareLoader.java
10,9 → 10,13
 
**************************************/
 
import java.util.Vector;
import java.io.*;
public class FirmwareLoader
implements Runnable
implements Runnable // for http download task
,org.ligi.ufo.DUBwiseLangDefs
, DUBwiseUIDefinitions
{
 
public final static String base_url= "http://mikrocontroller.cco-ev.de/mikrosvn/Projects/DUBwise/trunk/misc/firmwares/";
22,11 → 26,76
String[] names;
String[] filenames;
public FirmwareLoader()
DUBwiseCanvas canvas;
 
 
int selected=0;
public void menu_fire(byte pos)
{
new Thread( this ).start(); // fire up main Thread
 
if ( pos<(names.length-1))
{
selected=pos;
canvas.chg_state(STATEID_FLASHING);
}
else
canvas.chg_state(STATEID_MAINMENU);
}
 
 
public InputStream get_input_str()
{
if ( selected<fws_in_jar)
return this.getClass().getResourceAsStream("/fw_"+avrsig+"_"+selected+".bin");
 
return null;
}
 
 
int fws_in_jar=0;
int avrsig;
 
public FirmwareLoader(int _avrsig,DUBwiseCanvas _canvas)
{
avrsig=_avrsig;
canvas=_canvas;
 
// firmware files in jar
Vector jar_names_vector = new Vector();
 
String tmp_str="";
try {
InputStream in=this.getClass().getResourceAsStream("/fw_"+avrsig+".lst");
char ch=0;
while (in.available()>0)
{
if ( (ch=(char)in.read())!='\n')
tmp_str+=ch;
else
{
jar_names_vector.addElement( tmp_str );
tmp_str="";
}
 
}
}
catch (Exception e) {}
fws_in_jar= jar_names_vector.size();
 
names=new String[ fws_in_jar+2];
 
if ( jar_names_vector.size()>0)
for(int loop=0; loop<fws_in_jar; loop++)
names[loop] = (String)jar_names_vector.elementAt(loop);
names[jar_names_vector.size()]="Download";
names[jar_names_vector.size()+1]=canvas.l(STRINGID_BACK);
 
// new Thread( this ).start(); // fire up main Thread
}
 
public void run()
{
if (!got_list)
/DUBwise/trunk/j2me/src/MKParamsEditor.java
26,7 → 26,10
 
org.ligi.ufo.ParamsClass edit_source;
 
boolean select_mode;
 
 
 
public MKParamsEditor(DUBwiseCanvas _canvas,org.ligi.ufo.ParamsClass _edit_source,byte _nextstate)
{
nextstate=_nextstate;
34,13 → 37,15
 
canvas=_canvas;
lcd_lines=new String[40];
 
 
System.out.println("initing params_editor");
select_mode=(edit_source.tab_stringids!=null);
// refresh_lcd();
}
 
 
boolean select_mode=true;
 
 
public void paint ( Graphics g)
{
if (select_mode)
70,7 → 75,7
{
 
try {
act_lcd_lines=edit_source.field_stringids[act_tab].length*2+2;
act_lcd_lines=edit_source.field_types[act_tab].length*2+2;
for ( int i=0;i<act_lcd_lines;i++)
lcd_lines[i]="";
79,10 → 84,12
// lcd_lines[0]=(act_tab==0?" ":"< ") + edit_source.tab_stringids[act_tab] + (act_tab==(edit_source.tab_stringids.length-1)?" ":" >");
for (int i=0;i<edit_source.field_stringids[act_tab].length;i++)
for (int i=0;i<edit_source.field_types[act_tab].length;i++)
{
lcd_lines[2*i]=canvas.l(edit_source.field_stringids[act_tab][i]);
if (edit_source.field_stringids!=null)
lcd_lines[2*i]=canvas.l(edit_source.field_stringids[act_tab][i]);
else
lcd_lines[2*i]=edit_source.field_strings[act_tab][i];
switch(edit_source.field_types[act_tab][i])
{
case PARAMTYPE_BITSWITCH:
164,12 → 171,18
public boolean editing_number=false;
 
public void pointer_press(int x,int row)
public void pointer_press(int x,byte row)
{
 
System.out.println("pointer row " + row + " lcd_off" + canvas.lcd_off);
if (select_mode)
{
canvas.act_menu_select=row;
keypress (-4242,Canvas.FIRE);
if (canvas.act_menu_select!=row)
canvas.act_menu_select=row;
else
keypress (-4242,Canvas.FIRE);
 
}
else
180,6 → 193,7
{
act_y=row;
 
System.out.println("y:" + act_y);
if (act_y==(canvas.lcd_lines.length-1))
keypress (-4242,Canvas.FIRE);
else
196,7 → 210,6
 
public void keypress (int keyCode,int action)
{
 
if (select_mode)
{
if (action== Canvas.FIRE)
327,8 → 340,11
act_y=1;
// canvas.act_menu_select=0;
canvas.menu_items[0]="";
select_mode=true;
 
if (edit_source.tab_stringids==null)
canvas.chg_state(nextstate);
else
select_mode=true;
}
}
/DUBwise/trunk/j2me/src/MKStatusVoice.java
6,6 → 6,8
*
*******************************************/
 
//public class MKStatusVoice {}
 
import javax.microedition.media.*;
import javax.microedition.media.control.*;
import java.util.*;
16,9 → 18,11
implements Runnable,PlayerListener
{
 
org.ligi.ufo.MKCommunicator mk=null;
DUBwiseCanvas canvas=null;
Player player;
 
Player up_player;
Player down_player;
public final int PLAYERSTATE_IDLE=0;
public final int PLAYERSTATE_PLAYING=1;
31,10 → 35,10
int act_player_state=PLAYERSTATE_IDLE;
VolumeControl vc;
 
public MKStatusVoice(org.ligi.ufo.MKCommunicator _mk,DUBwiseCanvas _canvas)
public MKStatusVoice(DUBwiseCanvas _canvas)
{
canvas=_canvas;
mk=_mk;
 
new Thread( this ).start(); // fire up main Thread
}
 
67,33 → 71,79
}
 
 
public void start_playing(String name)
public Player init_player(String name)
{
Player _player=null;
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");
_player = Manager.createPlayer(getClass().getResourceAsStream(name+".wav"), "audio/x-wav");
}
player.addPlayerListener(this);
player.realize();
act_player_state=PLAYERSTATE_PLAYING;
_player.addPlayerListener(this);
_player.realize();
 
vc = (VolumeControl) player.getControl("VolumeControl");
if(vc != null) {
vc.setLevel(volume);
}
 
player.prefetch();
player.setLoopCount(1);
player.start();
vc = (VolumeControl) _player.getControl("VolumeControl");
if(vc != null) {
vc.setLevel(volume);
}
_player.prefetch();
_player.setLoopCount(1);
_player.start();
}
catch (Exception e) {
}
return _player;
 
}
 
public void play_up()
{
 
try {
act_player_state=PLAYERSTATE_PLAYING;
if (up_player==null)
up_player=init_player("up");
 
 
up_player.start();
}
catch (Exception e) {
}
}
 
 
public void play_down()
{
 
try {
act_player_state=PLAYERSTATE_PLAYING;
if (down_player==null)
down_player=init_player("down");
down_player.start();
}
catch (Exception e) {
}
}
public void start_playing(String name)
{
 
try {
act_player_state=PLAYERSTATE_PLAYING;
player=init_player(name);
player.start();
}
catch (Exception e) {
}
}
public void wait_for_end()
{
109,23 → 159,33
int info_from_debug_set=-1;
int volt_timeout=0;
 
public int BASE_SLEEP=10;
 
public int last_alt=-1;
 
 
public int loop_cnt;
public int volts_play_cnt;
 
public void run()
{
while(true)
{
if (mk.connected&&(canvas.settings.do_sound)&&(mk.UBatt()!=-1)&&(!mk.force_disconnect))
loop_cnt++;
if ((canvas.mk!=null)&&(canvas.mk.connected)&&(canvas.settings.do_sound)&&(canvas.mk.UBatt()!=-1)&&(!canvas.mk.force_disconnect))
{
volt_timeout--;
if (info_from_debug_set!=mk.stats.debug_data_count)
if (info_from_debug_set!=canvas.mk.stats.debug_data_count)
{ // only when newdata
if (canvas.settings.do_volts_sound&&(volt_timeout--<0))
if (canvas.settings.do_volts_sound&&(volt_timeout<0))
{
volt_timeout=delay*10;
int ubatt=mk.UBatt();
info_from_debug_set=mk.stats.debug_data_count;
volts_play_cnt++;
 
volt_timeout=(delay*1000)/BASE_SLEEP;
int ubatt=canvas.mk.UBatt();
info_from_debug_set=canvas.mk.stats.debug_data_count;
start_playing(""+(ubatt/10));
wait_for_end();
144,19 → 204,21
 
if (canvas.settings.do_altimeter_sound)
{
if (last_alt==-1) last_alt=mk.Alt();
if (last_alt==-1) last_alt=canvas.mk.Alt();
 
if (last_alt>mk.Alt()+canvas.settings.altsteps)
if (last_alt>canvas.mk.Alt()+canvas.settings.altsteps)
{
start_playing("down");
// start_playing("down");
play_down();
wait_for_end();
last_alt-=canvas.settings.altsteps;
}
if (last_alt<mk.Alt()-canvas.settings.altsteps)
if (last_alt<canvas.mk.Alt()-canvas.settings.altsteps)
{
start_playing("up");
//start_playing("up");
play_up();
wait_for_end();
last_alt+=canvas.settings.altsteps;
}
168,13 → 230,13
}
 
try {
Thread.sleep(100);
/*
if (delay<1)
Thread.sleep(1000);
else
Thread.sleep(delay*1000);
*/
Thread.sleep(BASE_SLEEP);
//if (delay<1)
// Thread.sleep(1000);
//else
// Thread.sleep(delay*1000);
}
catch (Exception e) { }
184,3 → 246,4
 
}
 
/DUBwise/trunk/j2me/src/MixerManager.java
0,0 → 1,29
public class MixerManager
{
 
String[] names={"Hexa","Hexa2","Octo","Octo-U","Octo2","Octo3","Quadro","Quadro-X"};
int[][] arrays={{64,64,0,64,64,64,-64,-64,64,-64,-64,64,64,-64,0,-64,64,-64,64,64,64,64,64,-64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{64,64,0,64,64,64,-64,-64,64,-64,-64,64,64,-64,0,-64,64,-64,64,64,64,64,64,-64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{64,64,64,64,64,64,-64,-64,64,64,-64,64,64,-64,-64,-64,64,-64,-64,64,64,-64,64,-64,64,-64,64,64,64,64,64,-64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{64,64,0,64,64,64,-64,-64,64,0,-64,64,64,-64,-64,-64,64,-64,0,64,64,-64,64,-64,64,0,64,64,64,64,64,-64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{64,64,0,64,64,64,-64,-64,64,0,-64,64,64,-64,-64,-64,64,-64,0,64,64,-64,64,-64,64,0,64,64,64,64,64,-64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{64,64,0,64,64,64,0,-64,64,0,-64,64,64,0,-64,-64,64,-64,0,64,64,-64,0,-64,64,0,64,64,64,0,64,-64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{64,64,0,64,64,-64,0,64,64,0,-64,-64,64,0,64,-64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{64,64,64,64,64,-64,-64,64,64,64,-64,-64,64,-64,64,-64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
 
 
public int[] bytes(byte id)
{
int[] res= new int[1+12+12*4];
 
res[0]=1;
for ( int i=1;i<13;i++)
try
{
res[i]=(byte)names[id].charAt(i-1);
}
catch (Exception e)
{
res[i] =0;
}
 
for ( int i=0;i<12*4;i++)
res[1+12+i]=arrays[id][i];
return res;
}
}
/DUBwise/trunk/j2me/src/MotorTester.java
0,0 → 1,36
public class MotorTester
extends org.ligi.ufo.ParamsClass
{
public final static int MAX_ENGINES=12;
 
int[] engine_field;
 
public void set_field_from_act(int pos,int val)
{
engine_field[pos]=val;
}
 
public int get_field_from_act(int pos)
{
return engine_field[pos];
}
 
public MotorTester()
{
 
engine_field=new int[MAX_ENGINES];
tab_stringids=null; // no tabs
 
field_strings=new String[1][MAX_ENGINES];
field_positions=new int[1][MAX_ENGINES];
field_types=new int[1][MAX_ENGINES];
 
for (int i=0;i<MAX_ENGINES;i++)
{
field_strings[0][i]="Engine " + (i+1);
field_positions[0][i]=i;
field_types[0][i]=PARAMTYPE_BYTE;
}
 
}
}