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