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)) |