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