Rev 242 | Rev 255 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
206 | ligi | 1 | /*************************************************************** |
2 | * |
||
3 | * User Interface ( Canvas ) of DUBwise |
||
4 | * |
||
5 | * Author: Marcus -LiGi- Bueschleb |
||
6 | * Mailto: LiGi @at@ LiGi DOTT de |
||
7 | * |
||
8 | ***************************************************************/ |
||
9 | |||
10 | import javax.microedition.lcdui.*; |
||
11 | |||
12 | import javax.microedition.media.*; |
||
13 | import javax.microedition.media.control.*; |
||
14 | |||
15 | |||
242 | ligi | 16 | import javax.microedition.rms.*; |
17 | import java.io.*; |
||
206 | ligi | 18 | |
19 | public class DUBwiseCanvas |
||
20 | extends Canvas |
||
211 | ligi | 21 | implements Runnable,org.ligi.ufo.DUBwiseDefinitions , DUBwiseUIDefinitions |
206 | ligi | 22 | { |
23 | |||
24 | //#if fileapi=="on" |
||
221 | ligi | 25 | DUBwiseFileAccess file_access; |
206 | ligi | 26 | //#endif |
27 | |||
213 | ligi | 28 | String act_input_str=" "; |
223 | ligi | 29 | // for dual use of states |
30 | boolean select_paramset4edit; |
||
242 | ligi | 31 | |
32 | |||
33 | boolean read_paramset_intension_save; |
||
206 | ligi | 34 | boolean ipinput4proxy; |
223 | ligi | 35 | |
36 | |||
206 | ligi | 37 | byte ipinput_pos=0; |
38 | int[] act_edit_ip; |
||
39 | |||
40 | int canvas_width=100; |
||
41 | int canvas_height=100; |
||
42 | |||
43 | |||
44 | int heading_offset=0; |
||
45 | int act_wp; |
||
46 | |||
47 | //#if bluetooth=="on" |
||
48 | private BTSearcher bt_scanner; |
||
49 | //#endif |
||
50 | |||
51 | public org.ligi.ufo.MKCommunicator mk=null; |
||
52 | // private MKStatistics mk_stat=null; |
||
53 | private MKParamsEditor params_editor=null; |
||
220 | ligi | 54 | private MKParamsEditor settings_editor=null; |
206 | ligi | 55 | public DUBwiseDebug debug=null; |
56 | |||
57 | |||
242 | ligi | 58 | |
59 | |||
206 | ligi | 60 | //#if voice_mode!="no_voice" |
229 | ligi | 61 | public MKStatusVoice status_voice; |
206 | ligi | 62 | //#endif |
63 | |||
64 | |||
65 | private DUBwise root; |
||
66 | public DUBwiseSettings settings; |
||
67 | // public UFOProber mk.ufo_prober; |
||
68 | |||
69 | private Image bg_img; |
||
70 | private Image lcd_img; |
||
71 | private Image symbols_img; |
||
242 | ligi | 72 | |
73 | private int symbols_img_tile_height; |
||
74 | private int symbols_img_tile_width; |
||
75 | |||
76 | |||
206 | ligi | 77 | private Image err_img; |
78 | |||
79 | |||
80 | int max_lines; |
||
81 | |||
82 | |||
83 | public byte act_motor=0; |
||
84 | public byte act_motor_increase=0; |
||
85 | public boolean motor_test_sel_all=false; |
||
86 | |||
87 | |||
88 | /* Graph Vars */ |
||
89 | public final static int GRAPH_COUNT=4; |
||
90 | public final static int[] graph_colors={0x156315,0xCC1315,0xf8ef02,0x19194d}; |
||
91 | public int[] graph_sources={0,1,2,3}; |
||
92 | public String[] graph_names={"nick int","roll int","nick acc","roll acc"}; |
||
93 | public int[][] graph_data; |
||
221 | ligi | 94 | public int graph_offset=0; |
95 | |||
223 | ligi | 96 | // public int lcd_char_width=0; |
206 | ligi | 97 | public int lcd_char_height=0; |
98 | |||
99 | public int frame_pos=0; |
||
100 | |||
101 | // public byte mk.user_intent=USER_INTENT_NONE; |
||
102 | |||
103 | int line_scaler=20; |
||
104 | |||
105 | int rawdebug_cursor_y=0; |
||
106 | int rawdebug_off_y=0; |
||
107 | |||
108 | public int line_middle_y; |
||
229 | ligi | 109 | public int graph_height; |
206 | ligi | 110 | |
229 | ligi | 111 | |
206 | ligi | 112 | boolean quit=false; |
113 | |||
114 | int bg_offset=0; |
||
115 | |||
116 | // variable to hold the current state |
||
223 | ligi | 117 | public byte state=STATEID_INITIAL; |
224 | ligi | 118 | public byte nextstate=STATEID_INITIAL; |
206 | ligi | 119 | |
120 | int local_max=-1; |
||
121 | |||
122 | int y_off=0; |
||
123 | int spacer=0; |
||
124 | int spacer1=0; |
||
125 | |||
126 | int[] motor_test = {0,0,0,0}; |
||
127 | |||
128 | |||
129 | String[] menu_items; |
||
130 | byte[] menu_actions; |
||
131 | int act_menu_select=0; |
||
223 | ligi | 132 | int[] act_menu_select_bak; |
206 | ligi | 133 | String[] lcd_lines =null; |
134 | |||
135 | |||
242 | ligi | 136 | // to check if 2 keys are pressed |
137 | byte keycontrol_exit=0; |
||
214 | ligi | 138 | |
242 | ligi | 139 | |
140 | byte setup_pos; |
||
141 | byte[] tmp_actions; |
||
142 | String[] tmp_items; |
||
214 | ligi | 143 | // boolean expert_mode=false; |
144 | |||
242 | ligi | 145 | public void tmp_menu_init(int max_items) |
214 | ligi | 146 | { |
242 | ligi | 147 | setup_pos=0; |
148 | tmp_actions=new byte[max_items]; |
||
149 | tmp_items=new String[max_items]; |
||
150 | } |
||
214 | ligi | 151 | |
242 | ligi | 152 | public void tmp_menu_add(String label,byte action) |
153 | { |
||
154 | tmp_actions[setup_pos] = action; |
||
155 | tmp_items[setup_pos] = label; |
||
156 | setup_pos++; |
||
157 | } |
||
214 | ligi | 158 | |
242 | ligi | 159 | public void tmp_menu_use() |
160 | { |
||
161 | byte[] tmp_actions_fin=new byte[setup_pos]; |
||
162 | String[] tmp_items_fin=new String[setup_pos]; |
||
163 | |||
164 | if (setup_pos<act_menu_select) |
||
165 | act_menu_select=0; |
||
214 | ligi | 166 | |
242 | ligi | 167 | for ( int tmp_p=0;tmp_p<setup_pos;tmp_p++) |
214 | ligi | 168 | { |
242 | ligi | 169 | tmp_actions_fin[tmp_p]=tmp_actions[tmp_p]; |
170 | tmp_items_fin[tmp_p] =tmp_items[tmp_p]; |
||
214 | ligi | 171 | } |
172 | |||
242 | ligi | 173 | setup_menu(tmp_items_fin,tmp_actions_fin); |
174 | } |
||
175 | |||
176 | public void setup_conn_menu() |
||
177 | { |
||
178 | tmp_menu_init(7); |
||
179 | tmp_menu_add("Packet Traffic",ACTIONID_TRAFFIC); |
||
180 | tmp_menu_add("view Data",ACTIONID_DATABUFF); |
||
181 | //#if bluetooth=="on" |
||
182 | tmp_menu_add("connect via BT",ACTIONID_SCAN_BT); |
||
183 | //#endif |
||
184 | tmp_menu_add("connect via TCP/IP",ACTIONID_CONNECT_TCP); |
||
214 | ligi | 185 | |
242 | ligi | 186 | if ((System.getProperty("microedition.commports")!=null)&&(!System.getProperty("microedition.commports").equals(""))) |
187 | tmp_menu_add("connect via COM",ACTIONID_SELECT_COM); |
||
188 | tmp_menu_add("set Proxy",ACTIONID_PROXY_INPUT); |
||
189 | tmp_menu_add("back",ACTIONID_MAINMENU); |
||
190 | tmp_menu_use(); |
||
214 | ligi | 191 | |
242 | ligi | 192 | } |
214 | ligi | 193 | |
222 | ligi | 194 | |
242 | ligi | 195 | public void setup_main_menu() |
196 | { |
||
197 | tmp_menu_init(20); |
||
198 | |||
199 | tmp_menu_add("Tool Settings",ACTIONID_SETTINGS); |
||
200 | tmp_menu_add("Connection",ACTIONID_CONN_DETAILS); |
||
214 | ligi | 201 | |
242 | ligi | 202 | if (settings.expert_mode) |
203 | tmp_menu_add("Debug",ACTIONID_DEBUG); |
||
204 | |||
205 | if (mk.ufo_prober.is_mk()) |
||
214 | ligi | 206 | { |
242 | ligi | 207 | |
208 | tmp_menu_add("Motor Test",ACTIONID_MOTORTEST); |
||
209 | tmp_menu_add("Key-Control",ACTIONID_KEYCONTROL); |
||
210 | tmp_menu_add("view RC-data",ACTIONID_RCDATA); |
||
211 | tmp_menu_add("Flight Settings",ACTIONID_PARAM_MENU); |
||
212 | tmp_menu_add("Artificial Horizon",ACTIONID_HORIZON); |
||
214 | ligi | 213 | } |
214 | |||
215 | |||
216 | |||
242 | ligi | 217 | if ( mk.ufo_prober.is_navi()||mk.ufo_prober.is_mk() ) |
218 | tmp_menu_add("LCD",ACTIONID_LCD); |
||
214 | ligi | 219 | |
242 | ligi | 220 | if ( mk.ufo_prober.is_mk() ) |
221 | tmp_menu_add("Graph",ACTIONID_GRAPH); |
||
214 | ligi | 222 | |
223 | if (( mk.ufo_prober.is_navi()||mk.ufo_prober.is_mk()||mk.ufo_prober.is_mk3mag() )) |
||
242 | ligi | 224 | tmp_menu_add("Debug Values",ACTIONID_RAWDEBUG); |
214 | ligi | 225 | |
226 | |||
227 | if ( mk.ufo_prober.is_navi()) |
||
228 | { |
||
242 | ligi | 229 | tmp_menu_add("view GPS-Data",ACTIONID_GPSDATA); |
230 | tmp_menu_add("view Errors",ACTIONID_NC_ERRORS); |
||
231 | tmp_menu_add("switch to FC",ACTIONID_SWITCH_FC); |
||
232 | tmp_menu_add("switch to MK3MAG",ACTIONID_SWITCH_MK3MAG); |
||
214 | ligi | 233 | |
234 | } |
||
235 | |||
242 | ligi | 236 | if (mk.ufo_prober.is_mk()||mk.ufo_prober.is_mk3mag() ) |
237 | tmp_menu_add("switch to navi",ACTIONID_SWITCH_NC); |
||
214 | ligi | 238 | |
239 | |||
219 | ligi | 240 | //if ((settings.expert_mode)&& ( mk.ufo_prober.is_navi()||mk.ufo_prober.is_mk()||mk.ufo_prober.is_mk3mag()||mk.ufo_prober.is_incompatible() )) |
229 | ligi | 241 | |
242 | if (settings.expert_mode) |
||
242 | ligi | 243 | tmp_menu_add("Flash Firmware",ACTIONID_FLASH); |
229 | ligi | 244 | |
242 | ligi | 245 | if (settings.expert_mode&& mk.ufo_prober.is_mk() ) |
246 | tmp_menu_add("Remote Cam",ACTIONID_CAM); |
||
214 | ligi | 247 | |
229 | ligi | 248 | if (!settings.expert_mode) |
242 | ligi | 249 | tmp_menu_add("About",ACTIONID_ABOUT); |
214 | ligi | 250 | |
242 | ligi | 251 | tmp_menu_add("Quit",ACTIONID_QUIT); |
214 | ligi | 252 | |
242 | ligi | 253 | tmp_menu_use(); |
214 | ligi | 254 | } |
255 | |||
256 | |||
206 | ligi | 257 | public void setup_menu(String[] items , byte[] actions) |
258 | { |
||
259 | menu_items=items; |
||
260 | menu_actions=actions; |
||
261 | lcd_lines=new String[menu_items.length]; |
||
262 | } |
||
263 | |||
264 | public void paint_menu(Graphics g) |
||
265 | { |
||
266 | for ( int i=0;i<menu_items.length;i++) |
||
267 | { |
||
268 | if ((frame_pos%3)!=0) |
||
269 | { |
||
270 | lcd_lines[i]=(act_menu_select==i?">":" ") + menu_items[i]; |
||
271 | for ( int ii=0;ii<(18-menu_items[i].length());ii++) |
||
272 | lcd_lines[i]+=" "; |
||
273 | if (act_menu_select==i) |
||
274 | lcd_lines[i]+="<"; |
||
275 | } |
||
276 | else |
||
277 | lcd_lines[i]=" " + menu_items[i]; |
||
278 | |||
279 | |||
280 | } |
||
221 | ligi | 281 | paint_lcd(g); |
206 | ligi | 282 | } |
283 | |||
284 | public void menu_keypress(int keyCode) |
||
285 | { |
||
286 | debug.log("Menu with KeyCode:"+keyCode); |
||
287 | switch (getGameAction (keyCode)) |
||
288 | { |
||
289 | case UP: |
||
220 | ligi | 290 | if (act_menu_select!=0) |
291 | act_menu_select--; |
||
206 | ligi | 292 | else |
293 | act_menu_select=menu_items.length-1; |
||
294 | break; |
||
295 | |||
296 | case DOWN: |
||
220 | ligi | 297 | if (act_menu_select<(menu_items.length-1)) |
298 | act_menu_select++; |
||
299 | else |
||
300 | act_menu_select=0; |
||
206 | ligi | 301 | break; |
302 | |||
303 | } |
||
304 | |||
305 | } |
||
306 | |||
307 | public boolean cam_condition() |
||
308 | { |
||
221 | ligi | 309 | return (mk.stick_data.stick[settings.remote_cam_stick]>100); |
206 | ligi | 310 | } |
311 | |||
312 | // int lcd_top=25; |
||
242 | ligi | 313 | int lcd_off; |
221 | ligi | 314 | public void paint_lcd(Graphics g) |
206 | ligi | 315 | { |
316 | int y; |
||
220 | ligi | 317 | // int lcd_top= (state==STATEID_EDIT_PARAMS?0:25); |
221 | ligi | 318 | //int lcd_top= 25; |
319 | max_lines=(canvas_height-25/*lcd_top*/)/lcd_char_height; |
||
206 | ligi | 320 | int spacer_left_right=(canvas_width-(20*(lcd_img.getWidth()/222)))/2; |
321 | // for(int i=0;i<lcd_lines.length;i++) |
||
322 | |||
323 | int display_lines=(lcd_lines.length>max_lines?max_lines:lcd_lines.length); |
||
324 | |||
325 | |||
242 | ligi | 326 | lcd_off= (((state==STATEID_EDIT_PARAMS)&&(!params_editor.select_mode))?params_editor.act_y:act_menu_select)-display_lines+1; |
206 | ligi | 327 | if ( lcd_off<0) lcd_off=0; |
328 | |||
329 | for(int i=0;i<display_lines;i++) |
||
330 | for (int pos=0;pos<20;pos++) |
||
331 | { |
||
221 | ligi | 332 | /*if (!bottomup) |
333 | y=i*lcd_char_height; |
||
334 | else*/ |
||
223 | ligi | 335 | y=canvas_height-(display_lines-i)*lcd_char_height; |
221 | ligi | 336 | |
206 | ligi | 337 | g.setClip((lcd_img.getWidth()/222)*pos+spacer_left_right,y,(lcd_img.getWidth()/222),lcd_img.getHeight()); |
338 | g.drawImage(lcd_img,spacer_left_right+(lcd_img.getWidth()/222)*pos-((pos<lcd_lines[i+lcd_off].length()?lcd_lines[i+lcd_off].charAt(pos):' ')-' ')*(lcd_img.getWidth()/222),y,g.TOP | g.LEFT); |
||
339 | } |
||
340 | } |
||
341 | |||
221 | ligi | 342 | public void load_skin_images() |
206 | ligi | 343 | { |
344 | try |
||
345 | { |
||
346 | bg_img=null; |
||
347 | lcd_img=null; |
||
348 | |||
349 | // load all needed images |
||
350 | switch (settings.act_skin) |
||
351 | { |
||
352 | case SKINID_DARK: |
||
353 | lcd_img=Image.createImage("/lcd_green.png"); |
||
221 | ligi | 354 | if (settings.do_scrollbg) bg_img=Image.createImage("/starfield.jpg"); |
355 | break; |
||
356 | |||
357 | |||
206 | ligi | 358 | case SKINID_LIGHT: |
359 | lcd_img=Image.createImage("/lcd_blue.png"); |
||
360 | if (settings.do_scrollbg) bg_img=Image.createImage("/clouds.jpg"); |
||
361 | break; |
||
362 | } |
||
223 | ligi | 363 | // lcd_char_width=lcd_img.getWidth()/222; |
221 | ligi | 364 | lcd_char_height=lcd_img.getHeight(); |
365 | } |
||
206 | ligi | 366 | |
221 | ligi | 367 | catch (Exception e) |
368 | { |
||
369 | debug.err(e.toString()); |
||
370 | } |
||
206 | ligi | 371 | |
221 | ligi | 372 | } |
373 | public void load_global_images() |
||
374 | { |
||
375 | try |
||
376 | { |
||
206 | ligi | 377 | symbols_img=Image.createImage("/symbols.png"); |
242 | ligi | 378 | symbols_img_tile_height=symbols_img.getHeight()/2; |
379 | symbols_img_tile_width=symbols_img.getWidth()/10; |
||
206 | ligi | 380 | |
221 | ligi | 381 | /* if (bg_img!=null) |
206 | ligi | 382 | graph_data=new int[GRAPH_COUNT][bg_img.getWidth()]; |
383 | else |
||
221 | ligi | 384 | */ |
206 | ligi | 385 | |
386 | } |
||
387 | |||
388 | catch (Exception e) |
||
389 | { |
||
390 | debug.err(e.toString()); |
||
391 | } |
||
392 | |||
393 | } |
||
394 | |||
221 | ligi | 395 | // construct |
206 | ligi | 396 | public DUBwiseCanvas(DUBwise _root) |
397 | { |
||
398 | |||
224 | ligi | 399 | act_menu_select_bak=new int[STATEID_COUNT]; |
400 | for (int i=0;i<STATEID_COUNT;i++) |
||
223 | ligi | 401 | act_menu_select_bak[i]=0; |
206 | ligi | 402 | //#if fileapi=="on" |
221 | ligi | 403 | file_access=new DUBwiseFileAccess(this); |
206 | ligi | 404 | //#endif |
405 | |||
406 | root=_root; |
||
407 | |||
408 | mk = new org.ligi.ufo.MKCommunicator(); |
||
229 | ligi | 409 | |
410 | |||
411 | //#if voice_mode!="no_voice" |
||
412 | status_voice=new MKStatusVoice(mk,this); |
||
413 | //#endif |
||
414 | |||
220 | ligi | 415 | settings = new DUBwiseSettings(this); |
416 | settings.load(); |
||
221 | ligi | 417 | load_global_images(); |
206 | ligi | 418 | debug = new DUBwiseDebug(this); |
419 | |||
420 | //#if bluetooth=="on" |
||
421 | bt_scanner = new BTSearcher(); |
||
422 | //#endif |
||
423 | |||
424 | |||
425 | |||
211 | ligi | 426 | |
221 | ligi | 427 | |
211 | ligi | 428 | mk.gps_position.act_speed_format=settings.speed_format; |
429 | mk.gps_position.act_gps_format= settings.gps_format; |
||
206 | ligi | 430 | |
221 | ligi | 431 | |
206 | ligi | 432 | chg_state(STATEID_MAINMENU); |
433 | |||
434 | new Thread(this).start(); |
||
435 | |||
221 | ligi | 436 | if (settings.connection_url!="") |
437 | connect_mk(settings.connection_url,settings.connection_name); |
||
206 | ligi | 438 | } |
439 | |||
440 | |||
441 | /****************************** Thread ******************/ |
||
442 | // ticking runnable Section |
||
443 | public void run() |
||
444 | { |
||
445 | while(true) |
||
446 | { |
||
447 | try { |
||
448 | |||
449 | |||
450 | repaint(); |
||
451 | serviceRepaints(); |
||
452 | |||
453 | System.gc(); |
||
454 | long loopStartTime = System.currentTimeMillis(); |
||
455 | long sleeptime=0; |
||
456 | // ticked thing |
||
457 | |||
458 | frame_pos++; |
||
459 | |||
460 | if (mk.ufo_prober.change_notify) |
||
461 | { |
||
462 | mk.ufo_prober.change_notify=false; |
||
463 | if (mk.ufo_prober.is_incompatible()) |
||
464 | { |
||
465 | mk.error_str="incompatible Device"; |
||
224 | ligi | 466 | chg_state(STATEID_ERROR_MSG); |
206 | ligi | 467 | } |
468 | else |
||
469 | if (state==STATEID_MAINMENU) |
||
470 | chg_state(STATEID_MAINMENU); // reload mainmenu ( changed content ) |
||
471 | } |
||
472 | |||
211 | ligi | 473 | |
206 | ligi | 474 | switch(state) |
475 | { |
||
224 | ligi | 476 | |
477 | case STATEID_RESET_PARAMS: |
||
233 | ligi | 478 | |
224 | ligi | 479 | if (mk.bootloader_finish_ok) |
480 | { |
||
233 | ligi | 481 | mk.params.reset(); |
482 | mk.watchdog.act_paramset=0; |
||
224 | ligi | 483 | nextstate=STATEID_PARAM_MENU; |
484 | success_msg="Param Reset Success!"; |
||
485 | chg_state(STATEID_SUCCESS_MSG); |
||
486 | } |
||
487 | break; |
||
221 | ligi | 488 | case STATEID_GRAPH: |
489 | graph_offset--; |
||
490 | if (graph_offset==-graph_data[0].length) |
||
491 | graph_offset=0; |
||
492 | break; |
||
493 | |||
206 | ligi | 494 | case STATEID_CAMMODE: |
211 | ligi | 495 | |
496 | try |
||
497 | { |
||
498 | if(cam_condition()) |
||
499 | { |
||
206 | ligi | 500 | cam_img=null; |
501 | debug.log("get snap\n"); |
||
502 | cam_raw = mVideoControl.getSnapshot(null); |
||
211 | ligi | 503 | |
221 | ligi | 504 | |
206 | ligi | 505 | try { Thread.sleep(4000); } |
506 | catch (Exception e) |
||
507 | { |
||
508 | debug.log("Problem Sleeping "); |
||
211 | ligi | 509 | |
206 | ligi | 510 | } |
221 | ligi | 511 | cam_img = Image.createImage(cam_raw, 0, cam_raw.length); |
211 | ligi | 512 | } |
513 | else |
||
514 | { |
||
515 | if (cam_img==null) |
||
221 | ligi | 516 | ;; |
211 | ligi | 517 | } |
518 | } |
||
519 | catch ( Exception e) |
||
520 | { |
||
521 | debug.log(e.toString()); |
||
522 | } |
||
206 | ligi | 523 | break; |
524 | case STATEID_KEYCONTROL: |
||
219 | ligi | 525 | //mk.send_keys(keycontrol_bitfield); |
206 | ligi | 526 | break; |
211 | ligi | 527 | |
224 | ligi | 528 | |
529 | case STATEID_ERROR_MSG: |
||
206 | ligi | 530 | lcd_lines[0]=""+mk.error_str; |
531 | break; |
||
211 | ligi | 532 | |
206 | ligi | 533 | case STATEID_READ_PARAMS: |
534 | if (mk.watchdog.act_paramset==5) |
||
223 | ligi | 535 | { |
242 | ligi | 536 | if (read_paramset_intension_save) |
537 | { |
||
538 | |||
539 | try |
||
540 | { |
||
541 | RecordStore.deleteRecordStore( PARAM_SAVE_STORE_NAME); |
||
542 | } |
||
543 | catch (Exception e) |
||
544 | { } |
||
545 | |||
546 | try { |
||
547 | RecordStore recStore = RecordStore.openRecordStore( PARAM_SAVE_STORE_NAME, true ); |
||
548 | |||
549 | ByteArrayOutputStream bout = new ByteArrayOutputStream(); |
||
550 | DataOutputStream dout = new DataOutputStream( bout ); |
||
551 | |||
552 | // params_version |
||
553 | dout.writeInt(mk.params.params_version); |
||
554 | |||
555 | // params_length |
||
556 | dout.writeInt(mk.params.field_bak[0].length); |
||
557 | |||
558 | for (int p=0;p<5;p++) |
||
559 | for (int i=0;i<mk.params.field_bak[0].length;i++) |
||
560 | dout.writeInt(mk.params.field_bak[p][i]); |
||
561 | |||
562 | recStore.addRecord(bout.toByteArray(),0,bout.size()); |
||
563 | recStore.closeRecordStore(); |
||
564 | |||
565 | |||
566 | } |
||
567 | catch (Exception e) |
||
568 | { } |
||
569 | // chg_state(STATEID_COPY_PARAMS); |
||
570 | nextstate=STATEID_HANDLE_PARAMS; |
||
571 | success_msg="Parameter Copy OK"; |
||
572 | chg_state(STATEID_SUCCESS_MSG); |
||
573 | |||
574 | } |
||
575 | else |
||
576 | { |
||
577 | chg_state(STATEID_SELECT_PARAMSET); |
||
578 | select_paramset4edit=true; |
||
579 | } |
||
580 | |||
223 | ligi | 581 | } |
206 | ligi | 582 | else |
583 | { |
||
584 | lcd_lines[0]="Reading Settings "; |
||
585 | lcd_lines[1]=mk.watchdog.act_paramset+"/5 |"+ (mk.watchdog.act_paramset>0?"#":"_") + (mk.watchdog.act_paramset>1?"#":"_") + (mk.watchdog.act_paramset>2?"#":"_")+ (mk.watchdog.act_paramset>3?"#":"_")+ (mk.watchdog.act_paramset>4?"#":"_") + "| "; |
||
211 | ligi | 586 | |
206 | ligi | 587 | if (mk.params.found_incompatible) |
588 | { |
||
589 | mk.error_str="incompatible params"; |
||
224 | ligi | 590 | chg_state(STATEID_ERROR_MSG); |
206 | ligi | 591 | } |
211 | ligi | 592 | |
206 | ligi | 593 | } |
594 | break; |
||
211 | ligi | 595 | |
206 | ligi | 596 | |
597 | case STATEID_MOTORTEST: |
||
598 | |||
599 | if (motor_test_sel_all) |
||
600 | for (int m=0;m<4;m++) |
||
601 | { |
||
602 | motor_test[m]+=act_motor_increase; |
||
603 | if (motor_test[m]<0)motor_test[m]=0; |
||
604 | if (motor_test[m]>255)motor_test[m]=255; |
||
605 | } |
||
606 | else |
||
607 | { |
||
608 | motor_test[act_motor]+=act_motor_increase; |
||
609 | if (motor_test[act_motor]<0) motor_test[act_motor]=0; |
||
610 | if (motor_test[act_motor]>255) motor_test[act_motor]=255; |
||
611 | } |
||
612 | |||
613 | mk.motor_test(motor_test); |
||
614 | break; |
||
615 | |||
213 | ligi | 616 | case STATEID_STRINGINPUT: |
617 | |||
618 | lcd_lines[0]=act_input_str; |
||
619 | for(int tmp_i=act_input_str.length();tmp_i<20;tmp_i++) |
||
620 | lcd_lines[0]+=(char)(0); |
||
621 | |||
622 | lcd_lines[1]=""; |
||
623 | for(int foo=0;foo<20;foo++) |
||
624 | { |
||
625 | if (foo==ipinput_pos) |
||
626 | lcd_lines[1]+="^"; |
||
627 | else |
||
628 | lcd_lines[1]+=" "; |
||
629 | } |
||
630 | break; |
||
631 | |||
632 | |||
206 | ligi | 633 | case STATEID_IPINPUT: |
634 | if (ipinput4proxy) |
||
635 | act_edit_ip=settings.act_proxy_ip; |
||
636 | else |
||
637 | act_edit_ip=settings.act_conn_ip; |
||
638 | |||
223 | ligi | 639 | lcd_lines[1]=DUBwiseHelper.ip_str(act_edit_ip,true); |
206 | ligi | 640 | |
641 | |||
642 | lcd_lines[2]=""; |
||
643 | for(int foo=0;foo<20;foo++) |
||
644 | { |
||
645 | if (foo==ipinput_pos) |
||
646 | lcd_lines[2]+="^"; |
||
647 | else |
||
648 | lcd_lines[2]+=" "; |
||
649 | } |
||
650 | break; |
||
651 | |||
652 | case STATEID_MAINMENU: |
||
653 | |||
654 | break; |
||
655 | |||
656 | //#if bluetooth=="on" |
||
657 | case STATEID_SCANNING: |
||
211 | ligi | 658 | |
659 | lcd_lines[1]="Bluetooth Devices " + idle_seq[(((frame_pos/5)%idle_seq.length))]; |
||
206 | ligi | 660 | lcd_lines[2]="found " + bt_scanner.remote_device_count; |
661 | |||
662 | if (!bt_scanner.searching) |
||
663 | chg_state(STATEID_DEVICESELECT); |
||
664 | |||
665 | break; |
||
666 | //#endif |
||
667 | |||
668 | |||
669 | } |
||
670 | |||
671 | if (quit) |
||
672 | { |
||
211 | ligi | 673 | settings.speed_format=mk.gps_position.act_speed_format; |
674 | settings.gps_format=mk.gps_position.act_gps_format; |
||
206 | ligi | 675 | settings.save(); |
676 | root.quit(); |
||
677 | } |
||
678 | |||
221 | ligi | 679 | |
206 | ligi | 680 | //rescan=false; |
221 | ligi | 681 | |
682 | if (bg_img!=null) |
||
683 | { |
||
684 | bg_offset--; |
||
685 | if (bg_offset==-bg_img.getWidth()) |
||
686 | bg_offset=0; |
||
687 | } |
||
688 | |||
689 | |||
690 | |||
691 | |||
206 | ligi | 692 | //#if devicecontrol=="on" |
221 | ligi | 693 | |
694 | try { |
||
206 | ligi | 695 | if (settings.keep_lighton) com.nokia.mid.ui.DeviceControl.setLights(0,100); |
696 | //#endif |
||
697 | } |
||
698 | catch (Exception e) { } |
||
699 | |||
700 | |||
701 | sleeptime=1000/ 15 - (int) (System.currentTimeMillis()- loopStartTime); |
||
702 | |||
703 | if (sleeptime<0) |
||
704 | sleeptime=100; // everyone has fi sleep |
||
705 | |||
706 | try { Thread.sleep(sleeptime); } |
||
707 | catch (Exception e) |
||
708 | { |
||
709 | debug.log("Problem Sleeping "); |
||
710 | } |
||
711 | |||
712 | } |
||
713 | catch (Exception e) |
||
714 | { |
||
715 | debug.log("E!:"+e.getMessage()); |
||
716 | |||
717 | } |
||
718 | } |
||
719 | } |
||
720 | |||
721 | |||
722 | |||
723 | boolean firstrun=true; |
||
724 | |||
725 | public int skin_bg_color() |
||
726 | { |
||
727 | |||
728 | switch (settings.act_skin) |
||
729 | { |
||
730 | case SKINID_DARK: |
||
731 | return 0x000000; |
||
732 | |||
733 | default: |
||
734 | case SKINID_LIGHT: |
||
735 | return 0xFFFFFF; |
||
736 | } |
||
737 | } |
||
738 | |||
739 | |||
740 | public int skin_fg_color() |
||
741 | { |
||
742 | |||
743 | switch (settings.act_skin) |
||
744 | { |
||
745 | case SKINID_DARK: |
||
746 | return 0xFFFFFF; |
||
747 | |||
748 | default: |
||
749 | case SKINID_LIGHT: |
||
750 | return 0x000000; |
||
751 | } |
||
752 | } |
||
753 | |||
223 | ligi | 754 | |
755 | public int check_local_max(int val) |
||
756 | { |
||
757 | if ( val>local_max) |
||
758 | local_max=val; |
||
759 | else if (-val>local_max) |
||
760 | local_max=-val; |
||
761 | return val; |
||
762 | } |
||
242 | ligi | 763 | |
764 | |||
765 | |||
766 | |||
767 | public void symbol_paint(Graphics g,int x,int tile,int row) |
||
768 | { |
||
769 | g.setClip(x,0,(symbols_img_tile_width),symbols_img_tile_height);; |
||
770 | g.drawImage(symbols_img,x+(-tile)*(symbols_img_tile_width),row*(-symbols_img_tile_height), g.TOP | g.LEFT); |
||
771 | } |
||
772 | |||
773 | |||
774 | |||
775 | |||
776 | // drawing sections |
||
206 | ligi | 777 | public void paint(Graphics g) { |
778 | |||
779 | canvas_width=this.getWidth(); |
||
780 | canvas_height=this.getHeight(); |
||
781 | |||
223 | ligi | 782 | |
229 | ligi | 783 | |
206 | ligi | 784 | if (debug.showing) |
785 | { |
||
786 | debug.paint(g); |
||
787 | return; |
||
788 | } |
||
789 | |||
790 | |||
791 | if (firstrun) |
||
792 | { |
||
793 | if (settings.fullscreen) setFullScreenMode(settings.fullscreen); |
||
794 | firstrun=false; |
||
795 | } |
||
796 | y_off=0; |
||
797 | |||
798 | |||
799 | |||
800 | try { |
||
222 | ligi | 801 | |
206 | ligi | 802 | |
803 | |||
804 | Font f1 = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM); |
||
805 | Font f2 = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL); |
||
806 | |||
807 | spacer=(f1.getHeight()); |
||
808 | spacer1=(f2.getHeight()); |
||
809 | |||
810 | //default Font |
||
811 | g.setFont(f1); |
||
812 | |||
813 | |||
814 | //draw background |
||
242 | ligi | 815 | if (settings.do_scrollbg) |
206 | ligi | 816 | { |
817 | g.setColor(0xFFFFFF); |
||
818 | g.fillRect(0,0,canvas_width,canvas_height); |
||
819 | g.drawImage(bg_img,bg_offset,0, g.TOP | g.LEFT); |
||
820 | |||
821 | if (bg_offset+bg_img.getWidth()<canvas_width) |
||
242 | ligi | 822 | g.drawImage(bg_img,bg_offset+bg_img.getWidth(),0, g.TOP | g.LEFT); |
823 | |||
206 | ligi | 824 | } |
242 | ligi | 825 | else |
826 | { |
||
827 | g.setColor(0xdedfff); |
||
828 | g.fillRect(0,0,canvas_width,symbols_img_tile_height); |
||
206 | ligi | 829 | |
242 | ligi | 830 | g.setColor(skin_bg_color()); |
831 | g.fillRect(0,symbols_img_tile_height,canvas_width,canvas_height-symbols_img.getHeight()); |
||
832 | } |
||
206 | ligi | 833 | |
242 | ligi | 834 | |
206 | ligi | 835 | //int bar=0; |
836 | // for ( int bar=0;bar<3;bar++) |
||
837 | if (settings.do_scrollbg) |
||
838 | for ( int bar=0;bar<canvas_width/(symbols_img.getWidth()/10)+1;bar++) |
||
839 | { |
||
242 | ligi | 840 | g.setClip(bar*(symbols_img_tile_width),0,(symbols_img_tile_width),symbols_img_tile_height);; |
841 | g.drawImage(symbols_img,bar*(symbols_img_tile_width),0, g.TOP | g.LEFT); |
||
206 | ligi | 842 | } |
843 | |||
844 | int symbol_left=0; |
||
219 | ligi | 845 | int symbol_spacer=5; |
206 | ligi | 846 | |
242 | ligi | 847 | g.setClip(symbol_left,0,symbols_img_tile_width,symbols_img_tile_height);; |
219 | ligi | 848 | if (mk.connected) |
242 | ligi | 849 | symbol_paint(g,symbol_left,(((mk.stats.bytes_in>>3)&1)==1)?2:3,0); |
206 | ligi | 850 | |
242 | ligi | 851 | else |
852 | symbol_paint(g,symbol_left,1,0); |
||
853 | // g.drawImage(symbols_img,(-1)*(symbols_img.getWidth()/10),0, g.TOP | g.LEFT); |
||
206 | ligi | 854 | |
219 | ligi | 855 | |
856 | |||
242 | ligi | 857 | symbol_left+=6*(symbols_img_tile_width)/4; |
219 | ligi | 858 | |
859 | |||
242 | ligi | 860 | if ((mk.ufo_prober.is_navi()||mk.ufo_prober.is_mk())) |
861 | { |
||
219 | ligi | 862 | |
242 | ligi | 863 | symbol_paint(g,symbol_left,4,0); |
864 | symbol_left+=5 *(symbols_img_tile_width)/4; |
||
219 | ligi | 865 | |
242 | ligi | 866 | if ((mk.UBatt()/100)!=0) |
867 | { |
||
868 | symbol_paint(g,symbol_left,(mk.UBatt()/100),1); |
||
869 | symbol_left+=(symbols_img_tile_width); |
||
870 | } |
||
219 | ligi | 871 | |
242 | ligi | 872 | symbol_paint(g,symbol_left,(mk.UBatt()/10)%10,1); |
873 | symbol_left+=(2*symbols_img_tile_width/3); |
||
874 | symbol_paint(g,symbol_left,9,0); |
||
875 | symbol_left+=(2*symbols_img_tile_width/3); |
||
876 | symbol_paint(g,symbol_left,(mk.UBatt())%10,1); |
||
877 | symbol_left+=6*(symbols_img_tile_width)/4; |
||
219 | ligi | 878 | |
879 | |||
242 | ligi | 880 | // g.drawString("" + (mk.UBatt()/10) + "," +(mk.UBatt()%10)+"V" , symbol_left,y_off,Graphics.TOP | Graphics.LEFT); |
219 | ligi | 881 | |
206 | ligi | 882 | |
242 | ligi | 883 | //symbol_left+= g.getFont().stringWidth("88,8V");//; |
206 | ligi | 884 | |
242 | ligi | 885 | symbol_paint(g,symbol_left,6,0); |
886 | symbol_left+=5*(symbols_img_tile_width)/4; |
||
206 | ligi | 887 | |
245 | ligi | 888 | if (mk.SenderOkay()!=0) |
889 | { |
||
890 | symbol_paint(g,symbol_left,(mk.SenderOkay())/100,1); |
||
891 | symbol_left+=(symbols_img_tile_width); |
||
206 | ligi | 892 | |
245 | ligi | 893 | symbol_paint(g,symbol_left,(mk.SenderOkay()/10)%10,1); |
894 | symbol_left+=(symbols_img_tile_width); |
||
895 | } |
||
242 | ligi | 896 | symbol_paint(g,symbol_left,(mk.SenderOkay())%10,1); |
897 | symbol_left+=6*(symbols_img_tile_width)/4; |
||
206 | ligi | 898 | |
242 | ligi | 899 | // g.drawString(""+mk.SenderOkay() ,symbol_left,y_off,Graphics.TOP | Graphics.LEFT); |
206 | ligi | 900 | |
901 | |||
242 | ligi | 902 | //symbol_left+= g.getFont().stringWidth("8")+symbol_spacer; //,0,(symbols_img.getWidth()/10)+2; |
206 | ligi | 903 | |
904 | |||
905 | |||
906 | |||
907 | if (mk.ufo_prober.is_navi()) |
||
908 | { |
||
242 | ligi | 909 | symbol_paint(g,symbol_left,5,0); |
910 | symbol_left+=5*(symbols_img_tile_width)/4; |
||
206 | ligi | 911 | |
242 | ligi | 912 | symbol_paint(g,symbol_left,(mk.gps_position.SatsInUse)%10,1); |
913 | symbol_left+=6*(symbols_img_tile_width)/4; |
||
206 | ligi | 914 | |
242 | ligi | 915 | |
206 | ligi | 916 | g.setClip(symbol_left,0,(symbols_img.getWidth()/10),symbols_img.getHeight()); |
917 | g.drawImage(symbols_img,(-5)*(symbols_img.getWidth()/10) + symbol_left,0, g.TOP | g.LEFT); |
||
918 | g.setClip(0,0,canvas_width,canvas_height); |
||
919 | symbol_left+=2+(symbols_img.getWidth()/10); |
||
920 | g.drawString(""+mk.gps_position.SatsInUse ,symbol_left,y_off,Graphics.TOP | Graphics.LEFT); |
||
921 | |||
922 | } |
||
923 | |||
924 | } |
||
925 | |||
926 | |||
927 | // unclip |
||
928 | g.setClip(0,0,canvas_width,canvas_height); |
||
929 | |||
242 | ligi | 930 | y_off+=symbols_img_tile_height; |
229 | ligi | 931 | graph_height=(canvas_height-y_off)/2; |
932 | line_middle_y=graph_height+y_off; |
||
206 | ligi | 933 | g.setColor(skin_fg_color()); |
934 | |||
935 | switch(state) |
||
936 | { |
||
222 | ligi | 937 | case STATEID_HORIZON: |
206 | ligi | 938 | |
222 | ligi | 939 | g.setStrokeStyle(Graphics.SOLID); |
940 | g.setColor(0x6e4e1d); |
||
206 | ligi | 941 | |
222 | ligi | 942 | int horizon_height=(canvas_height-y_off)/2; |
943 | int horizon_middle=y_off+horizon_height; |
||
944 | |||
945 | |||
946 | int horizon_roll_pixels= (mk.angle_roll*horizon_height)/600; |
||
947 | int horizon_roll_pixels_=horizon_roll_pixels; |
||
948 | |||
949 | |||
950 | int nick_bar_width=canvas_width/4; |
||
951 | int nick_bar_height= nick_bar_width/2; |
||
952 | |||
953 | |||
954 | int nick_size=canvas_width/4; |
||
955 | int nick_pixels_y=(mk.angle_nick*horizon_height)/900; |
||
956 | |||
957 | int nick_pixels_x; |
||
958 | if ((mk.angle_roll*mk.angle_nick)>1) |
||
959 | nick_pixels_x=-((int)Math.sqrt(mk.angle_roll*mk.angle_nick)*(canvas_width/2))/(900); |
||
960 | else |
||
961 | nick_pixels_x=((int)Math.sqrt(-mk.angle_roll*mk.angle_nick)*(canvas_width/2))/(900); |
||
962 | |||
963 | while (horizon_roll_pixels!=0) |
||
964 | { |
||
965 | |||
966 | if (horizon_roll_pixels_>0) |
||
967 | { |
||
968 | g.drawLine(0,horizon_middle+horizon_roll_pixels_,canvas_width,horizon_middle-horizon_roll_pixels); |
||
969 | g.drawLine(0,horizon_middle+horizon_roll_pixels_,canvas_width,horizon_middle+horizon_roll_pixels); |
||
970 | } |
||
971 | else |
||
972 | { |
||
973 | g.drawLine(0,horizon_middle+horizon_roll_pixels,canvas_width,horizon_middle-horizon_roll_pixels_); |
||
974 | g.drawLine(0,horizon_middle-horizon_roll_pixels,canvas_width,horizon_middle-horizon_roll_pixels_); |
||
975 | } |
||
976 | // g.drawLine(0,horizon_middle-horizon_roll_pixels_,canvas_width,horizon_middle-horizon_roll_pixels); |
||
977 | horizon_roll_pixels+=(horizon_roll_pixels<0)?1:-1; // go to 0 |
||
978 | |||
979 | /*g.drawLine(0,horizon_middle-horizon_roll_pixels,canvas_width,horizon_middle+horizon_roll_pixels); |
||
980 | if (horizon_roll_pixels<0) |
||
981 | g.drawLine(0,horizon_middle-horizon_roll_pixels_,canvas_width,horizon_middle-horizon_roll_pixels); |
||
982 | else |
||
983 | g.drawLine(0,horizon_middle+horizon_roll_pixels,canvas_width,horizon_middle+horizon_roll_pixels_); |
||
984 | |||
985 | horizon_roll_pixels+=(horizon_roll_pixels<0)?1:-1; // go to 0 |
||
986 | */ |
||
987 | } |
||
988 | |||
989 | if (horizon_roll_pixels_>0) |
||
990 | { |
||
991 | g.drawLine(0,horizon_middle+horizon_roll_pixels_,canvas_width,horizon_middle-horizon_roll_pixels); |
||
992 | g.drawLine(0,horizon_middle+horizon_roll_pixels_,canvas_width,horizon_middle+horizon_roll_pixels); |
||
993 | g.fillRect(0,horizon_middle+horizon_roll_pixels_,canvas_width,canvas_height-(horizon_middle+horizon_roll_pixels_)); |
||
994 | } |
||
995 | else |
||
996 | { |
||
997 | g.drawLine(0,horizon_middle+horizon_roll_pixels,canvas_width,horizon_middle-horizon_roll_pixels_); |
||
998 | g.drawLine(0,horizon_middle-horizon_roll_pixels,canvas_width,horizon_middle-horizon_roll_pixels_); |
||
999 | g.fillRect(0,horizon_middle-horizon_roll_pixels_,canvas_width,canvas_height-(horizon_middle-horizon_roll_pixels_)); |
||
1000 | } |
||
1001 | |||
1002 | |||
1003 | g.setColor(0x254d9e); |
||
1004 | g.fillArc((canvas_width-nick_size)/2- nick_pixels_x, horizon_middle-nick_size/2+ nick_pixels_y, nick_size, nick_size, 0,360); |
||
1005 | |||
1006 | // for (i=0;i<horizon_roll_pixels |
||
1007 | // g.fillArc(0, 0, canvas_width, canvas_width, 0,45); |
||
1008 | |||
1009 | /* |
||
1010 | int start_angle=(360+mk.gps_position.angle2wp(act_wp) - ((360+mk.debug_data.analog[26]-heading_offset)%360))%360; |
||
1011 | // start_angle=0; |
||
1012 | start_angle=(360-start_angle +90 -(45/2))%360; |
||
1013 | |||
1014 | g.fillArc(0, 0, canvas_width, canvas_width, start_angle,45); |
||
1015 | */ |
||
1016 | // g.drawArc(1, 1, canvas_width-2, canvas_width-2, start_angle,45); |
||
1017 | // g.drawArc(2, 2, canvas_width-4, canvas_width-4, start_angle ,45); |
||
1018 | |||
1019 | |||
1020 | g.setColor(skin_fg_color()); |
||
1021 | |||
1022 | |||
1023 | |||
1024 | if (settings.expert_mode) |
||
1025 | { |
||
1026 | g.drawString("nick => " + mk.angle_nick,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1027 | y_off+=spacer; |
||
1028 | |||
1029 | g.drawString("roll => " + mk.angle_roll,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1030 | y_off+=spacer; |
||
1031 | } |
||
1032 | break; |
||
1033 | |||
206 | ligi | 1034 | case STATEID_DATABUFF: |
1035 | g.setFont(f2); |
||
1036 | |||
245 | ligi | 1037 | int lines2paint=(((canvas_height-y_off)/spacer1)); |
206 | ligi | 1038 | y_off=canvas_height-spacer1; |
1039 | |||
245 | ligi | 1040 | for (int pos_y=0;pos_y<lines2paint;pos_y++) |
206 | ligi | 1041 | { |
1042 | |||
1043 | g.drawString(mk.get_buff(pos_y) ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1044 | y_off-=spacer1; |
||
1045 | } |
||
1046 | break; |
||
224 | ligi | 1047 | |
1048 | case STATEID_SUCCESS_MSG: |
||
1049 | case STATEID_ERROR_MSG: |
||
214 | ligi | 1050 | if (err_img!=null) |
206 | ligi | 1051 | { |
1052 | int err_img_left=(canvas_width-err_img.getWidth()/2)/2; |
||
1053 | int err_img_top=(canvas_height-err_img.getHeight())/2; |
||
224 | ligi | 1054 | if (err_img_top<0)err_img_top=0; |
206 | ligi | 1055 | g.setClip(err_img_left,err_img_top,err_img.getWidth()/2,err_img.getHeight()); |
224 | ligi | 1056 | g.drawImage(err_img,err_img_left-((state==STATEID_SUCCESS_MSG)?0:(err_img.getWidth()/2)),err_img_top, g.TOP | g.LEFT); |
206 | ligi | 1057 | } |
221 | ligi | 1058 | paint_lcd(g); |
206 | ligi | 1059 | |
224 | ligi | 1060 | break; |
206 | ligi | 1061 | |
1062 | case STATEID_GPSVIEW: |
||
1063 | |||
1064 | g.setFont(f2); |
||
1065 | |||
1066 | g.setStrokeStyle(Graphics.SOLID); |
||
1067 | g.setColor(0x0000ff); |
||
1068 | |||
1069 | |||
1070 | // g.fillArc(0, 0, canvas_width, canvas_width, 0,45); |
||
1071 | |||
1072 | /* |
||
1073 | int start_angle=(360+mk.gps_position.angle2wp(act_wp) - ((360+mk.debug_data.analog[26]-heading_offset)%360))%360; |
||
1074 | // start_angle=0; |
||
1075 | start_angle=(360-start_angle +90 -(45/2))%360; |
||
1076 | |||
1077 | g.fillArc(0, 0, canvas_width, canvas_width, start_angle,45); |
||
1078 | */ |
||
1079 | // g.drawArc(1, 1, canvas_width-2, canvas_width-2, start_angle,45); |
||
1080 | // g.drawArc(2, 2, canvas_width-4, canvas_width-4, start_angle ,45); |
||
1081 | |||
1082 | |||
1083 | g.setColor(skin_fg_color()); |
||
1084 | |||
1085 | g.drawString("Used Sats: " + mk.gps_position.SatsInUse + " | Packages: " + mk.stats.navi_data_count ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1086 | y_off+=spacer1; |
||
1087 | |||
1088 | g.drawString("Lat: " + mk.gps_position.Latitude_str() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1089 | y_off+=spacer1; |
||
1090 | |||
1091 | g.drawString("Long: " + mk.gps_position.Longitude_str() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1092 | y_off+=spacer1; |
||
1093 | |||
1094 | g.drawString("Altitude: " + mk.gps_position.Altitude ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1095 | y_off+=spacer1; |
||
211 | ligi | 1096 | |
1097 | g.drawString("GrSpeed: " + mk.gps_position.GroundSpeed_str() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1098 | y_off+=spacer1; |
||
1099 | |||
1100 | g.drawString("Heading: " + mk.gps_position.Heading ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1101 | y_off+=spacer1; |
||
1102 | |||
1103 | g.drawString("CompasHeading: " + mk.gps_position.CompasHeading ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1104 | y_off+=spacer1; |
||
206 | ligi | 1105 | |
1106 | |||
1107 | g.drawString("Target-Lat: " + mk.gps_position.TargetLatitude_str() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1108 | y_off+=spacer1; |
||
1109 | g.drawString("Target-Long: " + mk.gps_position.TargetLongitude_str() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1110 | y_off+=spacer1; |
||
1111 | |||
1112 | g.drawString("Target-Alt: " + mk.gps_position.TargetAltitude ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1113 | y_off+=spacer1; |
||
1114 | |||
1115 | |||
1116 | g.drawString("Home-Lat: " + mk.gps_position.HomeLatitude_str() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1117 | y_off+=spacer1; |
||
1118 | |||
1119 | g.drawString("Home-Long: " + mk.gps_position.HomeLongitude_str() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1120 | y_off+=spacer1; |
||
1121 | |||
1122 | g.drawString("Home-Alt: " + mk.gps_position.HomeAltitude ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1123 | |||
1124 | y_off+=spacer1; |
||
1125 | g.drawString("Distance : " + mk.gps_position.Distance2Target ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1126 | y_off+=spacer1; |
||
1127 | g.drawString("Angle: " + mk.gps_position.Angle2Target ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1128 | y_off+=spacer1; |
||
1129 | |||
1130 | g.drawString("WayPoints: " + mk.gps_position.WayPointNumber + "/" + mk.gps_position.WayPointIndex ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1131 | y_off+=spacer; |
||
1132 | |||
1133 | |||
1134 | |||
1135 | /* |
||
1136 | g.drawString("" + mk.gps_position.NameWP[act_wp] ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1137 | y_off+=spacer; |
||
1138 | |||
1139 | g.drawString("Lat: " + mk.gps_position.WP_Latitude_str(act_wp) ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1140 | y_off+=spacer; |
||
1141 | |||
1142 | g.drawString("Long: " + mk.gps_position.WP_Longitude_str(act_wp) ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1143 | y_off+=spacer; |
||
1144 | |||
1145 | |||
1146 | g.drawString("Distance: " + mk.gps_position.distance2wp(act_wp) ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1147 | y_off+=spacer; |
||
1148 | |||
1149 | g.drawString("Angle: " + mk.gps_position.angle2wp(act_wp) ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1150 | y_off+=spacer; |
||
1151 | |||
1152 | g.drawString("Compas Heading: " + (360+mk.debug_data.analog[26]-heading_offset)%360) + "(" +mk.debug_data.analog[26] +")" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1153 | y_off+=spacer; |
||
1154 | */ |
||
1155 | |||
1156 | |||
1157 | break; |
||
1158 | |||
224 | ligi | 1159 | case STATEID_RESET_PARAMS: |
206 | ligi | 1160 | case STATEID_FLASHING: |
219 | ligi | 1161 | g.setFont(f2); |
206 | ligi | 1162 | int msg_pos=0; |
1163 | while (mk.flash_msgs[msg_pos]!=null) |
||
1164 | { |
||
1165 | g.drawString(mk.flash_msgs[msg_pos] ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
219 | ligi | 1166 | y_off+=spacer1; |
206 | ligi | 1167 | msg_pos++; |
1168 | } |
||
1169 | break; |
||
1170 | |||
1171 | case STATEID_CAMMODE: |
||
1172 | |||
1173 | if (cam_img!=null) |
||
1174 | g.drawImage(cam_img,0,0,g.TOP | g.LEFT); |
||
221 | ligi | 1175 | g.drawString("condition: " + cam_condition() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
1176 | y_off+=spacer; |
||
1177 | g.drawString("width " + cam_img.getWidth(),0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1178 | y_off+=spacer; |
||
1179 | g.drawString("height " + cam_img.getHeight(),0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1180 | y_off+=spacer; |
||
1181 | break; |
||
206 | ligi | 1182 | |
1183 | case STATEID_STICKVIEW: |
||
1184 | |||
1185 | for(int tmp_y=0;tmp_y<10;tmp_y++) |
||
1186 | { |
||
1187 | g.drawString(""+tmp_y+"(" + mk.params.stick_names[tmp_y] + ")=>"+mk.stick_data.stick[tmp_y],0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1188 | y_off+=spacer; |
||
1189 | } |
||
1190 | break; |
||
1191 | |||
1192 | case STATEID_KEYCONTROL: |
||
1193 | |||
1194 | y_off+=spacer; |
||
222 | ligi | 1195 | g.drawString("UP or DOWN =>nick " + mk.extern_control[EXTERN_CONTROL_NICK],0,y_off,Graphics.TOP | Graphics.LEFT); |
206 | ligi | 1196 | y_off+=spacer; |
222 | ligi | 1197 | g.drawString("LEFT or RIGHT =>roll " + mk.extern_control[EXTERN_CONTROL_ROLL],0,y_off,Graphics.TOP | Graphics.LEFT); |
206 | ligi | 1198 | y_off+=spacer; |
222 | ligi | 1199 | g.drawString("1 or 4 =>altitude " + mk.extern_control[EXTERN_CONTROL_HIGHT],0,y_off,Graphics.TOP | Graphics.LEFT); |
206 | ligi | 1200 | |
1201 | y_off+=spacer; |
||
222 | ligi | 1202 | g.drawString("2 or 3 =>gier " + mk.extern_control[EXTERN_CONTROL_GIER],0,y_off,Graphics.TOP | Graphics.LEFT); |
206 | ligi | 1203 | |
1204 | y_off+=spacer; |
||
222 | ligi | 1205 | g.drawString("6 or 9 =>gas " + mk.extern_control[EXTERN_CONTROL_GAS],0,y_off,Graphics.TOP | Graphics.LEFT); |
219 | ligi | 1206 | |
1207 | y_off+=spacer; |
||
222 | ligi | 1208 | g.drawString("* and # =>exit",0,y_off,Graphics.TOP | Graphics.LEFT); |
206 | ligi | 1209 | y_off+=spacer; |
223 | ligi | 1210 | /* g.drawString("* and Fire =>Start Engines",0,y_off,Graphics.TOP | Graphics.LEFT); |
206 | ligi | 1211 | y_off+=spacer; |
222 | ligi | 1212 | g.drawString("* and 0 =>Stop Engines",0,y_off,Graphics.TOP | Graphics.LEFT); |
1213 | y_off+=spacer; |
||
223 | ligi | 1214 | */ |
219 | ligi | 1215 | g.drawString("sent:" + mk.stats.external_control_request_count +"confirm:" + mk.stats.external_control_confirm_frame_count,0,y_off,Graphics.TOP | Graphics.LEFT); |
1216 | y_off+=spacer; |
||
1217 | // g.drawString("bf1:"+ keycontrol_bitfield[0] ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1218 | //g.drawString("bf2:"+ keycontrol_bitfield[1] ,canvas_width/2,y_off,Graphics.TOP | Graphics.LEFT); |
||
206 | ligi | 1219 | |
1220 | break; |
||
1221 | |||
1222 | case STATEID_MOTORTEST: |
||
1223 | for (int bar=0;bar<4;bar++) |
||
1224 | |||
1225 | { |
||
1226 | g.setColor(((bar==act_motor)|motor_test_sel_all)?0x44CC44:0x4444DD); |
||
1227 | g.fillRect(canvas_width/(8*2)+bar*2*canvas_width/8,y_off+10,canvas_width/8,y_off+20+motor_test[bar]); |
||
1228 | g.setColor(0x000000); |
||
1229 | g.drawString(""+motor_test[bar] ,canvas_width/8+bar*2*canvas_width/8,y_off+10,Graphics.TOP | Graphics.HCENTER); |
||
1230 | g.drawString(""+mk.debug_data.motor_val(bar) ,canvas_width/8+bar*2*canvas_width/8,y_off+25,Graphics.TOP | Graphics.HCENTER); |
||
1231 | } |
||
242 | ligi | 1232 | g.setColor(skin_fg_color()); |
1233 | g.drawString(""+mk.debug_data.analog[2]+"<->"+mk.debug_data.analog[3] ,0,canvas_height-30,Graphics.TOP | Graphics.LEFT); |
||
206 | ligi | 1234 | break; |
1235 | |||
1236 | case STATEID_EDIT_PARAMS: |
||
1237 | params_editor.paint(g); |
||
1238 | break; |
||
1239 | |||
1240 | |||
242 | ligi | 1241 | |
206 | ligi | 1242 | //#if fileapi=="on" |
1243 | case STATEID_FILEOPEN: |
||
1244 | y_off+=spacer; |
||
221 | ligi | 1245 | g.drawString("act_path" + file_access.act_path() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
206 | ligi | 1246 | paint_menu(g); |
1247 | break; |
||
1248 | //#endif |
||
224 | ligi | 1249 | |
1250 | |||
242 | ligi | 1251 | case STATEID_SELECT_COMPORT: |
224 | ligi | 1252 | case STATEID_PARAM_MENU: |
1253 | paint_menu(g); |
||
1254 | break; |
||
213 | ligi | 1255 | case STATEID_STRINGINPUT: |
206 | ligi | 1256 | case STATEID_ABOUT: |
1257 | case STATEID_IPINPUT: |
||
224 | ligi | 1258 | |
221 | ligi | 1259 | paint_lcd(g); |
206 | ligi | 1260 | break; |
1261 | |||
1262 | case STATEID_READ_PARAMS: |
||
221 | ligi | 1263 | paint_lcd(g); |
206 | ligi | 1264 | break; |
1265 | |||
1266 | |||
1267 | //#if bluetooth=="on" |
||
1268 | case STATEID_SCANNING: |
||
221 | ligi | 1269 | paint_lcd(g); |
206 | ligi | 1270 | break; |
1271 | //#endif |
||
1272 | case STATEID_RAWDEBUG: |
||
1273 | g.setFont(f2); |
||
1274 | rawdebug_off_y=0; |
||
1275 | if ((rawdebug_cursor_y+3)*spacer1>canvas_height) |
||
1276 | rawdebug_off_y=((rawdebug_cursor_y+3)*spacer1-canvas_height)/spacer1; |
||
1277 | for (int i=0;i<(canvas_height/spacer1)-1;i++) |
||
1278 | { |
||
1279 | if (i+rawdebug_off_y==rawdebug_cursor_y) |
||
1280 | { |
||
1281 | g.setColor(0x0000CC); |
||
1282 | g.fillRect(0,y_off,canvas_width,spacer1); |
||
1283 | |||
1284 | g.setColor(skin_fg_color()); |
||
1285 | |||
1286 | |||
1287 | } |
||
1288 | if (i+rawdebug_off_y<32) //todo better style |
||
1289 | g.drawString(mk.debug_data.names[i+rawdebug_off_y] + mk.debug_data.analog[i+rawdebug_off_y] ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1290 | |||
1291 | y_off+=spacer1; |
||
1292 | |||
1293 | } |
||
1294 | |||
1295 | |||
1296 | |||
1297 | break; |
||
1298 | |||
1299 | |||
1300 | case STATEID_CONN_DETAILS: |
||
1301 | g.setFont(f1); |
||
1302 | g.drawString("Connection::",0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1303 | y_off+=spacer; |
||
1304 | g.setFont(f2); |
||
1305 | |||
1306 | g.drawString(" URL:" + mk.mk_url,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1307 | y_off+=spacer1; |
||
1308 | |||
1309 | g.drawString(" Name:" + mk.name,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1310 | y_off+=spacer1; |
||
1311 | |||
1312 | 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); |
||
1313 | y_off+=spacer1; |
||
1314 | g.drawString(" Version:" + mk.version.str ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1315 | y_off+=spacer1; |
||
1316 | g.drawString(" Slave-Addr:" + mk.slave_addr,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1317 | |||
1318 | paint_menu(g); |
||
1319 | |||
1320 | break; |
||
1321 | |||
1322 | case STATEID_TRAFFIC: |
||
1323 | |||
1324 | g.setFont(f1); |
||
1325 | g.drawString("Packet Traffic (over "+mk.conn_time_in_s()+"s):",0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1326 | y_off+=spacer; |
||
1327 | g.setFont(f2); |
||
1328 | 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); |
||
1329 | y_off+=spacer1; |
||
1330 | |||
1331 | |||
1332 | |||
1333 | |||
1334 | 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); |
||
1335 | y_off+=spacer1; |
||
219 | ligi | 1336 | 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); |
206 | ligi | 1337 | y_off+=spacer1; |
1338 | g.drawString( " debug_names:" + mk.stats.debug_names_count + " angles:" + mk.stats.angle_data_count ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1339 | |||
245 | ligi | 1340 | y_off+=spacer1; |
219 | ligi | 1341 | g.drawString( " other:"+mk.stats.other_data_count,0,y_off,Graphics.TOP | Graphics.LEFT); |
1342 | |||
206 | ligi | 1343 | y_off+=spacer1+3; |
1344 | 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); |
||
1345 | y_off+=spacer1; |
||
1346 | g.drawString( " LCD:" + mk.stats.lcd_data_request_count + " vers:" + mk.stats.version_data_request_count,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1347 | y_off+=spacer1; |
||
219 | ligi | 1348 | g.drawString( " params:"+mk.stats.params_data_request_count +" rc:" + mk.stats.stick_data_request_count ,0,y_off,Graphics.TOP | Graphics.LEFT); |
206 | ligi | 1349 | y_off+=spacer1; |
1350 | |||
219 | ligi | 1351 | g.drawString( " resend:"+mk.stats.resend_count ,0,y_off,Graphics.TOP | Graphics.LEFT); |
1352 | y_off+=spacer1; |
||
1353 | |||
206 | ligi | 1354 | paint_menu(g); |
1355 | break; |
||
1356 | |||
1357 | case STATEID_PROXY: |
||
1358 | g.setFont(f1); |
||
1359 | g.drawString("Host:",0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1360 | y_off+=spacer; |
||
1361 | g.setFont(f2); |
||
1362 | g.drawString(" " + mk.proxy.url + "("+((mk.proxy.connected)?"open":"closed") +")",0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1363 | y_off+=spacer1; |
||
1364 | |||
1365 | |||
1366 | |||
1367 | break; |
||
1368 | |||
220 | ligi | 1369 | case STATEID_SETTINGSMENU: |
1370 | |||
1371 | settings_editor.paint(g); |
||
1372 | break; |
||
211 | ligi | 1373 | // falltru wanted |
220 | ligi | 1374 | // case STATEID_SELECT_SPEED_FORMAT: |
1375 | // case STATEID_SELECT_GPS_FORMAT: |
||
206 | ligi | 1376 | case STATEID_MAINMENU: |
1377 | |||
211 | ligi | 1378 | |
220 | ligi | 1379 | |
206 | ligi | 1380 | case STATEID_SELECT_PARAMSET: |
1381 | case STATEID_HANDLE_PARAMS: |
||
1382 | |||
1383 | case STATEID_DEVICESELECT: |
||
1384 | |||
1385 | paint_menu(g); |
||
1386 | break; |
||
1387 | |||
1388 | |||
1389 | case STATEID_GRAPH: |
||
1390 | |||
1391 | g.setClip(0,0,canvas_width,canvas_height); |
||
1392 | |||
1393 | g.setStrokeStyle(Graphics.DOTTED); |
||
1394 | g.setColor(0xe1dddd); |
||
229 | ligi | 1395 | g.setFont(f2); |
1396 | // LEGEND |
||
1397 | if (settings.graph_legend) for (int d=0;d<GRAPH_COUNT;d++) |
||
1398 | {/* |
||
206 | ligi | 1399 | g.setColor(graph_colors[d]); |
1400 | g.fillRect(0,y_off +spacer1/2-2 ,20,4); |
||
1401 | g.setColor(skin_fg_color()); |
||
229 | ligi | 1402 | g.drawString(graph_names[d] + mk.debug_data.analog[graph_sources[d]],23,y_off,Graphics.TOP | Graphics.LEFT); |
206 | ligi | 1403 | y_off+=spacer1; |
1404 | |||
229 | ligi | 1405 | */ |
1406 | g.setColor(graph_colors[d]); |
||
1407 | g.fillRect(canvas_width-20,canvas_height-spacer*(d+1)+(spacer)/2-2 ,20,4); |
||
1408 | g.setColor(skin_fg_color()); |
||
1409 | g.drawString(graph_names[d] /*+ mk.debug_data.analog[graph_sources[d]]*/,canvas_width-23,canvas_height-spacer*(d+1),Graphics.TOP | Graphics.RIGHT); |
||
1410 | // y_off+=spacer1; |
||
1411 | |||
206 | ligi | 1412 | } |
1413 | |||
229 | ligi | 1414 | if (settings.graph_scale) |
1415 | { |
||
1416 | |||
1417 | int scale=10; |
||
1418 | // if ((10/line_scaler)<5)scale =1; |
||
1419 | if (((10/line_scaler)*2)<(canvas_height/2) )scale =10; |
||
1420 | if (((50/line_scaler)*2)<(canvas_height/2) )scale =50; |
||
1421 | if (((100/line_scaler)*2)<(canvas_height/2) )scale =100; |
||
1422 | if (((250/line_scaler)*2)<(canvas_height/2) )scale =250; |
||
1423 | if (((500/line_scaler)*2)<(canvas_height/2) )scale =500; |
||
1424 | if (((1000/line_scaler)*2)<(canvas_height/2) )scale =1000; |
||
1425 | if (((10000/line_scaler)*2)<(canvas_height/2) )scale =10000; |
||
206 | ligi | 1426 | |
1427 | |||
1428 | |||
229 | ligi | 1429 | |
1430 | // g.drawString("scale:"+scale + "line scaler" + line_scaler,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1431 | |||
1432 | |||
1433 | int jump=0; |
||
1434 | |||
1435 | g.drawLine(0,line_middle_y,canvas_width,line_middle_y); |
||
1436 | |||
1437 | while ((jump/line_scaler)<graph_height) |
||
1438 | { |
||
1439 | |||
1440 | g.drawString(""+jump,0,line_middle_y - jump/line_scaler,Graphics.TOP | Graphics.LEFT); |
||
1441 | if (jump!=0)g.drawString("-"+jump,0,line_middle_y + jump/line_scaler,Graphics.TOP | Graphics.LEFT); |
||
1442 | g.drawLine(0,line_middle_y - jump/line_scaler,canvas_width,line_middle_y - jump/line_scaler); |
||
1443 | g.drawLine(0,line_middle_y + jump/line_scaler,canvas_width,line_middle_y + jump/line_scaler); |
||
1444 | jump+=scale; |
||
1445 | } |
||
206 | ligi | 1446 | } |
1447 | |||
1448 | |||
1449 | |||
1450 | for (int gr=0;gr<GRAPH_COUNT;gr++) |
||
1451 | { |
||
1452 | |||
223 | ligi | 1453 | |
1454 | // !!TODO checkme |
||
206 | ligi | 1455 | g.setColor(graph_colors[gr]); |
1456 | |||
223 | ligi | 1457 | graph_data[gr][-graph_offset]=check_local_max(mk.debug_data.analog[graph_sources[gr]]); |
1458 | |||
1459 | |||
206 | ligi | 1460 | |
229 | ligi | 1461 | line_scaler= local_max/graph_height+1; |
206 | ligi | 1462 | |
1463 | |||
1464 | for ( int x=0;x<canvas_width;x++) |
||
1465 | { |
||
221 | ligi | 1466 | int p= (((-graph_offset+x-canvas_width-5))); |
206 | ligi | 1467 | if (p<1) |
1468 | p+=graph_data[0].length; |
||
1469 | p%=(graph_data[0].length-1); |
||
1470 | |||
1471 | draw_graph_part(g,x,graph_data[gr][p]/line_scaler,graph_data[gr][p+1]/line_scaler); |
||
1472 | |||
1473 | } |
||
1474 | } |
||
1475 | |||
223 | ligi | 1476 | |
1477 | |||
206 | ligi | 1478 | break; |
1479 | |||
245 | ligi | 1480 | case STATEID_LCD: |
206 | ligi | 1481 | /* |
1482 | g.setClip(canvas_width/2-load_img.getWidth()/6+1,canvas_height/2-load_img.getHeight()/8+1, load_img.getWidth()/4,load_img.getHeight()/3);; |
||
1483 | if (( mk.LCD.init_state!=-1)||(mk.LCD.act_mk_page!=mk.LCD.act_user_page)) g.drawImage(load_img,canvas_width/2-load_img.getWidth()/8 - ((((frame_pos/3)%12)%4)*(load_img.getWidth()/4)) ,canvas_height/2-load_img.getHeight()/6- ((((frame_pos/3)%12)/4)*(load_img.getHeight()/3)), g.TOP | g.LEFT); |
||
1484 | |||
1485 | */ |
||
1486 | /* |
||
1487 | // !!TODO!! check exactly which version those Datas where introduced |
||
1488 | if (mk.version.compare(0,60)==mk.version.VERSION_PREVIOUS) |
||
1489 | { |
||
1490 | g.drawString("Voltage: " + (mk.debug_data.UBatt()/10) + "," +(mk.debug_data.UBatt()%10)+"V" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1491 | g.drawString("Sender: " + mk.debug_data.SenderOkay(),canvas_width/2,y_off,Graphics.TOP | Graphics.LEFT); |
||
1492 | y_off+=spacer; |
||
1493 | } |
||
1494 | |||
1495 | g.drawString(mk.version.str+"(d"+mk.debug_data_count+ "l" + mk.lcd_data_count+ "v" + mk.version_data_count+"o"+mk.other_data_count+"p"+mk.params_data_count+")",0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1496 | |||
1497 | y_off+=spacer; |
||
1498 | |||
1499 | g.drawString("n:"+mk.debug_data.nick_int() + " r:"+mk.debug_data.roll_int() + " an:"+mk.debug_data.accnick() + " ar:"+mk.debug_data.accroll() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1500 | y_off+=spacer; |
||
1501 | |||
1502 | |||
1503 | g.drawString("m1:"+mk.debug_data.motor_val(0) + " m2:"+mk.debug_data.motor_val(1)+" m3:"+mk.debug_data.motor_val(2) + " m4:"+mk.debug_data.motor_val(3) ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1504 | y_off+=spacer; |
||
1505 | |||
1506 | if (mk.connected) |
||
1507 | { |
||
1508 | g.drawString("time conn:" +((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1509 | y_off+=spacer; |
||
1510 | g.drawString("time motor>15:" +(mk_stat.motor_on_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1511 | y_off+=spacer; |
||
1512 | g.drawString("time motor=15:" +(mk_stat.motor_stand_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1513 | y_off+=spacer; |
||
1514 | g.drawString("lcd:" + mk.LCD.act_mk_page + "/" + mk.LCD.pages + " ( wanted: " + mk.LCD.act_user_page + "state:" + mk.LCD.init_state +")" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1515 | |||
1516 | y_off+=spacer; |
||
1517 | g.drawString("lcd-key:" + mk.LCD.act_key ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1518 | |||
1519 | } |
||
1520 | */ |
||
1521 | |||
1522 | int spacer_left_right=(canvas_width-(20*(lcd_img.getWidth()/222)))/2; |
||
1523 | |||
1524 | y_off=canvas_height-4*lcd_img.getHeight(); |
||
1525 | |||
1526 | for ( int foo=0;foo<4;foo++) |
||
1527 | { |
||
1528 | for (int x=0;x<20;x++) |
||
1529 | { |
||
1530 | g.setClip(spacer_left_right+(lcd_img.getWidth()/222)*x,y_off,(lcd_img.getWidth()/222),lcd_img.getHeight()); |
||
1531 | g.drawImage(lcd_img,spacer_left_right+(lcd_img.getWidth()/222)*x-(mk.LCD.get_act_page()[foo].charAt(x)-' ')*(lcd_img.getWidth()/222),y_off, g.TOP | g.LEFT); |
||
1532 | |||
1533 | } |
||
1534 | y_off+=lcd_img.getHeight(); |
||
1535 | } |
||
1536 | |||
1537 | g.setClip(0,0,canvas_width,canvas_height); |
||
1538 | |||
1539 | } |
||
1540 | |||
1541 | |||
1542 | |||
1543 | } catch (Exception e) {} |
||
1544 | |||
1545 | } |
||
1546 | Player mPlayer; |
||
1547 | VideoControl mVideoControl; |
||
1548 | Image cam_img; |
||
221 | ligi | 1549 | Image last_cam_img; |
206 | ligi | 1550 | int cam_img_seq=0; |
1551 | byte[] cam_raw; |
||
1552 | |||
1553 | private void connect_mk(String url,String name) |
||
1554 | { |
||
1555 | // mk.ufo_prober.bluetooth_probe(url); |
||
1556 | settings.connection_url=url; |
||
1557 | settings.connection_name=name; |
||
1558 | mk.connect_to(url,name); |
||
1559 | } |
||
1560 | |||
1561 | public void draw_graph_part(Graphics g,int x,int y1,int y2) |
||
1562 | { |
||
1563 | if ( canvas_width>200) |
||
1564 | { |
||
1565 | g.fillRect(x,line_middle_y-y1,1,1 ); |
||
1566 | if (y1>y2) |
||
1567 | g.fillRect(x,line_middle_y-y1,1,y1-y2); |
||
1568 | else |
||
1569 | g.fillRect(x,line_middle_y-y2,1,y2-y1); |
||
1570 | |||
1571 | } |
||
1572 | else |
||
1573 | { |
||
1574 | g.fillRect(x,line_middle_y-y1,1,1 ); |
||
1575 | if (y1>y2) |
||
1576 | g.fillRect(x,line_middle_y-y1,1,y1-y2); |
||
1577 | else |
||
1578 | g.fillRect(x,line_middle_y-y2,1,y2-y1); |
||
1579 | } |
||
1580 | |||
1581 | } |
||
1582 | |||
1583 | |||
1584 | /*********************************************** input Section **********************************************/ |
||
1585 | |||
1586 | |||
1587 | |||
1588 | // public final String intro_str=" Digital Ufo Broadcasting with intelligent service equipment by Marcus -LiGi- Bueschleb ; Big Up Holger&Ingo for the MikroKopter Project (http://www.mikrokopter.de) "; |
||
1589 | |||
1590 | // int intro_str_pos=0; |
||
1591 | // int intro_str_delay=3; |
||
219 | ligi | 1592 | // boolean init_bootloader=false; |
224 | ligi | 1593 | String success_msg=""; |
206 | ligi | 1594 | |
1595 | public void chg_state(byte next_state) |
||
1596 | { |
||
220 | ligi | 1597 | settings_editor = null; |
1598 | params_editor = null; |
||
223 | ligi | 1599 | err_img=null; |
221 | ligi | 1600 | graph_data=null; |
220 | ligi | 1601 | |
223 | ligi | 1602 | act_menu_select_bak[state]=act_menu_select; |
1603 | act_menu_select=act_menu_select_bak[next_state]; |
||
229 | ligi | 1604 | |
1605 | |||
1606 | /* |
||
1607 | // tasks on state exit |
||
1608 | switch(next_state) |
||
1609 | { |
||
1610 | case STATEID_SETTINGSMENU: |
||
1611 | |||
1612 | break; |
||
1613 | } |
||
1614 | */ |
||
206 | ligi | 1615 | // prepare next state |
1616 | switch(next_state) |
||
242 | ligi | 1617 | |
206 | ligi | 1618 | { |
242 | ligi | 1619 | // case STATEID_COPY_PARAMS: |
1620 | |||
1621 | //break; |
||
224 | ligi | 1622 | case STATEID_SUCCESS_MSG: |
1623 | case STATEID_ERROR_MSG: |
||
221 | ligi | 1624 | lcd_lines=new String[1]; |
224 | ligi | 1625 | |
1626 | lcd_lines[0]=""+((next_state==STATEID_SUCCESS_MSG)?success_msg:mk.error_str); |
||
221 | ligi | 1627 | try |
1628 | { |
||
1629 | err_img=Image.createImage("/preflight.jpg"); |
||
1630 | } |
||
1631 | catch (Exception e) |
||
1632 | { |
||
1633 | debug.log("problem loading error image"); |
||
1634 | } |
||
1635 | |||
1636 | break; |
||
220 | ligi | 1637 | case STATEID_EDIT_PARAMS: |
1638 | params_editor = new MKParamsEditor(this,mk.params,STATEID_HANDLE_PARAMS); |
||
1639 | break; |
||
213 | ligi | 1640 | case STATEID_STRINGINPUT: |
1641 | lcd_lines=new String[2]; |
||
1642 | lcd_lines[0]=act_input_str; |
||
1643 | lcd_lines[1]="^"; |
||
1644 | |||
1645 | break; |
||
245 | ligi | 1646 | case STATEID_LCD: |
206 | ligi | 1647 | mk.user_intent=USER_INTENT_LCD; |
1648 | break; |
||
224 | ligi | 1649 | case STATEID_RESET_PARAMS: |
1650 | |||
1651 | mk.bootloader_intension_flash=false; |
||
1652 | mk.bl_retrys=0; |
||
1653 | mk.init_bootloader=true; |
||
1654 | break; |
||
1655 | |||
206 | ligi | 1656 | case STATEID_FLASHING: |
1657 | mk.bootloader_intension_flash=true; |
||
219 | ligi | 1658 | mk.bl_retrys=0; |
1659 | mk.init_bootloader=true; |
||
206 | ligi | 1660 | break; |
1661 | |||
1662 | //#if fileapi=="on" |
||
1663 | case STATEID_FILEOPEN: |
||
221 | ligi | 1664 | file_access.trigger(); |
206 | ligi | 1665 | break; |
1666 | //#endif |
||
1667 | |||
1668 | case STATEID_STICKVIEW: |
||
1669 | mk.user_intent=USER_INTENT_RCDATA; |
||
1670 | break; |
||
1671 | case STATEID_SELECT_COMPORT: |
||
242 | ligi | 1672 | menu_items=DUBwiseHelper.split_str(System.getProperty("microedition.commports")+",back",","); |
1673 | setup_menu(menu_items,null); |
||
206 | ligi | 1674 | break; |
1675 | |||
1676 | |||
1677 | case STATEID_ABOUT: |
||
1678 | lcd_lines=credits; |
||
213 | ligi | 1679 | lcd_lines[1]=" ufo-lib: " + mk.lib_version_str(); |
206 | ligi | 1680 | act_menu_select=max_lines-1; |
1681 | break; |
||
1682 | case STATEID_CONN_DETAILS: |
||
242 | ligi | 1683 | setup_conn_menu();//conn_details_menu_items,conn_details_menu_actions); |
206 | ligi | 1684 | break; |
224 | ligi | 1685 | |
1686 | |||
1687 | case STATEID_PARAM_MENU: |
||
1688 | setup_menu(param_menu_items,param_menu_actions); |
||
1689 | break; |
||
206 | ligi | 1690 | case STATEID_TRAFFIC: |
1691 | setup_menu(onlyback_menu_items,back_to_conndetails_actions); |
||
1692 | break; |
||
1693 | case STATEID_CAMMODE: |
||
221 | ligi | 1694 | mk.user_intent=USER_INTENT_RCDATA; |
206 | ligi | 1695 | if (mVideoControl==null) |
1696 | try |
||
1697 | { |
||
1698 | debug.log("creating player\n"); |
||
1699 | mPlayer = Manager.createPlayer("capture://video?encoding=png&width=2048&height=1536"); |
||
1700 | |||
1701 | debug.log("realizing player\n"); |
||
1702 | mPlayer.realize(); |
||
1703 | |||
1704 | debug.log("get_videocontrol\n"); |
||
1705 | |||
1706 | mVideoControl = (VideoControl)mPlayer.getControl("VideoControl"); |
||
1707 | |||
1708 | debug.log("switching Canvas\n"); |
||
1709 | mVideoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this); |
||
1710 | |||
1711 | debug.log("get snap\n"); |
||
1712 | byte[] raw = mVideoControl.getSnapshot(null); |
||
1713 | |||
1714 | } |
||
1715 | catch ( Exception e) |
||
1716 | { |
||
1717 | debug.log(e.toString()); |
||
1718 | } |
||
1719 | |||
1720 | |||
1721 | break; |
||
1722 | case STATEID_KEYCONTROL: |
||
219 | ligi | 1723 | mk.user_intent= USER_INTENT_EXTERNAL_CONTROL; |
206 | ligi | 1724 | keycontrol_exit=0; |
1725 | break; |
||
1726 | |||
233 | ligi | 1727 | |
1728 | |||
206 | ligi | 1729 | case STATEID_READ_PARAMS: |
1730 | mk.user_intent=USER_INTENT_PARAMS; |
||
1731 | lcd_lines=new String[2]; |
||
1732 | lcd_lines[0]="Reading Settings "; |
||
1733 | lcd_lines[1]=mk.watchdog.act_paramset+"/5 |"+ (mk.watchdog.act_paramset>0?"#":"_") + (mk.watchdog.act_paramset>1?"#":"_") + (mk.watchdog.act_paramset>2?"#":"_")+ (mk.watchdog.act_paramset>3?"#":"_")+ (mk.watchdog.act_paramset>4?"#":"_") + "| "; |
||
1734 | |||
1735 | break; |
||
1736 | |||
1737 | case STATEID_IPINPUT: |
||
1738 | |||
1739 | lcd_lines=new String[3]; |
||
1740 | lcd_lines[0]="Address (IP:Port): "; |
||
1741 | break; |
||
1742 | |||
1743 | //#if bluetooth=="on" |
||
1744 | case STATEID_SCANNING: |
||
1745 | lcd_lines=new String[3]; |
||
1746 | lcd_lines[0]="Searching for"; |
||
1747 | lcd_lines[1]="Bluetooth Devices"; |
||
1748 | lcd_lines[2]="found"; |
||
1749 | |||
1750 | mk.close_connections(true); |
||
1751 | bt_scanner.search(); |
||
1752 | break; |
||
1753 | //#endif |
||
1754 | |||
1755 | case STATEID_HANDLE_PARAMS: |
||
1756 | menu_items=handle_params_menu_items; |
||
1757 | menu_actions=handle_params_menu_actions; |
||
1758 | lcd_lines=new String[menu_items.length]; |
||
1759 | |||
1760 | break; |
||
1761 | |||
1762 | case STATEID_SELECT_PARAMSET: |
||
224 | ligi | 1763 | menu_items=new String[6]; |
206 | ligi | 1764 | for (int i=0;i<5;i++) |
223 | ligi | 1765 | menu_items[i]=""+(i+1)+": " + mk.params.getParamName(i) + ((i==mk.params.active_paramset)?"*":""); |
206 | ligi | 1766 | |
224 | ligi | 1767 | menu_items[5]="back"; |
1768 | lcd_lines=new String[6]; |
||
206 | ligi | 1769 | break; |
1770 | |||
1771 | //#if bluetooth=="on" |
||
1772 | case STATEID_DEVICESELECT: |
||
1773 | |||
1774 | menu_items=new String[bt_scanner.remote_device_count+2]; |
||
1775 | lcd_lines=new String[bt_scanner.remote_device_count+2]; |
||
1776 | |||
1777 | for (int i=0;i<bt_scanner.remote_device_count;i++) |
||
1778 | menu_items[i]=bt_scanner.remote_device_name[i]; |
||
1779 | menu_items[bt_scanner.remote_device_count]="scan again"; |
||
1780 | menu_items[bt_scanner.remote_device_count+1]="cancel"; |
||
1781 | |||
1782 | break; |
||
1783 | //#endif |
||
1784 | |||
1785 | case STATEID_MAINMENU: |
||
214 | ligi | 1786 | setup_main_menu(); |
1787 | |||
206 | ligi | 1788 | break; |
1789 | |||
1790 | case STATEID_SETTINGSMENU: |
||
220 | ligi | 1791 | settings_editor = new MKParamsEditor(this,settings,STATEID_MAINMENU); |
1792 | /* |
||
206 | ligi | 1793 | menu_items=new String[settings_menu_items.length]; |
1794 | for(int cnt=0;cnt<settings_menu_items.length;cnt++) |
||
1795 | menu_items[cnt]=settings_menu_items[cnt]; |
||
1796 | |||
1797 | menu_items[0]+=(settings.act_skin==SKINID_DARK)?"Dark":"Light"; |
||
1798 | menu_items[1]+=(!settings.do_sound)?"Off":"On"; |
||
1799 | menu_items[2]+=(!settings.do_vibra)?"Off":"On"; |
||
1800 | menu_items[3]+=(!settings.do_scrollbg)?"Off":"On"; |
||
1801 | menu_items[4]+=(!settings.fullscreen)?"Off":"On"; |
||
211 | ligi | 1802 | menu_items[5]+=(mk.gps_position.act_gps_format==0)?" Decimal":" MinSec"; |
1803 | menu_items[6]+=(mk.gps_position.act_speed_format==0)?" KM/H":((mk.gps_position.act_speed_format==1)?" MP/H":"CM/S"); |
||
206 | ligi | 1804 | |
1805 | //#if devicecontrol=="on" |
||
211 | ligi | 1806 | menu_items[7]+=(!settings.keep_lighton)?"Off":"On"; |
206 | ligi | 1807 | //#endif |
214 | ligi | 1808 | menu_items[8]+=(!settings.expert_mode)?" Off":" On"; |
206 | ligi | 1809 | menu_actions=settings_menu_actions; |
220 | ligi | 1810 | lcd_lines=new String[menu_items.length];*/ |
206 | ligi | 1811 | break; |
1812 | |||
1813 | case STATEID_RAWDEBUG: |
||
1814 | mk.user_intent=USER_INTENT_RAWDEBUG; |
||
1815 | break; |
||
1816 | |||
1817 | |||
1818 | case STATEID_GRAPH: |
||
221 | ligi | 1819 | graph_data=new int[GRAPH_COUNT][this.getWidth()*2]; |
1820 | |||
1821 | for (int c=0;c<graph_data[0].length;c++) |
||
1822 | for (int d=0;d<GRAPH_COUNT;d++) |
||
1823 | graph_data[d][c]=-1; |
||
1824 | |||
1825 | |||
206 | ligi | 1826 | mk.user_intent=USER_INTENT_GRAPH; |
223 | ligi | 1827 | local_max=1; |
206 | ligi | 1828 | break; |
1829 | |||
1830 | } |
||
1831 | mk.watchdog.resend_timeout=0; |
||
1832 | |||
1833 | // switch state |
||
1834 | state=next_state; |
||
1835 | } // void chg_state |
||
1836 | |||
1837 | |||
1838 | public void keyReleased(int keyCode) |
||
1839 | { |
||
1840 | |||
1841 | switch(state) |
||
1842 | { |
||
1843 | case STATEID_MOTORTEST: |
||
1844 | act_motor_increase=0; |
||
1845 | break; |
||
1846 | |||
1847 | case STATEID_KEYCONTROL: |
||
1848 | if (keyCode==KEY_POUND) |
||
1849 | keycontrol_exit &= 255^1; |
||
1850 | else |
||
1851 | if (keyCode==KEY_STAR) |
||
1852 | keycontrol_exit &= 255^2; |
||
1853 | else |
||
219 | ligi | 1854 | mod_external_control_by_keycode(keyCode,(byte)0); |
206 | ligi | 1855 | |
219 | ligi | 1856 | /* |
206 | ligi | 1857 | mk.send_keys(keycontrol_bitfield); |
219 | ligi | 1858 | */ |
206 | ligi | 1859 | break; |
1860 | } |
||
1861 | |||
1862 | } |
||
1863 | |||
1864 | |||
219 | ligi | 1865 | public void mod_external_control_by_keycode(int keyCode,byte mul) |
1866 | { |
||
1867 | |||
1868 | if (keyCode==this.KEY_NUM2) |
||
1869 | mk.extern_control[EXTERN_CONTROL_GIER]=(byte)(-mul*settings.default_extern_control[EXTERN_CONTROL_GIER]); |
||
1870 | else if (keyCode==this.KEY_NUM3) |
||
1871 | mk.extern_control[EXTERN_CONTROL_GIER]=(byte)(mul*settings.default_extern_control[EXTERN_CONTROL_GIER]); |
||
1872 | |||
1873 | else if (keyCode==this.KEY_NUM1) |
||
220 | ligi | 1874 | mk.extern_control[EXTERN_CONTROL_HIGHT]+=mul*settings.default_extern_control[EXTERN_CONTROL_HIGHT]; |
219 | ligi | 1875 | else if (keyCode==this.KEY_NUM4) |
220 | ligi | 1876 | mk.extern_control[EXTERN_CONTROL_HIGHT]-=mul*settings.default_extern_control[EXTERN_CONTROL_HIGHT]; |
219 | ligi | 1877 | |
1878 | |||
1879 | else if (keyCode==this.KEY_NUM6) |
||
220 | ligi | 1880 | { if ( mk.extern_control[EXTERN_CONTROL_GAS]<255) mk.extern_control[EXTERN_CONTROL_GAS]+=mul*settings.default_extern_control[EXTERN_CONTROL_GAS]; } |
219 | ligi | 1881 | else if (keyCode==this.KEY_NUM9) |
220 | ligi | 1882 | { if ( mk.extern_control[EXTERN_CONTROL_GAS]>0) mk.extern_control[EXTERN_CONTROL_GAS]-=mul*settings.default_extern_control[EXTERN_CONTROL_GAS]; } |
219 | ligi | 1883 | |
1884 | else switch (getGameAction (keyCode)) |
||
1885 | { |
||
1886 | case UP: |
||
1887 | mk.extern_control[EXTERN_CONTROL_NICK]=(byte)(mul*settings.default_extern_control[EXTERN_CONTROL_NICK]); |
||
1888 | break; |
||
1889 | |||
1890 | case DOWN: |
||
1891 | mk.extern_control[EXTERN_CONTROL_NICK]=(byte)(-mul*settings.default_extern_control[EXTERN_CONTROL_NICK]); |
||
1892 | |||
1893 | break; |
||
1894 | |||
1895 | |||
1896 | case LEFT: |
||
1897 | mk.extern_control[EXTERN_CONTROL_ROLL]=(byte)(mul*settings.default_extern_control[EXTERN_CONTROL_ROLL]); |
||
1898 | break; |
||
1899 | |||
1900 | case RIGHT: |
||
1901 | mk.extern_control[EXTERN_CONTROL_ROLL]=(byte)(-mul*settings.default_extern_control[EXTERN_CONTROL_ROLL]); |
||
1902 | break; |
||
1903 | |||
1904 | case FIRE: |
||
1905 | |||
1906 | break; |
||
1907 | |||
1908 | |||
1909 | } |
||
1910 | |||
1911 | } |
||
1912 | |||
242 | ligi | 1913 | |
206 | ligi | 1914 | |
242 | ligi | 1915 | public final static String PARAM_SAVE_STORE_NAME="MKParamsV1"; |
206 | ligi | 1916 | |
242 | ligi | 1917 | public void process_action(byte actionid) |
1918 | { |
||
1919 | switch(actionid) |
||
1920 | { |
||
1921 | case ACTIONID_PARAM_LOAD_MOBILE: |
||
1922 | try |
||
1923 | { |
||
1924 | RecordStore recStore = RecordStore.openRecordStore(PARAM_SAVE_STORE_NAME , true ); |
||
1925 | |||
1926 | if (recStore.getNumRecords()==1) |
||
1927 | { |
||
1928 | ByteArrayInputStream bin = new ByteArrayInputStream(recStore.getRecord(1)); |
||
1929 | DataInputStream din = new DataInputStream( bin ); |
||
1930 | } |
||
1931 | else throw(new Exception("rms err")); |
||
1932 | recStore.closeRecordStore(); |
||
1933 | } |
||
1934 | catch (Exception e) |
||
1935 | { |
||
1936 | mk.error_str="No Params on Mobile"; |
||
1937 | chg_state(STATEID_ERROR_MSG); |
||
1938 | } |
||
206 | ligi | 1939 | |
242 | ligi | 1940 | |
1941 | break; |
||
1942 | |||
1943 | case ACTIONID_PARAM_COPY_MOBILE: |
||
1944 | read_paramset_intension_save=true; |
||
1945 | chg_state(STATEID_READ_PARAMS); |
||
1946 | break; |
||
1947 | |||
1948 | case ACTIONID_PARAM_MENU: |
||
1949 | chg_state(STATEID_PARAM_MENU); |
||
1950 | break; |
||
1951 | |||
1952 | case ACTIONID_PARAM_WRITE_OK: |
||
1953 | success_msg="Parameter Write OK"; |
||
1954 | chg_state(STATEID_SUCCESS_MSG); |
||
1955 | break; |
||
1956 | case ACTIONID_HORIZON: |
||
1957 | chg_state(STATEID_HORIZON); |
||
1958 | break; |
||
1959 | |||
1960 | case ACTIONID_RENAME_PARAMS: |
||
1961 | act_input_str=mk.params.getParamName(mk.params.act_paramset); |
||
1962 | ipinput_pos=0; |
||
1963 | chg_state(STATEID_STRINGINPUT); |
||
1964 | break; |
||
1965 | |||
1966 | |||
1967 | case ACTIONID_BACK_TO_CONNDETAILS: |
||
1968 | chg_state(STATEID_CONN_DETAILS); |
||
1969 | break; |
||
1970 | |||
1971 | case ACTIONID_RESET_PARAMS: |
||
1972 | chg_state(STATEID_RESET_PARAMS); |
||
1973 | // state=STATEID_FLASHING; |
||
1974 | |||
1975 | break; |
||
1976 | |||
1977 | case ACTIONID_FLASH: |
||
1978 | chg_state(STATEID_FLASHING); |
||
1979 | break; |
||
1980 | |||
1981 | case ACTIONID_DATABUFF: |
||
1982 | chg_state(STATEID_DATABUFF); |
||
1983 | break; |
||
1984 | |||
1985 | case ACTIONID_NC_ERRORS: |
||
1986 | chg_state(STATEID_ERROR_MSG); |
||
1987 | break; |
||
1988 | |||
1989 | case ACTIONID_ABOUT: |
||
1990 | chg_state(STATEID_ABOUT); |
||
1991 | break; |
||
1992 | |||
1993 | case ACTIONID_CONN_DETAILS: |
||
1994 | chg_state(STATEID_CONN_DETAILS); |
||
1995 | break; |
||
1996 | |||
1997 | case ACTIONID_QUIT: |
||
1998 | quit=true; |
||
1999 | break; |
||
2000 | |||
2001 | case ACTIONID_SWITCH_NC: |
||
2002 | mk.switch_to_navi(); |
||
2003 | break; |
||
2004 | |||
2005 | case ACTIONID_SWITCH_FC: |
||
2006 | mk.switch_to_fc(); |
||
2007 | break; |
||
2008 | |||
2009 | case ACTIONID_SWITCH_MK3MAG: |
||
2010 | mk.switch_to_mk3mag(); |
||
2011 | break; |
||
2012 | |||
2013 | case ACTIONID_GRAPH: |
||
2014 | chg_state(STATEID_GRAPH); |
||
2015 | break; |
||
2016 | |||
2017 | case ACTIONID_KEYCONTROL: |
||
2018 | chg_state(STATEID_KEYCONTROL); |
||
2019 | break; |
||
2020 | |||
2021 | case ACTIONID_LCD : |
||
245 | ligi | 2022 | chg_state(STATEID_LCD); |
242 | ligi | 2023 | break; |
2024 | |||
2025 | |||
2026 | case ACTIONID_PROXY: |
||
2027 | |||
2028 | chg_state(STATEID_IPINPUT); |
||
2029 | break; |
||
2030 | |||
2031 | case ACTIONID_DEVICESELECT: |
||
2032 | chg_state(STATEID_SCANNING); |
||
2033 | break; |
||
2034 | |||
2035 | case ACTIONID_RAWDEBUG: |
||
2036 | chg_state(STATEID_RAWDEBUG); |
||
2037 | break; |
||
2038 | |||
2039 | case ACTIONID_SETTINGS: |
||
2040 | chg_state(STATEID_SETTINGSMENU); |
||
2041 | break; |
||
2042 | |||
2043 | case ACTIONID_RCDATA: |
||
2044 | chg_state(STATEID_STICKVIEW); |
||
2045 | break; |
||
2046 | |||
2047 | case ACTIONID_CAM: |
||
2048 | chg_state(STATEID_CAMMODE); |
||
2049 | break; |
||
2050 | |||
2051 | case ACTIONID_GPSDATA: |
||
2052 | chg_state(STATEID_GPSVIEW); |
||
2053 | break; |
||
2054 | |||
2055 | |||
2056 | case ACTIONID_MOTORTEST : |
||
2057 | chg_state(STATEID_MOTORTEST); |
||
2058 | break; |
||
2059 | |||
2060 | |||
2061 | case ACTIONID_EDIT_PARAMS: |
||
2062 | chg_state(STATEID_EDIT_PARAMS); |
||
2063 | break; |
||
2064 | case ACTIONID_SELECT_PARAMS: |
||
2065 | select_paramset4edit=true; |
||
2066 | read_paramset_intension_save=false; |
||
2067 | if (settings.reload_settings) |
||
2068 | { |
||
2069 | |||
2070 | mk.watchdog.act_paramset=0; |
||
2071 | mk.params.reset(); |
||
2072 | |||
2073 | chg_state(STATEID_READ_PARAMS); |
||
2074 | } |
||
2075 | else |
||
2076 | { |
||
2077 | if (mk.watchdog.act_paramset!=5) |
||
2078 | chg_state(STATEID_READ_PARAMS); |
||
2079 | else |
||
2080 | chg_state(STATEID_SELECT_PARAMSET); |
||
2081 | } |
||
2082 | break; |
||
2083 | |||
2084 | |||
2085 | case ACTIONID_WRITE_PARAM_AS: |
||
2086 | select_paramset4edit=false; |
||
2087 | chg_state(STATEID_SELECT_PARAMSET); |
||
2088 | break; |
||
2089 | |||
2090 | case ACTIONID_WRITE_PARAMS: |
||
2091 | mk.write_params(mk.params.act_paramset); |
||
2092 | success_msg="Saved Settings"; // too optimistic |
||
2093 | nextstate=STATEID_HANDLE_PARAMS; |
||
2094 | chg_state(STATEID_SUCCESS_MSG); |
||
2095 | break; |
||
2096 | |||
2097 | case ACTIONID_UNDO_PARAMS: |
||
2098 | mk.params.use_backup(); |
||
2099 | success_msg="Settings Undo OK"; // too optimistic |
||
2100 | nextstate=STATEID_HANDLE_PARAMS; |
||
2101 | chg_state(STATEID_SUCCESS_MSG); |
||
2102 | |||
2103 | break; |
||
2104 | |||
2105 | case ACTIONID_MAINMENU: |
||
2106 | chg_state(STATEID_MAINMENU); |
||
2107 | break; |
||
2108 | |||
2109 | case ACTIONID_DEBUG: |
||
2110 | debug.showing=true; |
||
2111 | break; |
||
2112 | |||
2113 | case ACTIONID_TRAFFIC: |
||
2114 | chg_state(STATEID_TRAFFIC); |
||
2115 | break; |
||
2116 | |||
2117 | case ACTIONID_CONNECT_TCP: |
||
2118 | ipinput4proxy=false; |
||
2119 | chg_state(STATEID_IPINPUT); |
||
2120 | break; |
||
2121 | |||
2122 | case ACTIONID_SCAN_BT: |
||
2123 | chg_state(STATEID_SCANNING); |
||
2124 | break; |
||
2125 | |||
2126 | case ACTIONID_SELECT_COM: |
||
2127 | chg_state(STATEID_SELECT_COMPORT); |
||
2128 | break; |
||
2129 | |||
2130 | case ACTIONID_PROXY_INPUT: |
||
2131 | ipinput4proxy=true; |
||
2132 | chg_state(STATEID_IPINPUT); |
||
2133 | break; |
||
2134 | |||
2135 | } |
||
2136 | |||
2137 | } |
||
2138 | |||
2139 | |||
206 | ligi | 2140 | public void pointerPressed (int pointer_x, int pointer_y) |
2141 | { |
||
242 | ligi | 2142 | |
206 | ligi | 2143 | if (pointer_y<lcd_img.getHeight()) |
2144 | keyPressed(KEY_STAR); |
||
2145 | else |
||
242 | ligi | 2146 | if (pointer_y>canvas_height-lcd_img.getHeight()*lcd_lines.length) |
2147 | switch(state) |
||
206 | ligi | 2148 | { |
242 | ligi | 2149 | case STATEID_SETTINGSMENU: |
2150 | |||
2151 | settings_editor.pointer_press(pointer_x,(pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight()) ; |
||
2152 | break; |
||
2153 | |||
2154 | case STATEID_EDIT_PARAMS: |
||
2155 | params_editor.pointer_press(pointer_x,(pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight()) ; |
||
2156 | |||
2157 | break; |
||
2158 | |||
245 | ligi | 2159 | case STATEID_LCD: |
2160 | if (pointer_x<(canvas_width/2)) |
||
2161 | keyPressed(getKeyCode(LEFT)); |
||
2162 | else |
||
2163 | keyPressed(getKeyCode(RIGHT)); |
||
2164 | break; |
||
242 | ligi | 2165 | case STATEID_PARAM_MENU: |
206 | ligi | 2166 | case STATEID_CONN_DETAILS: |
242 | ligi | 2167 | case STATEID_HANDLE_PARAMS: |
206 | ligi | 2168 | case STATEID_FILEOPEN: |
2169 | case STATEID_TRAFFIC: |
||
2170 | case STATEID_SELECT_COMPORT: |
||
2171 | case STATEID_MAINMENU: |
||
2172 | case STATEID_SELECT_PARAMSET: |
||
2173 | case STATEID_DEVICESELECT: |
||
2174 | |||
242 | ligi | 2175 | |
2176 | // if (pointer_y>canvas_height-lcd_img.getHeight()*menu_items.length) |
||
2177 | // { |
||
2178 | if (lcd_lines.length>max_lines) |
||
245 | ligi | 2179 | act_menu_select=(pointer_y-(canvas_height-lcd_img.getHeight()*max_lines))/lcd_img.getHeight() +lcd_off ; |
242 | ligi | 2180 | else |
2181 | act_menu_select=(pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight() ; |
||
2182 | keyPressed(getKeyCode(FIRE)); |
||
2183 | //} |
||
206 | ligi | 2184 | break; |
242 | ligi | 2185 | } |
2186 | |||
206 | ligi | 2187 | } |
213 | ligi | 2188 | |
2189 | |||
2190 | int last_keycode=-1; |
||
2191 | int repeat_keycode=0; |
||
2192 | |||
206 | ligi | 2193 | public void keyPressed(int keyCode) |
2194 | { |
||
213 | ligi | 2195 | if (last_keycode==keyCode) |
2196 | repeat_keycode++; |
||
2197 | else |
||
2198 | { |
||
2199 | repeat_keycode=0; |
||
2200 | last_keycode=keyCode; |
||
2201 | } |
||
2202 | |||
206 | ligi | 2203 | debug.log("KeyCode:"+keyCode); |
2204 | // key-actions common in all states |
||
2205 | debug.process_key(keyCode); |
||
2206 | |||
213 | ligi | 2207 | |
229 | ligi | 2208 | if (((keyCode==KEY_STAR) || (keyCode==settings.key_back) )&&(state!=STATEID_KEYCONTROL))//&&(state!= STATEID_STRINGINPUT)) |
206 | ligi | 2209 | { |
229 | ligi | 2210 | chg_state(STATEID_MAINMENU); |
2211 | return; |
||
206 | ligi | 2212 | } |
213 | ligi | 2213 | |
2214 | |||
221 | ligi | 2215 | if (((keyCode==KEY_POUND)||(keyCode==settings.key_fullscreen))&&(state!=STATEID_KEYCONTROL)) |
206 | ligi | 2216 | { |
220 | ligi | 2217 | settings.toggle_fullscreen(); |
2218 | |||
206 | ligi | 2219 | return; |
2220 | } |
||
2221 | |||
2222 | // key actions per state |
||
2223 | switch(state) |
||
2224 | { |
||
2225 | |||
224 | ligi | 2226 | case STATEID_SUCCESS_MSG: |
2227 | chg_state(nextstate); |
||
2228 | break; |
||
2229 | case STATEID_ERROR_MSG: |
||
206 | ligi | 2230 | chg_state(STATEID_MAINMENU); |
2231 | break; |
||
213 | ligi | 2232 | case STATEID_STRINGINPUT: |
2233 | if ((keyCode>=KEY_NUM2)&&(keyCode<=KEY_NUM9)) |
||
2234 | { |
||
2235 | act_input_str=act_input_str.substring(0,ipinput_pos) + |
||
2236 | |||
2237 | |||
2238 | (char)( 97 + (keyCode-KEY_NUM2)*3 + ((keyCode>KEY_NUM7)?1:0) +(repeat_keycode%(((keyCode==KEY_NUM7)||(keyCode==KEY_NUM9))?4:3))) |
||
2239 | |||
2240 | + act_input_str.substring(ipinput_pos+1,act_input_str.length()); |
||
2241 | } |
||
2242 | else if ((keyCode==KEY_NUM0)) |
||
2243 | { |
||
2244 | act_input_str=act_input_str.substring(0,ipinput_pos) + |
||
2245 | act_input_str.substring(ipinput_pos+1,act_input_str.length()); |
||
2246 | } |
||
2247 | else |
||
2248 | { |
||
2249 | switch (getGameAction (keyCode)) |
||
2250 | { |
||
2251 | |||
2252 | case LEFT: |
||
2253 | if(ipinput_pos>0) ipinput_pos--; |
||
2254 | break; |
||
2255 | |||
2256 | case RIGHT: |
||
2257 | if(ipinput_pos<19) ipinput_pos++; |
||
2258 | break; |
||
2259 | |||
2260 | case UP: |
||
2261 | act_input_str=act_input_str.substring(0,ipinput_pos) + |
||
2262 | (char)((byte) act_input_str.charAt(ipinput_pos)-1) + act_input_str.substring(ipinput_pos+1,act_input_str.length()); |
||
2263 | |||
2264 | break; |
||
2265 | case DOWN: |
||
2266 | act_input_str=act_input_str.substring(0,ipinput_pos) + |
||
2267 | (char)((byte) act_input_str.charAt(ipinput_pos)+1) + act_input_str.substring(ipinput_pos+1,act_input_str.length()); |
||
2268 | |||
2269 | break; |
||
2270 | |||
2271 | |||
2272 | case FIRE: |
||
2273 | mk.params.set_name(act_input_str); |
||
2274 | chg_state(STATEID_HANDLE_PARAMS); |
||
2275 | break; |
||
2276 | } |
||
2277 | |||
2278 | } |
||
2279 | if (act_input_str.length()<=ipinput_pos) act_input_str+=" "; |
||
2280 | break; |
||
206 | ligi | 2281 | case STATEID_IPINPUT: |
2282 | if ((keyCode>=KEY_NUM0)&&(keyCode<=KEY_NUM9)) |
||
2283 | { |
||
223 | ligi | 2284 | act_edit_ip[ipinput_pos/4]=DUBwiseHelper.mod_decimal(act_edit_ip[ipinput_pos/4],(ipinput_pos<15?2:3)-(ipinput_pos%4),0,(keyCode-KEY_NUM0),9); |
206 | ligi | 2285 | |
2286 | if(ipinput_pos<19) ipinput_pos++; |
||
2287 | if ((ipinput_pos<18)&&(((ipinput_pos+1)%4)==0))ipinput_pos++; |
||
2288 | } |
||
2289 | else |
||
2290 | switch (getGameAction (keyCode)) |
||
2291 | { |
||
2292 | case LEFT: |
||
2293 | if(ipinput_pos>0) ipinput_pos--; |
||
2294 | if (((ipinput_pos+1)%4)==0)ipinput_pos--; |
||
2295 | break; |
||
2296 | |||
2297 | case RIGHT: |
||
2298 | if(ipinput_pos<19) ipinput_pos++; |
||
2299 | if(ipinput_pos<18)if (((ipinput_pos+1)%4)==0)ipinput_pos++; |
||
2300 | break; |
||
2301 | |||
2302 | case UP: |
||
223 | ligi | 2303 | act_edit_ip[ipinput_pos/4]=DUBwiseHelper.mod_decimal(act_edit_ip[ipinput_pos/4],(ipinput_pos<15?2:3)-(ipinput_pos%4),1,-1,9); |
206 | ligi | 2304 | |
2305 | break; |
||
2306 | |||
2307 | case DOWN: |
||
223 | ligi | 2308 | act_edit_ip[ipinput_pos/4]=DUBwiseHelper.mod_decimal(act_edit_ip[ipinput_pos/4],(ipinput_pos<15?2:3)-(ipinput_pos%4),-1,-1,9); |
206 | ligi | 2309 | |
2310 | |||
2311 | case FIRE: |
||
2312 | if (ipinput4proxy) |
||
2313 | { |
||
2314 | settings.act_proxy_ip=act_edit_ip; |
||
223 | ligi | 2315 | mk.do_proxy("socket://"+DUBwiseHelper.ip_str(settings.act_proxy_ip,false)); |
206 | ligi | 2316 | chg_state(STATEID_PROXY); |
2317 | } |
||
2318 | else |
||
2319 | { |
||
2320 | settings.act_conn_ip=act_edit_ip; |
||
223 | ligi | 2321 | connect_mk("socket://"+DUBwiseHelper.ip_str(settings.act_conn_ip,false),"TCP/IP Connection"); |
206 | ligi | 2322 | chg_state(STATEID_CONN_DETAILS); |
2323 | } |
||
2324 | |||
2325 | break; |
||
2326 | |||
2327 | } |
||
2328 | break; |
||
2329 | |||
2330 | case STATEID_GPSVIEW: |
||
2331 | if (keyCode == this.KEY_NUM0) |
||
2332 | mk.set_gps_target(mk.gps_position.Latitude,mk.gps_position.Longitude); |
||
2333 | if (keyCode == this.KEY_NUM1) |
||
2334 | mk.gps_position.push_wp(); |
||
2335 | if (keyCode == this.KEY_NUM2) |
||
2336 | chg_state(STATEID_FILEOPEN); |
||
2337 | if (keyCode == this.KEY_NUM3) |
||
2338 | mk.set_gps_target(mk.gps_position.LatWP[act_wp],mk.gps_position.LongWP[act_wp]); |
||
2339 | |||
2340 | |||
2341 | if (keyCode == this.KEY_NUM5) |
||
2342 | heading_offset= mk.debug_data.analog[26]; |
||
2343 | |||
2344 | switch (getGameAction (keyCode)) |
||
2345 | { |
||
2346 | case UP: |
||
2347 | if (act_wp!=0) act_wp--; |
||
2348 | break; |
||
2349 | |||
2350 | case DOWN: |
||
2351 | if (act_wp<mk.gps_position.last_wp) act_wp++; |
||
2352 | |||
2353 | break; |
||
2354 | |||
2355 | |||
2356 | } |
||
2357 | |||
2358 | |||
2359 | break; |
||
2360 | |||
2361 | case STATEID_ABOUT: |
||
2362 | |||
2363 | switch (getGameAction (keyCode)) |
||
2364 | { |
||
2365 | case UP: |
||
2366 | if (act_menu_select>=max_lines) |
||
2367 | act_menu_select--; |
||
2368 | break; |
||
2369 | |||
2370 | case DOWN: |
||
2371 | if (act_menu_select<lcd_lines.length-1) |
||
2372 | act_menu_select++; |
||
2373 | |||
2374 | break; |
||
2375 | |||
2376 | |||
2377 | } |
||
2378 | |||
2379 | |||
2380 | break; |
||
2381 | |||
2382 | |||
2383 | case STATEID_RAWDEBUG: |
||
2384 | |||
2385 | switch (getGameAction (keyCode)) |
||
2386 | { |
||
2387 | case UP: |
||
2388 | if (rawdebug_cursor_y==0) |
||
2389 | rawdebug_cursor_y=31; |
||
2390 | else |
||
2391 | rawdebug_cursor_y--; |
||
2392 | break; |
||
2393 | |||
2394 | case DOWN: |
||
2395 | if (rawdebug_cursor_y==31) |
||
2396 | rawdebug_cursor_y=0; |
||
2397 | else |
||
2398 | rawdebug_cursor_y++; |
||
2399 | break; |
||
2400 | |||
2401 | |||
2402 | } |
||
2403 | break; |
||
2404 | case STATEID_KEYCONTROL: |
||
2405 | if (keyCode==KEY_POUND) |
||
2406 | keycontrol_exit |= 1; |
||
2407 | else |
||
2408 | if (keyCode==KEY_STAR) |
||
2409 | keycontrol_exit |= 2; |
||
2410 | else |
||
219 | ligi | 2411 | mod_external_control_by_keycode(keyCode,(byte)1); |
2412 | |||
2413 | |||
2414 | |||
2415 | if (keycontrol_exit==3) |
||
2416 | chg_state(STATEID_MAINMENU); |
||
2417 | |||
2418 | /* |
||
206 | ligi | 2419 | if ((keyCode >= this.KEY_NUM0) && (keyCode < this.KEY_NUM8)) |
2420 | keycontrol_bitfield[0]|=1<<(keyCode-this.KEY_NUM0); |
||
2421 | else |
||
2422 | if ((keyCode >= this.KEY_NUM8) && (keyCode <= this.KEY_NUM9)) |
||
2423 | keycontrol_bitfield[1]|=1<<(keyCode-this.KEY_NUM8); |
||
2424 | |||
2425 | else |
||
2426 | switch (getGameAction (keyCode)) |
||
2427 | { |
||
2428 | case UP: |
||
2429 | keycontrol_bitfield[1]|=4; |
||
2430 | break; |
||
2431 | |||
2432 | case DOWN: |
||
2433 | keycontrol_bitfield[1]|=8; |
||
2434 | break; |
||
2435 | |||
2436 | |||
2437 | case LEFT: |
||
2438 | keycontrol_bitfield[1]|=16; |
||
2439 | break; |
||
2440 | |||
2441 | case RIGHT: |
||
2442 | keycontrol_bitfield[1]|=32; |
||
2443 | break; |
||
2444 | |||
2445 | case FIRE: |
||
2446 | keycontrol_bitfield[1]|=64; |
||
2447 | break; |
||
2448 | |||
2449 | } |
||
2450 | else |
||
2451 | mk.send_keys(keycontrol_bitfield); |
||
219 | ligi | 2452 | */ |
206 | ligi | 2453 | break; |
2454 | |||
2455 | |||
2456 | case STATEID_MOTORTEST: |
||
2457 | switch (getGameAction (keyCode)) |
||
2458 | { |
||
2459 | case UP: |
||
2460 | act_motor_increase=-1; |
||
2461 | break; |
||
2462 | |||
2463 | case DOWN: |
||
2464 | act_motor_increase=1; |
||
2465 | break; |
||
2466 | |||
2467 | case FIRE: |
||
2468 | motor_test_sel_all=!motor_test_sel_all; |
||
2469 | break; |
||
2470 | |||
2471 | case LEFT: |
||
2472 | act_motor--; |
||
2473 | if (act_motor<0) {act_motor=0; chg_state(STATEID_MAINMENU); } |
||
2474 | break; |
||
2475 | |||
2476 | case RIGHT: |
||
2477 | act_motor++; |
||
2478 | act_motor%=4; |
||
2479 | break; |
||
2480 | } |
||
2481 | |||
2482 | break; |
||
2483 | |||
2484 | case STATEID_SELECT_COMPORT: |
||
2485 | if ( getGameAction (keyCode)==FIRE ) |
||
2486 | { |
||
2487 | |||
2488 | if (act_menu_select<menu_items.length) |
||
242 | ligi | 2489 | connect_mk("comm:"+menu_items[act_menu_select]+";baudrate=57600","com"+act_menu_select); |
206 | ligi | 2490 | |
2491 | chg_state(STATEID_CONN_DETAILS); |
||
2492 | } |
||
2493 | else |
||
2494 | menu_keypress(keyCode); |
||
2495 | break; |
||
2496 | |||
2497 | /* |
||
2498 | case STATEID_HANDLsE_PARAMS: |
||
2499 | |||
2500 | menu_keypress(keyCode); |
||
2501 | break; |
||
2502 | */ |
||
2503 | /* |
||
2504 | case STATEID_TRAFFIC: |
||
2505 | if ( getGameAction (keyCode)==FIRE ) |
||
2506 | chg_state(STATEID_CONN_DETAILS); |
||
2507 | else |
||
2508 | menu_keypress(keyCode); |
||
2509 | break; |
||
2510 | */ |
||
2511 | //#if fileapi=="on" |
||
2512 | case STATEID_FILEOPEN: |
||
2513 | if ( getGameAction (keyCode)==FIRE ) |
||
2514 | { |
||
221 | ligi | 2515 | file_access.fire(); |
206 | ligi | 2516 | } |
2517 | else |
||
2518 | menu_keypress(keyCode); |
||
2519 | break; |
||
2520 | |||
2521 | //#endif |
||
2522 | |||
220 | ligi | 2523 | case STATEID_SETTINGSMENU: |
2524 | settings_editor.keypress(keyCode,getGameAction (keyCode)) ; |
||
2525 | break; |
||
206 | ligi | 2526 | |
2527 | // handle menue |
||
220 | ligi | 2528 | // case STATEID_SELECT_SPEED_FORMAT: |
2529 | // case STATEID_SELECT_GPS_FORMAT: |
||
224 | ligi | 2530 | case STATEID_PARAM_MENU: |
206 | ligi | 2531 | case STATEID_TRAFFIC: |
2532 | case STATEID_CONN_DETAILS: |
||
2533 | case STATEID_HANDLE_PARAMS: |
||
220 | ligi | 2534 | |
206 | ligi | 2535 | case STATEID_MAINMENU: |
2536 | |||
2537 | if ( getGameAction (keyCode)==FIRE ) |
||
242 | ligi | 2538 | process_action(menu_actions[act_menu_select]); |
2539 | else |
||
2540 | menu_keypress(keyCode); |
||
222 | ligi | 2541 | |
206 | ligi | 2542 | break; |
2543 | |||
2544 | case STATEID_SELECT_PARAMSET: |
||
2545 | if ( getGameAction (keyCode)==FIRE ) |
||
223 | ligi | 2546 | { |
224 | ligi | 2547 | if (act_menu_select==5) // back |
2548 | { |
||
2549 | if (select_paramset4edit) |
||
2550 | chg_state(STATEID_PARAM_MENU); |
||
2551 | else |
||
2552 | chg_state(STATEID_HANDLE_PARAMS); |
||
2553 | |||
206 | ligi | 2554 | } |
223 | ligi | 2555 | else |
224 | ligi | 2556 | { |
2557 | if (select_paramset4edit) |
||
2558 | // if ( mk.params.field[act_menu_select]!=null) |
||
2559 | { |
||
2560 | mk.params.act_paramset=act_menu_select; |
||
2561 | chg_state(STATEID_HANDLE_PARAMS); |
||
2562 | //success_msg="Params saved"; |
||
2563 | } |
||
2564 | else |
||
2565 | { |
||
2566 | mk.write_params(act_menu_select); |
||
2567 | nextstate=STATEID_HANDLE_PARAMS; |
||
2568 | success_msg="saved in slot " + (act_menu_select+1) ; |
||
2569 | chg_state(STATEID_SUCCESS_MSG); // TODO - ground too optimistic way ;-) |
||
2570 | } |
||
2571 | |||
223 | ligi | 2572 | } |
206 | ligi | 2573 | } |
2574 | else menu_keypress(keyCode); |
||
2575 | break; |
||
2576 | |||
2577 | //#if bluetooth=="on" |
||
2578 | case STATEID_DEVICESELECT: |
||
2579 | |||
2580 | if ( getGameAction (keyCode)==FIRE ) |
||
2581 | { |
||
2582 | |||
2583 | if (bt_scanner.remote_device_count > act_menu_select) |
||
2584 | { |
||
2585 | connect_mk("btspp://"+bt_scanner.remote_device_mac[act_menu_select] + ":1",bt_scanner.remote_device_name[act_menu_select]); |
||
2586 | chg_state(STATEID_CONN_DETAILS); |
||
2587 | } |
||
2588 | else |
||
2589 | { |
||
2590 | if (bt_scanner.remote_device_count == act_menu_select) |
||
2591 | chg_state(STATEID_SCANNING); |
||
2592 | else |
||
2593 | chg_state(STATEID_CONN_DETAILS); |
||
2594 | } |
||
2595 | |||
2596 | } |
||
2597 | else menu_keypress(keyCode); |
||
2598 | |||
2599 | break; |
||
2600 | //#endif |
||
2601 | |||
2602 | |||
2603 | case STATEID_EDIT_PARAMS: |
||
2604 | params_editor.keypress(keyCode,getGameAction (keyCode)) ; |
||
2605 | break; |
||
2606 | |||
245 | ligi | 2607 | case STATEID_LCD: |
206 | ligi | 2608 | |
2609 | if ((keyCode >= this.KEY_NUM0) && (keyCode <= this.KEY_NUM9)) |
||
2610 | mk.LCD.set_page(keyCode-this.KEY_NUM0); |
||
2611 | else |
||
2612 | switch (getGameAction (keyCode)) |
||
2613 | { |
||
2614 | case LEFT: |
||
2615 | case UP: |
||
2616 | mk.LCD.LCD_PREVPAGE(); |
||
2617 | break; |
||
2618 | |||
2619 | case RIGHT: |
||
2620 | case DOWN: |
||
2621 | mk.LCD.LCD_NEXTPAGE(); |
||
2622 | break; |
||
2623 | |||
2624 | |||
2625 | |||
2626 | } |
||
2627 | break; |
||
2628 | } |
||
2629 | |||
2630 | |||
2631 | |||
2632 | } |
||
2633 | |||
2634 | |||
2635 | |||
2636 | |||
2637 | |||
2638 | |||
2639 | |||
2640 | |||
2641 | } |
||
2642 | |||
2643 |