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