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