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