Rev 382 | 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 | |||
382 | ligi | 12 | //#if j2memap=="on" |
13 | import com.eightmotions.map.*; |
||
14 | import com.eightmotions.util.UtilMidp; |
||
15 | //#endif |
||
206 | ligi | 16 | |
382 | ligi | 17 | //#if jsr179=="on" |
18 | import javax.microedition.location.*; |
||
19 | //#endif |
||
206 | ligi | 20 | |
382 | ligi | 21 | //#if openlapi=="on" |
22 | import com.openlapi.*; |
||
23 | //#endif |
||
24 | |||
242 | ligi | 25 | import javax.microedition.rms.*; |
26 | import java.io.*; |
||
206 | ligi | 27 | |
382 | ligi | 28 | |
29 | import org.ligi.ufo.MKFirmwareFlasher; |
||
30 | import org.ligi.ufo.DUBwiseDefinitions; |
||
31 | import org.ligi.ufo.DUBwiseLangDefs; |
||
32 | import org.ligi.ufo.MKCommunicator; |
||
33 | import org.ligi.ufo.MKFirmwareHelper; |
||
34 | |||
35 | |||
206 | ligi | 36 | public class DUBwiseCanvas |
37 | extends Canvas |
||
382 | ligi | 38 | implements Runnable,DUBwiseDefinitions , DUBwiseUIDefinitions,DUBwiseLangDefs |
39 | |||
40 | //#if (location=="on")&&(cldc11=="on") |
||
41 | ,LocationListener |
||
42 | //#endif |
||
206 | ligi | 43 | { |
44 | |||
493 | ligi | 45 | //#expand public final static byte version_patch=%VERSION_PATCH%; |
46 | //#expand public final static byte version_minor=%VERSION_MINOR%; |
||
47 | //#expand public final static byte version_major=%VERSION_MAJOR%; |
||
48 | |||
49 | public final static String version_str="" +version_major + "." + version_minor +"" +(char)('a'+version_patch) ; |
||
50 | |||
382 | ligi | 51 | //#if (location=="on")&&(cldc11=="on") |
52 | public void providerStateChanged(javax.microedition.location.LocationProvider p ,int i ) |
||
53 | { |
||
54 | } |
||
55 | |||
56 | public void locationUpdated(LocationProvider lp, Location loc) |
||
57 | { |
||
58 | try |
||
59 | { |
||
60 | Coordinates coords = loc.getQualifiedCoordinates(); |
||
61 | if (coords != null) |
||
62 | { |
||
63 | phone_long = coords.getLongitude(); |
||
64 | phone_lat = coords.getLatitude(); |
||
65 | |||
66 | if (mk!=null) |
||
67 | { |
||
68 | mk.lat=(long)phone_lat*10000000; |
||
69 | mk.lon=(long)phone_long*10000000; |
||
70 | |||
71 | } |
||
72 | // Start thread for handling the new coordinates |
||
73 | // (...) |
||
74 | } |
||
75 | else |
||
76 | { |
||
77 | phone_lat=-1.0; |
||
78 | phone_long=-1.0; |
||
79 | |||
80 | |||
81 | |||
82 | } |
||
83 | } |
||
84 | catch (Exception e) |
||
85 | { |
||
86 | // handle the exception |
||
87 | // (...) |
||
88 | } |
||
89 | } |
||
90 | |||
91 | //#endif |
||
92 | |||
93 | |||
493 | ligi | 94 | // MENU Definitions |
382 | ligi | 95 | |
255 | ligi | 96 | public final static int[] param_menu_items={STRINGID_EDIT_SETTINGS,STRINGID_COPY_TO_MOBILE,STRINGID_LOAD_FROM_MOBILE,STRINGID_REINITIALIZE_ALL,STRINGID_BACK}; |
97 | public final static byte[] param_menu_actions={ACTIONID_SELECT_PARAMS,ACTIONID_PARAM_COPY_MOBILE,ACTIONID_PARAM_LOAD_MOBILE,ACTIONID_RESET_PARAMS,ACTIONID_MAINMENU}; |
||
98 | |||
99 | public final static int[] handle_params_menu_items={STRINGID_EDIT_CONTENT,STRINGID_RENAME,STRINGID_SAVE_AS,STRINGID_SAVE,STRINGID_REREAD,STRINGID_BACK}; |
||
100 | 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 }; |
||
101 | |||
269 | ligi | 102 | |
103 | |||
104 | public final static int[] setting_options_menu_items={STRINGID_EDIT,STRINGID_LOADPLAIN,STRINGID_LOADFANCY,STRINGID_BACK}; |
||
105 | public final static byte[]setting_options_menu_actions={ACTIONID_SETTINGS,ACTIONID_SETTING_LOADPLAIN,ACTIONID_SETTING_LOADFANCY,ACTIONID_MAINMENU }; |
||
106 | |||
255 | ligi | 107 | public final static int[] onlyback_menu_items={STRINGID_BACK }; |
108 | public final static byte[] back_to_conndetails_actions={ACTIONID_BACK_TO_CONNDETAILS}; |
||
109 | |||
110 | |||
382 | ligi | 111 | |
112 | public int[] beta_unlock_code={Canvas.KEY_NUM2,Canvas.KEY_NUM3,Canvas.KEY_NUM8,Canvas.KEY_NUM2}; |
||
113 | |||
114 | int beta_unlock_pos=0; |
||
115 | |||
206 | ligi | 116 | //#if fileapi=="on" |
221 | ligi | 117 | DUBwiseFileAccess file_access; |
206 | ligi | 118 | //#endif |
119 | |||
382 | ligi | 120 | MixerManager mixer_manager; |
121 | MotorTester motor_tester; |
||
122 | |||
123 | |||
213 | ligi | 124 | String act_input_str=" "; |
223 | ligi | 125 | // for dual use of states |
126 | boolean select_paramset4edit; |
||
242 | ligi | 127 | |
382 | ligi | 128 | //#if (location=="on")&&(cldc11=="on") |
129 | Criteria cr= null; |
||
267 | ligi | 130 | |
382 | ligi | 131 | LocationProvider lp= null; |
132 | Coordinates c=null; |
||
267 | ligi | 133 | |
134 | |||
382 | ligi | 135 | //#endif |
267 | ligi | 136 | |
137 | |||
138 | |||
382 | ligi | 139 | String act_msg=""; |
242 | ligi | 140 | |
141 | boolean read_paramset_intension_save; |
||
206 | ligi | 142 | boolean ipinput4proxy; |
223 | ligi | 143 | |
144 | |||
206 | ligi | 145 | byte ipinput_pos=0; |
146 | int[] act_edit_ip; |
||
147 | |||
148 | int canvas_width=100; |
||
149 | int canvas_height=100; |
||
150 | |||
151 | |||
382 | ligi | 152 | |
206 | ligi | 153 | int heading_offset=0; |
154 | int act_wp; |
||
155 | |||
382 | ligi | 156 | long key_bitfield=0; |
157 | |||
158 | |||
159 | boolean debug_overlay=false; |
||
160 | |||
161 | public long keyCode2mask(int keyCode) |
||
162 | { |
||
163 | if ((keyCode>=KEY_NUM0)&&(keyCode<=KEY_NUM9)) |
||
164 | return 1<<(keyCode-KEY_NUM0); |
||
165 | else |
||
166 | switch (getGameAction( keyCode )) |
||
167 | { |
||
168 | case UP: |
||
169 | return 1<<10; |
||
170 | case DOWN: |
||
171 | return 1<<11; |
||
172 | case LEFT: |
||
173 | return 1<<12; |
||
174 | case RIGHT: |
||
175 | return 1<<13; |
||
176 | case FIRE: |
||
177 | return 1<<14; |
||
178 | } |
||
179 | // log("unmapped key"); |
||
180 | return 0; // cant translate |
||
181 | } |
||
182 | |||
206 | ligi | 183 | //#if bluetooth=="on" |
184 | private BTSearcher bt_scanner; |
||
185 | //#endif |
||
186 | |||
382 | ligi | 187 | public MKCommunicator mk=null; |
206 | ligi | 188 | // private MKStatistics mk_stat=null; |
382 | ligi | 189 | |
190 | private MKParamsEditor act_editor=null; |
||
191 | |||
192 | /* |
||
206 | ligi | 193 | private MKParamsEditor params_editor=null; |
220 | ligi | 194 | private MKParamsEditor settings_editor=null; |
382 | ligi | 195 | private MKParamsEditor motor_tester=null; |
196 | |||
197 | */ |
||
198 | |||
199 | public MKFirmwareFlasher firmware_flasher=null; |
||
206 | ligi | 200 | public DUBwiseDebug debug=null; |
255 | ligi | 201 | public FirmwareLoader fw_loader=null; |
206 | ligi | 202 | |
266 | ligi | 203 | public byte last_navi_error=0; |
242 | ligi | 204 | |
205 | |||
266 | ligi | 206 | |
206 | ligi | 207 | //#if voice_mode!="no_voice" |
229 | ligi | 208 | public MKStatusVoice status_voice; |
206 | ligi | 209 | //#endif |
210 | |||
211 | |||
212 | private DUBwise root; |
||
213 | public DUBwiseSettings settings; |
||
214 | |||
382 | ligi | 215 | |
206 | ligi | 216 | private Image bg_img; |
217 | private Image lcd_img; |
||
218 | private Image symbols_img; |
||
493 | ligi | 219 | |
220 | private Image big_symbols_img; |
||
242 | ligi | 221 | |
222 | private int symbols_img_tile_height; |
||
223 | private int symbols_img_tile_width; |
||
224 | |||
225 | |||
206 | ligi | 226 | private Image err_img; |
227 | |||
228 | |||
382 | ligi | 229 | private Image icon_img; |
206 | ligi | 230 | |
231 | |||
382 | ligi | 232 | byte max_lines; |
233 | |||
234 | |||
235 | /* |
||
206 | ligi | 236 | public byte act_motor=0; |
237 | public byte act_motor_increase=0; |
||
238 | public boolean motor_test_sel_all=false; |
||
382 | ligi | 239 | */ |
206 | ligi | 240 | |
241 | /* Graph Vars */ |
||
242 | public final static int GRAPH_COUNT=4; |
||
264 | ligi | 243 | // public final static int[] graph_colors={0x156315,0xCC1315,0xf8ef02,0x19194d}; |
244 | public final static int[] graph_colors={0x0aff15,0xCC1315,0xf8ef02,0x1638ff}; |
||
206 | ligi | 245 | public int[] graph_sources={0,1,2,3}; |
246 | public String[] graph_names={"nick int","roll int","nick acc","roll acc"}; |
||
262 | ligi | 247 | // public int[][] graph_data; |
248 | //public int graph_offset=0; |
||
221 | ligi | 249 | |
223 | ligi | 250 | // public int lcd_char_width=0; |
206 | ligi | 251 | public int lcd_char_height=0; |
252 | |||
253 | public int frame_pos=0; |
||
254 | |||
255 | // public byte mk.user_intent=USER_INTENT_NONE; |
||
256 | |||
257 | int line_scaler=20; |
||
258 | |||
259 | int rawdebug_cursor_y=0; |
||
260 | int rawdebug_off_y=0; |
||
261 | |||
262 | public int line_middle_y; |
||
229 | ligi | 263 | public int graph_height; |
206 | ligi | 264 | |
229 | ligi | 265 | |
206 | ligi | 266 | boolean quit=false; |
267 | |||
268 | int bg_offset=0; |
||
269 | |||
270 | // variable to hold the current state |
||
223 | ligi | 271 | public byte state=STATEID_INITIAL; |
224 | ligi | 272 | public byte nextstate=STATEID_INITIAL; |
206 | ligi | 273 | |
262 | ligi | 274 | // int local_max=-1; |
206 | ligi | 275 | |
276 | int y_off=0; |
||
265 | ligi | 277 | int spacer_small=0; |
278 | int spacer_medium=0; |
||
279 | int spacer_large=0; |
||
206 | ligi | 280 | |
281 | String[] menu_items; |
||
282 | byte[] menu_actions; |
||
382 | ligi | 283 | byte act_menu_select=0; |
284 | byte[] act_menu_select_bak; |
||
206 | ligi | 285 | String[] lcd_lines =null; |
286 | |||
287 | |||
242 | ligi | 288 | // to check if 2 keys are pressed |
289 | byte keycontrol_exit=0; |
||
214 | ligi | 290 | |
242 | ligi | 291 | |
292 | byte setup_pos; |
||
293 | byte[] tmp_actions; |
||
294 | String[] tmp_items; |
||
214 | ligi | 295 | // boolean expert_mode=false; |
296 | |||
255 | ligi | 297 | |
298 | byte act_lang=0; |
||
299 | |||
300 | public String[] localized_strings; |
||
301 | |||
302 | public String l(int str_id) |
||
303 | { |
||
304 | return localized_strings[str_id]; |
||
305 | |||
306 | } |
||
242 | ligi | 307 | public void tmp_menu_init(int max_items) |
214 | ligi | 308 | { |
242 | ligi | 309 | setup_pos=0; |
310 | tmp_actions=new byte[max_items]; |
||
311 | tmp_items=new String[max_items]; |
||
312 | } |
||
214 | ligi | 313 | |
242 | ligi | 314 | public void tmp_menu_add(String label,byte action) |
315 | { |
||
316 | tmp_actions[setup_pos] = action; |
||
317 | tmp_items[setup_pos] = label; |
||
318 | setup_pos++; |
||
319 | } |
||
214 | ligi | 320 | |
242 | ligi | 321 | public void tmp_menu_use() |
322 | { |
||
323 | byte[] tmp_actions_fin=new byte[setup_pos]; |
||
324 | String[] tmp_items_fin=new String[setup_pos]; |
||
325 | |||
326 | if (setup_pos<act_menu_select) |
||
327 | act_menu_select=0; |
||
214 | ligi | 328 | |
242 | ligi | 329 | for ( int tmp_p=0;tmp_p<setup_pos;tmp_p++) |
214 | ligi | 330 | { |
242 | ligi | 331 | tmp_actions_fin[tmp_p]=tmp_actions[tmp_p]; |
332 | tmp_items_fin[tmp_p] =tmp_items[tmp_p]; |
||
214 | ligi | 333 | } |
334 | |||
242 | ligi | 335 | setup_menu(tmp_items_fin,tmp_actions_fin); |
336 | } |
||
337 | |||
338 | public void setup_conn_menu() |
||
339 | { |
||
382 | ligi | 340 | tmp_menu_init(10); |
266 | ligi | 341 | |
342 | if (mk.connected) |
||
343 | { |
||
344 | tmp_menu_add(l(STRINGID_PACKET_TRAFFIC),ACTIONID_TRAFFIC); |
||
345 | tmp_menu_add(l(STRINGID_VIEW_DATA),ACTIONID_DATABUFF); |
||
269 | ligi | 346 | tmp_menu_add(l(STRINGID_FORCERECONNECT),ACTIONID_RECONNECT); |
266 | ligi | 347 | } |
242 | ligi | 348 | //#if bluetooth=="on" |
255 | ligi | 349 | tmp_menu_add(l(STRINGID_CONNECT_BT),ACTIONID_SCAN_BT); |
242 | ligi | 350 | //#endif |
255 | ligi | 351 | tmp_menu_add(l(STRINGID_CONNECT_TCP),ACTIONID_CONNECT_TCP); |
214 | ligi | 352 | |
242 | ligi | 353 | if ((System.getProperty("microedition.commports")!=null)&&(!System.getProperty("microedition.commports").equals(""))) |
255 | ligi | 354 | tmp_menu_add(l(STRINGID_CONNECT_COM),ACTIONID_SELECT_COM); |
355 | tmp_menu_add(l(STRINGID_SET_PROXY),ACTIONID_PROXY_INPUT); |
||
356 | tmp_menu_add(l(STRINGID_BACK),ACTIONID_MAINMENU); |
||
242 | ligi | 357 | tmp_menu_use(); |
214 | ligi | 358 | |
242 | ligi | 359 | } |
214 | ligi | 360 | |
222 | ligi | 361 | |
242 | ligi | 362 | public void setup_main_menu() |
363 | { |
||
382 | ligi | 364 | tmp_menu_init(30); |
242 | ligi | 365 | |
382 | ligi | 366 | |
269 | ligi | 367 | tmp_menu_add(l(STRINGID_SETTINGS),ACTIONID_SETTING_OPTIONS); |
255 | ligi | 368 | tmp_menu_add(l(STRINGID_CONN),ACTIONID_CONN_DETAILS); |
214 | ligi | 369 | |
382 | ligi | 370 | |
266 | ligi | 371 | if (settings.dev_mode) |
372 | { |
||
382 | ligi | 373 | // tmp_menu_add(l(STRINGID_SELECT_FIRMWARE),ACTIONID_SELECT_FIRMWARE); |
374 | // tmp_menu_add("UPDATE_DUBWISE",ACTIONID_UPDATE_DUBWISE); |
||
375 | |||
376 | // tmp_menu_add("Follow Me",ACTIONID_SHOWPHONEGPS); |
||
377 | |||
378 | tmp_menu_add("File Open",ACTIONID_SELECT_DUBWISEDIR); |
||
379 | tmp_menu_add(l(STRINGID_DEBUG),ACTIONID_DEBUG); |
||
266 | ligi | 380 | } |
255 | ligi | 381 | |
382 | |||
266 | ligi | 383 | |
382 | ligi | 384 | |
385 | |||
266 | ligi | 386 | // only mk |
382 | ligi | 387 | if (mk.is_mk()) |
214 | ligi | 388 | { |
255 | ligi | 389 | tmp_menu_add(l(STRINGID_MOTORTEST),ACTIONID_MOTORTEST); |
390 | tmp_menu_add(l(STRINGID_KEYCONTROL),ACTIONID_KEYCONTROL); |
||
391 | tmp_menu_add(l(STRINGID_RCDATA),ACTIONID_RCDATA); |
||
392 | tmp_menu_add(l(STRINGID_FLIGHTSETTINGS),ACTIONID_PARAM_MENU); |
||
266 | ligi | 393 | tmp_menu_add(l(STRINGID_GRAPH),ACTIONID_GRAPH); |
382 | ligi | 394 | |
395 | tmp_menu_add("Mixer",ACTIONID_SELECT_MIXER); |
||
214 | ligi | 396 | } |
397 | |||
382 | ligi | 398 | if ( mk.is_rangeextender()|| mk.is_followme() ) |
399 | { |
||
400 | tmp_menu_add(l(STRINGID_LCD),ACTIONID_LCD); |
||
401 | tmp_menu_add(l(STRINGID_DEBUG_VALUES),ACTIONID_RAWDEBUG); |
||
402 | } |
||
214 | ligi | 403 | |
266 | ligi | 404 | // mk & navi |
382 | ligi | 405 | |
406 | if ( mk.is_navi()||mk.is_mk() ) |
||
264 | ligi | 407 | { |
493 | ligi | 408 | tmp_menu_add("Big Symbols",ACTIONID_BIG_SYMBOLS); |
266 | ligi | 409 | tmp_menu_add(l(STRINGID_COCKPIT),ACTIONID_HORIZON); |
264 | ligi | 410 | tmp_menu_add(l(STRINGID_LCD),ACTIONID_LCD); |
411 | } |
||
214 | ligi | 412 | |
266 | ligi | 413 | |
414 | |||
382 | ligi | 415 | if (( mk.is_navi()||mk.is_mk()||mk.is_mk3mag() )) |
255 | ligi | 416 | tmp_menu_add(l(STRINGID_DEBUG_VALUES),ACTIONID_RAWDEBUG); |
214 | ligi | 417 | |
382 | ligi | 418 | |
214 | ligi | 419 | |
266 | ligi | 420 | // only navi |
382 | ligi | 421 | if ( mk.is_navi()) |
214 | ligi | 422 | { |
382 | ligi | 423 | |
424 | |||
425 | //#if j2memap=="on" |
||
426 | tmp_menu_add("Map",ACTIONID_MAP); |
||
427 | //#endif |
||
428 | |||
429 | |||
430 | //#if (location=="on")&&(cldc11=="on") |
||
431 | tmp_menu_add("Follow Me",ACTIONID_SHOWPHONEGPS); |
||
432 | //#endif |
||
433 | |||
255 | ligi | 434 | tmp_menu_add(l(STRINGID_VIEW_GPS),ACTIONID_GPSDATA); |
267 | ligi | 435 | if (mk.gps_position.ErrorCode!=0) tmp_menu_add(l(STRINGID_VIEW_ERRORS),ACTIONID_NC_ERRORS); |
255 | ligi | 436 | tmp_menu_add(l(STRINGID_SWITCH_FC),ACTIONID_SWITCH_FC); |
437 | tmp_menu_add(l(STRINGID_SWITCH_MK3MAG),ACTIONID_SWITCH_MK3MAG); |
||
214 | ligi | 438 | |
439 | } |
||
440 | |||
382 | ligi | 441 | if (mk.is_mk()||mk.is_mk3mag() ) |
255 | ligi | 442 | tmp_menu_add(l(STRINGID_SWITCH_NAVI),ACTIONID_SWITCH_NC); |
214 | ligi | 443 | |
444 | |||
219 | ligi | 445 | //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 | 446 | |
382 | ligi | 447 | if ((settings.expert_mode)||mk.is_mk()) |
255 | ligi | 448 | tmp_menu_add(l(STRINGID_FLASH_FIRMWARE),ACTIONID_FLASH); |
229 | ligi | 449 | |
382 | ligi | 450 | if (settings.dev_mode&& mk.is_mk() ) |
255 | ligi | 451 | tmp_menu_add(l(STRINGID_REMOTE_CAM),ACTIONID_CAM); |
214 | ligi | 452 | |
229 | ligi | 453 | if (!settings.expert_mode) |
255 | ligi | 454 | tmp_menu_add(l(STRINGID_ABOUT),ACTIONID_ABOUT); |
214 | ligi | 455 | |
255 | ligi | 456 | tmp_menu_add(l(STRINGID_QUIT),ACTIONID_QUIT); |
214 | ligi | 457 | |
242 | ligi | 458 | tmp_menu_use(); |
214 | ligi | 459 | } |
460 | |||
206 | ligi | 461 | public void setup_menu(String[] items , byte[] actions) |
462 | { |
||
267 | ligi | 463 | if ((menu_items==null)||(act_menu_select>=menu_items.length)) |
266 | ligi | 464 | act_menu_select=0; |
206 | ligi | 465 | menu_items=items; |
466 | menu_actions=actions; |
||
467 | lcd_lines=new String[menu_items.length]; |
||
266 | ligi | 468 | |
206 | ligi | 469 | } |
470 | |||
255 | ligi | 471 | public void setup_menu(int[] items , byte[] actions) |
472 | { |
||
473 | menu_items=new String[items.length]; |
||
474 | for(int i=0;i<items.length;i++) |
||
475 | menu_items[i]=l(items[i]); |
||
476 | |||
477 | menu_actions=actions; |
||
478 | lcd_lines=new String[menu_items.length]; |
||
479 | } |
||
480 | |||
206 | ligi | 481 | public void paint_menu(Graphics g) |
482 | { |
||
255 | ligi | 483 | if (menu_items==null) return; |
206 | ligi | 484 | for ( int i=0;i<menu_items.length;i++) |
485 | { |
||
486 | if ((frame_pos%3)!=0) |
||
487 | { |
||
488 | lcd_lines[i]=(act_menu_select==i?">":" ") + menu_items[i]; |
||
489 | for ( int ii=0;ii<(18-menu_items[i].length());ii++) |
||
490 | lcd_lines[i]+=" "; |
||
491 | if (act_menu_select==i) |
||
492 | lcd_lines[i]+="<"; |
||
493 | } |
||
494 | else |
||
495 | lcd_lines[i]=" " + menu_items[i]; |
||
496 | |||
497 | |||
498 | } |
||
221 | ligi | 499 | paint_lcd(g); |
206 | ligi | 500 | } |
501 | |||
382 | ligi | 502 | |
503 | // int selected_fw= |
||
504 | |||
206 | ligi | 505 | public void menu_keypress(int keyCode) |
506 | { |
||
507 | debug.log("Menu with KeyCode:"+keyCode); |
||
508 | switch (getGameAction (keyCode)) |
||
509 | { |
||
510 | case UP: |
||
220 | ligi | 511 | if (act_menu_select!=0) |
512 | act_menu_select--; |
||
206 | ligi | 513 | else |
382 | ligi | 514 | act_menu_select=(byte)(menu_items.length-1); |
206 | ligi | 515 | break; |
516 | |||
517 | case DOWN: |
||
220 | ligi | 518 | if (act_menu_select<(menu_items.length-1)) |
519 | act_menu_select++; |
||
520 | else |
||
521 | act_menu_select=0; |
||
206 | ligi | 522 | break; |
255 | ligi | 523 | |
524 | case FIRE: |
||
525 | switch(state) |
||
526 | { |
||
527 | |||
382 | ligi | 528 | case STATEID_SELECT_MIXER: |
529 | if (act_menu_select<menu_items.length-1) |
||
530 | mk.set_mixer_table(mixer_manager.bytes(act_menu_select)); |
||
531 | else |
||
532 | chg_state(STATEID_MAINMENU); |
||
533 | |||
534 | break; |
||
535 | |||
536 | case STATEID_SELECT_FIRMWARE: |
||
537 | |||
538 | fw_loader.menu_fire(act_menu_select); |
||
539 | |||
540 | break; |
||
255 | ligi | 541 | case STATEID_SELECT_COMPORT: |
542 | if (act_menu_select<menu_items.length) |
||
543 | connect_mk("comm:"+menu_items[act_menu_select]+";baudrate=57600","com"+act_menu_select); |
||
544 | |||
545 | chg_state(STATEID_CONN_DETAILS); |
||
546 | break; |
||
547 | |||
548 | //#if fileapi=="on" |
||
549 | case STATEID_FILEOPEN: |
||
550 | |||
551 | file_access.fire(); |
||
552 | |||
553 | break; |
||
554 | |||
555 | //#endif |
||
556 | |||
557 | case STATEID_SELECT_PARAMSET: |
||
558 | |||
559 | if (act_menu_select==5) // back |
||
560 | { |
||
561 | if (select_paramset4edit) |
||
562 | chg_state(STATEID_PARAM_MENU); |
||
563 | else |
||
564 | chg_state(STATEID_HANDLE_PARAMS); // from save as |
||
565 | |||
566 | } |
||
567 | else |
||
568 | { |
||
569 | if (select_paramset4edit) |
||
570 | // if ( mk.params.field[act_menu_select]!=null) |
||
571 | { |
||
572 | mk.params.act_paramset=act_menu_select; |
||
573 | chg_state(STATEID_HANDLE_PARAMS); |
||
382 | ligi | 574 | //act_msg="Params saved"; |
255 | ligi | 575 | } |
576 | else |
||
577 | { |
||
578 | mk.write_params(act_menu_select); |
||
579 | nextstate=STATEID_HANDLE_PARAMS; |
||
382 | ligi | 580 | act_msg="saved in slot " + (act_menu_select+1) ; |
255 | ligi | 581 | chg_state(STATEID_SUCCESS_MSG); // TODO - ground too optimistic way ;-) |
582 | } |
||
583 | |||
584 | } |
||
585 | |||
586 | |||
587 | break; |
||
588 | |||
589 | //#if bluetooth=="on" |
||
590 | case STATEID_DEVICESELECT: |
||
591 | |||
592 | |||
593 | if (bt_scanner.remote_device_count > act_menu_select) |
||
594 | { |
||
595 | connect_mk("btspp://"+bt_scanner.remote_device_mac[act_menu_select] + ":1",bt_scanner.remote_device_name[act_menu_select]); |
||
596 | chg_state(STATEID_CONN_DETAILS); |
||
597 | } |
||
598 | else |
||
599 | { |
||
600 | if (bt_scanner.remote_device_count == act_menu_select) |
||
601 | chg_state(STATEID_SCANNING); |
||
602 | else |
||
603 | chg_state(STATEID_CONN_DETAILS); |
||
604 | } |
||
605 | |||
606 | break; |
||
607 | //#endif |
||
608 | |||
609 | |||
610 | default: |
||
611 | if (menu_actions!=null) |
||
612 | process_action(menu_actions[act_menu_select]); |
||
613 | } |
||
206 | ligi | 614 | } |
615 | |||
616 | } |
||
617 | |||
618 | public boolean cam_condition() |
||
619 | { |
||
221 | ligi | 620 | return (mk.stick_data.stick[settings.remote_cam_stick]>100); |
206 | ligi | 621 | } |
622 | |||
623 | // int lcd_top=25; |
||
242 | ligi | 624 | int lcd_off; |
221 | ligi | 625 | public void paint_lcd(Graphics g) |
206 | ligi | 626 | { |
627 | int y; |
||
220 | ligi | 628 | // int lcd_top= (state==STATEID_EDIT_PARAMS?0:25); |
221 | ligi | 629 | //int lcd_top= 25; |
382 | ligi | 630 | max_lines=(byte)((canvas_height-25/*lcd_top*/)/lcd_char_height); |
206 | ligi | 631 | int spacer_left_right=(canvas_width-(20*(lcd_img.getWidth()/222)))/2; |
632 | // for(int i=0;i<lcd_lines.length;i++) |
||
633 | |||
634 | int display_lines=(lcd_lines.length>max_lines?max_lines:lcd_lines.length); |
||
635 | |||
636 | |||
382 | ligi | 637 | lcd_off=act_menu_select-display_lines+1; |
638 | if (((act_editor!=null)&&(!act_editor.select_mode))) |
||
639 | lcd_off=act_editor.act_y-display_lines+1; |
||
640 | |||
206 | ligi | 641 | if ( lcd_off<0) lcd_off=0; |
642 | |||
643 | for(int i=0;i<display_lines;i++) |
||
644 | for (int pos=0;pos<20;pos++) |
||
645 | { |
||
221 | ligi | 646 | /*if (!bottomup) |
647 | y=i*lcd_char_height; |
||
648 | else*/ |
||
223 | ligi | 649 | y=canvas_height-(display_lines-i)*lcd_char_height; |
221 | ligi | 650 | |
206 | ligi | 651 | g.setClip((lcd_img.getWidth()/222)*pos+spacer_left_right,y,(lcd_img.getWidth()/222),lcd_img.getHeight()); |
652 | 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); |
||
653 | } |
||
654 | } |
||
655 | |||
221 | ligi | 656 | public void load_skin_images() |
206 | ligi | 657 | { |
658 | try |
||
659 | { |
||
660 | bg_img=null; |
||
661 | lcd_img=null; |
||
662 | |||
663 | // load all needed images |
||
664 | switch (settings.act_skin) |
||
665 | { |
||
666 | case SKINID_DARK: |
||
667 | lcd_img=Image.createImage("/lcd_green.png"); |
||
221 | ligi | 668 | if (settings.do_scrollbg) bg_img=Image.createImage("/starfield.jpg"); |
669 | break; |
||
670 | |||
671 | |||
206 | ligi | 672 | case SKINID_LIGHT: |
673 | lcd_img=Image.createImage("/lcd_blue.png"); |
||
674 | if (settings.do_scrollbg) bg_img=Image.createImage("/clouds.jpg"); |
||
675 | break; |
||
676 | } |
||
223 | ligi | 677 | // lcd_char_width=lcd_img.getWidth()/222; |
221 | ligi | 678 | lcd_char_height=lcd_img.getHeight(); |
679 | } |
||
206 | ligi | 680 | |
221 | ligi | 681 | catch (Exception e) |
682 | { |
||
683 | debug.err(e.toString()); |
||
684 | } |
||
206 | ligi | 685 | |
221 | ligi | 686 | } |
687 | public void load_global_images() |
||
688 | { |
||
689 | try |
||
690 | { |
||
382 | ligi | 691 | icon_img=Image.createImage("/i.png"); |
206 | ligi | 692 | symbols_img=Image.createImage("/symbols.png"); |
266 | ligi | 693 | symbols_img_tile_height=symbols_img.getHeight()/3; |
242 | ligi | 694 | symbols_img_tile_width=symbols_img.getWidth()/10; |
206 | ligi | 695 | |
221 | ligi | 696 | /* if (bg_img!=null) |
206 | ligi | 697 | graph_data=new int[GRAPH_COUNT][bg_img.getWidth()]; |
698 | else |
||
221 | ligi | 699 | */ |
206 | ligi | 700 | |
701 | } |
||
702 | |||
703 | catch (Exception e) |
||
704 | { |
||
705 | debug.err(e.toString()); |
||
706 | } |
||
707 | |||
708 | } |
||
709 | |||
255 | ligi | 710 | |
711 | public void load_strings() |
||
712 | { |
||
382 | ligi | 713 | // System.out.println("loading strings"); |
255 | ligi | 714 | localized_strings=new String[STRING_COUNT]; |
715 | |||
716 | try { |
||
717 | InputStream in=this.getClass().getResourceAsStream("/l"); |
||
718 | |||
719 | for (int i=0;i<STRING_COUNT;i++) |
||
720 | { |
||
382 | ligi | 721 | String tmp_s=""; // temp string to use |
722 | String tmp_b=""; // backup string ( if string isnt present in selected lang - e.g. same as in english ) |
||
255 | ligi | 723 | char ch=0; |
724 | |||
725 | int act_l=0; |
||
726 | while ( (ch=(char)in.read())!='\n') |
||
727 | { |
||
728 | if (ch==';') |
||
382 | ligi | 729 | act_l++; |
255 | ligi | 730 | else |
731 | { |
||
382 | ligi | 732 | // "backup" str |
255 | ligi | 733 | if (act_l==0) |
734 | tmp_b+=ch; |
||
735 | |||
382 | ligi | 736 | |
737 | // normal str |
||
255 | ligi | 738 | if (act_l==act_lang) |
739 | tmp_s+=ch; |
||
740 | } |
||
741 | |||
742 | } |
||
743 | |||
382 | ligi | 744 | |
255 | ligi | 745 | if (tmp_s.equals("")) |
746 | localized_strings[i]=tmp_b; |
||
747 | else |
||
748 | localized_strings[i]=tmp_s; |
||
382 | ligi | 749 | |
255 | ligi | 750 | } |
751 | } |
||
752 | catch (Exception e) { System.out.println("str_load err"+e);} |
||
753 | } |
||
754 | |||
755 | |||
221 | ligi | 756 | // construct |
206 | ligi | 757 | public DUBwiseCanvas(DUBwise _root) |
758 | { |
||
382 | ligi | 759 | |
760 | int foo=0; |
||
761 | |||
762 | // |
||
255 | ligi | 763 | load_strings(); |
382 | ligi | 764 | |
255 | ligi | 765 | |
382 | ligi | 766 | act_menu_select_bak=new byte[STATEID_COUNT]; |
767 | |||
224 | ligi | 768 | for (int i=0;i<STATEID_COUNT;i++) |
223 | ligi | 769 | act_menu_select_bak[i]=0; |
382 | ligi | 770 | |
206 | ligi | 771 | //#if fileapi=="on" |
221 | ligi | 772 | file_access=new DUBwiseFileAccess(this); |
206 | ligi | 773 | //#endif |
774 | |||
382 | ligi | 775 | |
206 | ligi | 776 | root=_root; |
777 | |||
382 | ligi | 778 | mixer_manager = new MixerManager(); |
779 | settings = new DUBwiseSettings(this); |
||
229 | ligi | 780 | |
382 | ligi | 781 | try { |
782 | settings.load(); |
||
783 | } |
||
784 | catch ( Exception e) {} |
||
229 | ligi | 785 | |
382 | ligi | 786 | load_global_images(); |
229 | ligi | 787 | |
206 | ligi | 788 | debug = new DUBwiseDebug(this); |
789 | |||
790 | |||
791 | |||
382 | ligi | 792 | //#if voice_mode!="no_voice" |
793 | status_voice=new MKStatusVoice(this); |
||
794 | //#endif |
||
211 | ligi | 795 | |
266 | ligi | 796 | // mk.gps_position.act_speed_format=settings.speed_format; |
797 | /// mk.gps_position.act_gps_format= settings.gps_format; |
||
206 | ligi | 798 | |
221 | ligi | 799 | |
206 | ligi | 800 | chg_state(STATEID_MAINMENU); |
382 | ligi | 801 | |
206 | ligi | 802 | new Thread(this).start(); |
803 | |||
804 | } |
||
805 | |||
267 | ligi | 806 | public void refresh_dynamic_menues() |
807 | { |
||
808 | if (state==STATEID_MAINMENU) |
||
809 | chg_state(STATEID_MAINMENU); // reload mainmenu ( changed content ) |
||
810 | if (state==STATEID_CONN_DETAILS) |
||
382 | ligi | 811 | chg_state(STATEID_CONN_DETAILS); // reload con details ( changed content ) |
267 | ligi | 812 | } |
382 | ligi | 813 | |
814 | |||
815 | |||
206 | ligi | 816 | |
817 | /****************************** Thread ******************/ |
||
818 | // ticking runnable Section |
||
819 | public void run() |
||
820 | { |
||
821 | while(true) |
||
822 | { |
||
382 | ligi | 823 | if ((firmware_flasher!=null)) |
824 | { |
||
825 | if (mk!=null) |
||
826 | { |
||
827 | mk.close_connections(true); |
||
828 | mk=null; |
||
829 | } |
||
830 | if (!firmware_flasher.started) |
||
831 | firmware_flasher.start(); |
||
832 | } |
||
833 | |||
834 | if ( key_bitfield==(keyCode2mask(KEY_NUM1)|keyCode2mask(KEY_NUM3))) |
||
835 | debug_overlay=!debug_overlay; |
||
836 | |||
206 | ligi | 837 | try { |
838 | |||
839 | |||
840 | repaint(); |
||
841 | serviceRepaints(); |
||
842 | |||
843 | System.gc(); |
||
844 | long loopStartTime = System.currentTimeMillis(); |
||
845 | long sleeptime=0; |
||
846 | // ticked thing |
||
847 | |||
848 | frame_pos++; |
||
849 | |||
382 | ligi | 850 | if (mk!=null) |
206 | ligi | 851 | { |
382 | ligi | 852 | if (mk.mixer_change_notify) |
206 | ligi | 853 | { |
382 | ligi | 854 | nextstate=STATEID_MAINMENU; |
855 | if (mk.mixer_change_success) |
||
856 | { |
||
857 | act_msg="Mixer Write OK"; |
||
858 | chg_state(STATEID_SUCCESS_MSG); |
||
859 | } |
||
860 | else |
||
861 | |||
862 | { |
||
863 | act_msg="Mixer Write Fail"; |
||
864 | chg_state(STATEID_ERROR_MSG); |
||
865 | } |
||
866 | mk.mixer_change_notify=false; |
||
206 | ligi | 867 | } |
267 | ligi | 868 | |
382 | ligi | 869 | // handle Device Change |
870 | if (mk.change_notify) |
||
871 | { |
||
872 | mk.change_notify=false; |
||
873 | if ((mk.is_incompatible())&&(settings.instant_error_show)) |
||
874 | { |
||
875 | act_msg=l(STRINGID_INCOMPATIBLEDEVICE); |
||
876 | chg_state(STATEID_ERROR_MSG); |
||
877 | } |
||
878 | else |
||
879 | refresh_dynamic_menues(); |
||
880 | |||
881 | if (state==STATEID_ERROR_MSG) |
||
882 | chg_state(STATEID_MAINMENU); |
||
883 | |||
884 | } |
||
885 | |||
886 | if (mk.disconnect_notify) |
||
887 | { |
||
888 | mk.disconnect_notify=false; |
||
889 | |||
890 | if (!mk.mk_url.equals("")&&(settings.instant_error_show)) |
||
891 | { |
||
892 | if (settings.instant_error_show) |
||
893 | { |
||
894 | nextstate=STATEID_MAINMENU; |
||
895 | act_msg=l(STRINGID_DISCONNECT); |
||
896 | chg_state( STATEID_ERROR_MSG); |
||
897 | } |
||
898 | if (settings.do_vibra) |
||
899 | root.vibrate(100); |
||
900 | } |
||
901 | } |
||
902 | |||
903 | if (mk.is_navi()) |
||
904 | { |
||
905 | if ((last_navi_error==0)&&(mk.gps_position.ErrorCode!=0)) |
||
906 | { |
||
907 | if (settings.instant_error_show) |
||
908 | { |
||
909 | nextstate=state; |
||
910 | |||
911 | act_msg=null; |
||
912 | chg_state( STATEID_ERROR_MSG); |
||
913 | } |
||
914 | if (settings.do_vibra) |
||
915 | root.vibrate(100); |
||
916 | } |
||
917 | else |
||
918 | if ((last_navi_error!=0)&&(mk.gps_position.ErrorCode==0)&&(state== STATEID_ERROR_MSG)) |
||
919 | chg_state(nextstate); |
||
920 | else if (last_navi_error!=mk.gps_position.ErrorCode) |
||
921 | act_msg=null; |
||
922 | last_navi_error=(byte)mk.gps_position.ErrorCode; |
||
923 | } |
||
924 | |||
206 | ligi | 925 | } |
926 | |||
382 | ligi | 927 | switch(state) |
266 | ligi | 928 | { |
382 | ligi | 929 | |
930 | //#if fileapi=="on" |
||
931 | case STATEID_FILEOPEN: |
||
932 | file_access.refresh_if_dirty(); |
||
933 | break; |
||
934 | //#endif |
||
935 | |||
936 | |||
937 | case STATEID_GET_AVRSIG: |
||
938 | if (firmware_flasher.job_done) |
||
267 | ligi | 939 | { |
382 | ligi | 940 | fw_loader=new FirmwareLoader(firmware_flasher.avr_sig,this); |
941 | firmware_flasher.exit_bootloader(); |
||
942 | firmware_flasher=null; |
||
943 | chg_state(STATEID_SELECT_FIRMWARE); |
||
267 | ligi | 944 | } |
382 | ligi | 945 | break; |
267 | ligi | 946 | |
382 | ligi | 947 | case STATEID_FLASHING: |
948 | if (firmware_flasher.job_done) |
||
266 | ligi | 949 | { |
382 | ligi | 950 | |
951 | if (firmware_flasher.success) |
||
267 | ligi | 952 | { |
382 | ligi | 953 | nextstate=STATEID_MAINMENU; |
954 | act_msg="Flashing OK"; |
||
955 | chg_state(STATEID_SUCCESS_MSG); |
||
267 | ligi | 956 | } |
382 | ligi | 957 | else |
958 | { |
||
959 | nextstate=STATEID_MAINMENU; |
||
960 | act_msg="Flashing Fail"; |
||
961 | chg_state(STATEID_ERROR_MSG); |
||
962 | } |
||
963 | |||
266 | ligi | 964 | } |
382 | ligi | 965 | |
966 | |||
967 | break; |
||
266 | ligi | 968 | |
969 | |||
382 | ligi | 970 | //#if (location=="on")&&(cldc11=="on") |
255 | ligi | 971 | |
261 | ligi | 972 | case STATEID_SHOWPHONEGPS: |
267 | ligi | 973 | |
261 | ligi | 974 | try |
975 | { |
||
382 | ligi | 976 | // Class.forName("javax.microedition.location.LocationProvider"); |
261 | ligi | 977 | |
382 | ligi | 978 | if ((lp==null)) |
979 | // if ((cr==null)||(lp==null)) |
||
267 | ligi | 980 | { |
382 | ligi | 981 | //Criteria cr= new Criteria(); |
982 | //cr.setHorizontalAccuracy(500); |
||
261 | ligi | 983 | |
267 | ligi | 984 | // Get an instance of the provider |
382 | ligi | 985 | // LocationProvider lp= LocationProvider.getInstance(cr); |
986 | lp= LocationProvider.getInstance(null); |
||
987 | lp.setLocationListener(this, 1, -1, -1); |
||
988 | |||
267 | ligi | 989 | } |
990 | // Request the location, setting a one-minute timeout |
||
991 | |||
382 | ligi | 992 | else if (false){ |
261 | ligi | 993 | |
382 | ligi | 994 | Location l = lp.getLocation(10); |
995 | c = l.getQualifiedCoordinates(); |
||
261 | ligi | 996 | |
267 | ligi | 997 | |
382 | ligi | 998 | |
261 | ligi | 999 | /* low crit |
1000 | |||
1001 | Criteria crit2 = new Criteria(); |
||
1002 | crit2.setHorizontalAccuracy(Criteria.NO_REQUIREMENT); |
||
1003 | crit2.setVerticalAccuracy(Criteria.NO_REQUIREMENT); |
||
1004 | crit2.setPreferredResponseTime(Criteria.NO_REQUIREMENT); |
||
1005 | crit2.setPreferredPowerConsumption(Criteria.POWER_USAGE_HIGH); |
||
1006 | crit2.setCostAllowed(false); |
||
1007 | crit2.setSpeedAndCourseRequired(false); |
||
1008 | crit2.setAltitudeRequired(false); |
||
1009 | lp= LocationProvider.getInstance(crit2); |
||
1010 | |||
1011 | */ |
||
262 | ligi | 1012 | |
261 | ligi | 1013 | if(c != null ) { |
1014 | // Use coordinate information |
||
264 | ligi | 1015 | //#if cldc11=="on" |
266 | ligi | 1016 | |
261 | ligi | 1017 | phone_lat= c.getLatitude(); |
1018 | phone_long = c.getLongitude(); |
||
264 | ligi | 1019 | //#endif |
261 | ligi | 1020 | } |
382 | ligi | 1021 | } |
261 | ligi | 1022 | } |
1023 | catch (Exception e) |
||
1024 | { |
||
382 | ligi | 1025 | debug.log("Follow ME Err" ); |
1026 | debug.log("-" + e ); |
||
1027 | debug.log("-" + e.getMessage() ); |
||
1028 | // act_msg="Phone GPS Problem"; |
||
1029 | // chg_state(STATEID_ERROR_MSG); |
||
261 | ligi | 1030 | |
1031 | } |
||
1032 | |||
1033 | break; |
||
266 | ligi | 1034 | |
1035 | //#endif |
||
255 | ligi | 1036 | case STATEID_SELECT_FIRMWARE: |
382 | ligi | 1037 | |
1038 | |||
1039 | // if ((menu_items.length==0)&&(fw_loader.got_list)) |
||
1040 | // setup_menu(fw_loader.names,null); |
||
255 | ligi | 1041 | |
382 | ligi | 1042 | |
1043 | break; |
||
1044 | |||
224 | ligi | 1045 | case STATEID_RESET_PARAMS: |
382 | ligi | 1046 | // if (mk.bootloader_finish_ok) |
1047 | if (firmware_flasher.job_done) |
||
224 | ligi | 1048 | { |
382 | ligi | 1049 | // mk.params.reset(); |
1050 | //mk.watchdog.act_paramset=0; |
||
224 | ligi | 1051 | nextstate=STATEID_PARAM_MENU; |
382 | ligi | 1052 | act_msg=l(STRINGID_PARAMRESETOK); |
1053 | firmware_flasher.exit_bootloader(); |
||
1054 | firmware_flasher=null; |
||
224 | ligi | 1055 | chg_state(STATEID_SUCCESS_MSG); |
1056 | } |
||
1057 | break; |
||
262 | ligi | 1058 | |
1059 | /* |
||
221 | ligi | 1060 | case STATEID_GRAPH: |
262 | ligi | 1061 | |
1062 | |||
221 | ligi | 1063 | graph_offset--; |
1064 | if (graph_offset==-graph_data[0].length) |
||
1065 | graph_offset=0; |
||
1066 | break; |
||
262 | ligi | 1067 | */ |
206 | ligi | 1068 | case STATEID_CAMMODE: |
211 | ligi | 1069 | |
1070 | try |
||
1071 | { |
||
1072 | if(cam_condition()) |
||
1073 | { |
||
206 | ligi | 1074 | cam_img=null; |
1075 | debug.log("get snap\n"); |
||
382 | ligi | 1076 | //xda cam_raw = mVideoControl.getSnapshot(null); |
211 | ligi | 1077 | |
221 | ligi | 1078 | |
206 | ligi | 1079 | try { Thread.sleep(4000); } |
1080 | catch (Exception e) |
||
1081 | { |
||
1082 | debug.log("Problem Sleeping "); |
||
211 | ligi | 1083 | |
206 | ligi | 1084 | } |
221 | ligi | 1085 | cam_img = Image.createImage(cam_raw, 0, cam_raw.length); |
211 | ligi | 1086 | } |
1087 | else |
||
1088 | { |
||
1089 | if (cam_img==null) |
||
221 | ligi | 1090 | ;; |
211 | ligi | 1091 | } |
1092 | } |
||
1093 | catch ( Exception e) |
||
1094 | { |
||
1095 | debug.log(e.toString()); |
||
1096 | } |
||
206 | ligi | 1097 | break; |
1098 | case STATEID_KEYCONTROL: |
||
219 | ligi | 1099 | //mk.send_keys(keycontrol_bitfield); |
206 | ligi | 1100 | break; |
211 | ligi | 1101 | |
224 | ligi | 1102 | |
1103 | case STATEID_ERROR_MSG: |
||
382 | ligi | 1104 | lcd_lines[0]=""+act_msg; |
206 | ligi | 1105 | break; |
211 | ligi | 1106 | |
252 | ligi | 1107 | |
1108 | case STATEID_PARAM_MASSWRITE: |
||
1109 | |||
1110 | if (param_masswrite_write_pos==5) |
||
1111 | { |
||
1112 | nextstate=STATEID_PARAM_MENU; |
||
382 | ligi | 1113 | act_msg=l(STRINGID_PARAMWRITEOK); |
252 | ligi | 1114 | chg_state(STATEID_SUCCESS_MSG); |
1115 | } |
||
1116 | else |
||
1117 | { |
||
1118 | if (param_masswrite_write_pos!=0) |
||
1119 | try { Thread.sleep(2000); } |
||
1120 | catch (Exception e) |
||
1121 | {debug.log("Problem Sleeping "); } |
||
1122 | |||
261 | ligi | 1123 | lcd_lines[0]=l(STRINGID_WRITINGPARAMS); |
252 | ligi | 1124 | lcd_lines[1]=DUBwiseHelper.pound_progress(param_masswrite_write_pos,5); |
1125 | |||
1126 | |||
1127 | mk.params.set_by_mk_data(params2masswrite[param_masswrite_write_pos]); |
||
1128 | mk.params.act_paramset=param_masswrite_write_pos; |
||
1129 | mk.write_params(mk.params.act_paramset); |
||
1130 | |||
1131 | param_masswrite_write_pos++; |
||
1132 | } |
||
1133 | break; |
||
206 | ligi | 1134 | case STATEID_READ_PARAMS: |
1135 | if (mk.watchdog.act_paramset==5) |
||
223 | ligi | 1136 | { |
242 | ligi | 1137 | if (read_paramset_intension_save) |
1138 | { |
||
1139 | |||
1140 | try |
||
1141 | { |
||
1142 | RecordStore.deleteRecordStore( PARAM_SAVE_STORE_NAME); |
||
1143 | } |
||
1144 | catch (Exception e) |
||
1145 | { } |
||
1146 | |||
1147 | try { |
||
1148 | RecordStore recStore = RecordStore.openRecordStore( PARAM_SAVE_STORE_NAME, true ); |
||
1149 | |||
1150 | ByteArrayOutputStream bout = new ByteArrayOutputStream(); |
||
1151 | DataOutputStream dout = new DataOutputStream( bout ); |
||
1152 | |||
1153 | // params_version |
||
1154 | dout.writeInt(mk.params.params_version); |
||
1155 | |||
1156 | // params_length |
||
1157 | dout.writeInt(mk.params.field_bak[0].length); |
||
1158 | |||
1159 | for (int p=0;p<5;p++) |
||
1160 | for (int i=0;i<mk.params.field_bak[0].length;i++) |
||
1161 | dout.writeInt(mk.params.field_bak[p][i]); |
||
1162 | |||
1163 | recStore.addRecord(bout.toByteArray(),0,bout.size()); |
||
1164 | recStore.closeRecordStore(); |
||
1165 | |||
1166 | |||
1167 | } |
||
1168 | catch (Exception e) |
||
1169 | { } |
||
1170 | // chg_state(STATEID_COPY_PARAMS); |
||
252 | ligi | 1171 | |
1172 | nextstate=STATEID_PARAM_MENU; |
||
382 | ligi | 1173 | act_msg="Parameter Copy OK"; |
242 | ligi | 1174 | chg_state(STATEID_SUCCESS_MSG); |
1175 | |||
1176 | } |
||
1177 | else |
||
1178 | { |
||
252 | ligi | 1179 | select_paramset4edit=true; |
242 | ligi | 1180 | chg_state(STATEID_SELECT_PARAMSET); |
252 | ligi | 1181 | |
242 | ligi | 1182 | } |
1183 | |||
223 | ligi | 1184 | } |
206 | ligi | 1185 | else |
1186 | { |
||
1187 | lcd_lines[0]="Reading Settings "; |
||
252 | ligi | 1188 | lcd_lines[1]=DUBwiseHelper.pound_progress(mk.watchdog.act_paramset,5); |
211 | ligi | 1189 | |
252 | ligi | 1190 | |
206 | ligi | 1191 | if (mk.params.found_incompatible) |
1192 | { |
||
382 | ligi | 1193 | act_msg="incompatible params"; |
224 | ligi | 1194 | chg_state(STATEID_ERROR_MSG); |
206 | ligi | 1195 | } |
211 | ligi | 1196 | |
206 | ligi | 1197 | } |
1198 | break; |
||
211 | ligi | 1199 | |
206 | ligi | 1200 | |
1201 | case STATEID_MOTORTEST: |
||
382 | ligi | 1202 | /* |
206 | ligi | 1203 | if (motor_test_sel_all) |
1204 | for (int m=0;m<4;m++) |
||
1205 | { |
||
1206 | motor_test[m]+=act_motor_increase; |
||
1207 | if (motor_test[m]<0)motor_test[m]=0; |
||
1208 | if (motor_test[m]>255)motor_test[m]=255; |
||
1209 | } |
||
1210 | else |
||
1211 | { |
||
1212 | motor_test[act_motor]+=act_motor_increase; |
||
1213 | if (motor_test[act_motor]<0) motor_test[act_motor]=0; |
||
1214 | if (motor_test[act_motor]>255) motor_test[act_motor]=255; |
||
1215 | } |
||
1216 | |||
382 | ligi | 1217 | mk.motor_test(motor_test);*/ |
1218 | mk.motor_test(motor_tester.engine_field); |
||
206 | ligi | 1219 | break; |
1220 | |||
213 | ligi | 1221 | case STATEID_STRINGINPUT: |
1222 | |||
1223 | lcd_lines[0]=act_input_str; |
||
1224 | for(int tmp_i=act_input_str.length();tmp_i<20;tmp_i++) |
||
1225 | lcd_lines[0]+=(char)(0); |
||
1226 | |||
1227 | lcd_lines[1]=""; |
||
1228 | for(int foo=0;foo<20;foo++) |
||
1229 | { |
||
1230 | if (foo==ipinput_pos) |
||
1231 | lcd_lines[1]+="^"; |
||
1232 | else |
||
1233 | lcd_lines[1]+=" "; |
||
1234 | } |
||
1235 | break; |
||
1236 | |||
1237 | |||
206 | ligi | 1238 | case STATEID_IPINPUT: |
1239 | if (ipinput4proxy) |
||
1240 | act_edit_ip=settings.act_proxy_ip; |
||
1241 | else |
||
1242 | act_edit_ip=settings.act_conn_ip; |
||
1243 | |||
223 | ligi | 1244 | lcd_lines[1]=DUBwiseHelper.ip_str(act_edit_ip,true); |
206 | ligi | 1245 | |
1246 | |||
1247 | lcd_lines[2]=""; |
||
1248 | for(int foo=0;foo<20;foo++) |
||
1249 | { |
||
1250 | if (foo==ipinput_pos) |
||
1251 | lcd_lines[2]+="^"; |
||
1252 | else |
||
1253 | lcd_lines[2]+=" "; |
||
1254 | } |
||
1255 | break; |
||
1256 | |||
1257 | case STATEID_MAINMENU: |
||
1258 | |||
1259 | break; |
||
1260 | |||
1261 | //#if bluetooth=="on" |
||
1262 | case STATEID_SCANNING: |
||
211 | ligi | 1263 | |
1264 | lcd_lines[1]="Bluetooth Devices " + idle_seq[(((frame_pos/5)%idle_seq.length))]; |
||
206 | ligi | 1265 | lcd_lines[2]="found " + bt_scanner.remote_device_count; |
1266 | |||
1267 | if (!bt_scanner.searching) |
||
1268 | chg_state(STATEID_DEVICESELECT); |
||
1269 | |||
1270 | break; |
||
1271 | //#endif |
||
1272 | |||
1273 | |||
1274 | } |
||
1275 | |||
1276 | if (quit) |
||
1277 | { |
||
266 | ligi | 1278 | // settings.speed_format=mk.gps_position.act_speed_format; |
1279 | //settings.gps_format=mk.gps_position.act_gps_format; |
||
206 | ligi | 1280 | settings.save(); |
1281 | root.quit(); |
||
1282 | } |
||
1283 | |||
221 | ligi | 1284 | |
206 | ligi | 1285 | //rescan=false; |
221 | ligi | 1286 | |
1287 | if (bg_img!=null) |
||
1288 | { |
||
1289 | bg_offset--; |
||
1290 | if (bg_offset==-bg_img.getWidth()) |
||
1291 | bg_offset=0; |
||
1292 | } |
||
1293 | |||
1294 | |||
1295 | |||
1296 | |||
206 | ligi | 1297 | //#if devicecontrol=="on" |
221 | ligi | 1298 | try { |
382 | ligi | 1299 | if (mk.connected&&settings.keep_lighton) com.nokia.mid.ui.DeviceControl.setLights(0,100); |
258 | ligi | 1300 | |
206 | ligi | 1301 | } |
382 | ligi | 1302 | catch (Exception e) |
1303 | { |
||
1304 | // cannot do anything helpfull here |
||
1305 | } |
||
258 | ligi | 1306 | //#endif |
206 | ligi | 1307 | |
1308 | sleeptime=1000/ 15 - (int) (System.currentTimeMillis()- loopStartTime); |
||
1309 | |||
1310 | if (sleeptime<0) |
||
1311 | sleeptime=100; // everyone has fi sleep |
||
1312 | |||
1313 | try { Thread.sleep(sleeptime); } |
||
1314 | catch (Exception e) |
||
1315 | { |
||
1316 | debug.log("Problem Sleeping "); |
||
1317 | } |
||
1318 | |||
1319 | } |
||
1320 | catch (Exception e) |
||
1321 | { |
||
1322 | debug.log("E!:"+e.getMessage()); |
||
1323 | |||
1324 | } |
||
1325 | } |
||
1326 | } |
||
1327 | |||
1328 | |||
1329 | |||
1330 | boolean firstrun=true; |
||
1331 | |||
1332 | public int skin_bg_color() |
||
1333 | { |
||
1334 | |||
1335 | switch (settings.act_skin) |
||
1336 | { |
||
1337 | case SKINID_DARK: |
||
252 | ligi | 1338 | return BG_COLOR_SKIN_DARK; |
206 | ligi | 1339 | |
1340 | default: |
||
1341 | case SKINID_LIGHT: |
||
252 | ligi | 1342 | return BG_COLOR_SKIN_LIGHT; |
206 | ligi | 1343 | } |
1344 | } |
||
1345 | |||
1346 | |||
1347 | public int skin_fg_color() |
||
1348 | { |
||
1349 | |||
1350 | switch (settings.act_skin) |
||
1351 | { |
||
1352 | case SKINID_DARK: |
||
252 | ligi | 1353 | return FG_COLOR_SKIN_DARK; |
206 | ligi | 1354 | |
1355 | default: |
||
1356 | case SKINID_LIGHT: |
||
252 | ligi | 1357 | return FG_COLOR_SKIN_LIGHT; |
206 | ligi | 1358 | } |
1359 | } |
||
1360 | |||
262 | ligi | 1361 | /* |
223 | ligi | 1362 | public int check_local_max(int val) |
1363 | { |
||
1364 | if ( val>local_max) |
||
1365 | local_max=val; |
||
1366 | else if (-val>local_max) |
||
1367 | local_max=-val; |
||
1368 | return val; |
||
1369 | } |
||
262 | ligi | 1370 | */ |
242 | ligi | 1371 | |
1372 | |||
493 | ligi | 1373 | public byte big_symbol_by_pos(byte pos) |
1374 | { |
||
1375 | switch(pos) |
||
1376 | { |
||
242 | ligi | 1377 | |
493 | ligi | 1378 | case 0: |
1379 | if (mk.connected) |
||
1380 | return (byte)((((mk.stats.bytes_in>>3)&1)==1)?2:3); |
||
1381 | |||
1382 | else |
||
1383 | { |
||
1384 | if (mk.mk_url.startsWith("btspp://")) |
||
1385 | return 1; |
||
1386 | else return 29; |
||
1387 | |||
1388 | |||
1389 | } |
||
1390 | |||
1391 | |||
1392 | case 1: |
||
1393 | if (mk.SenderOkay()>0) |
||
1394 | return 6; |
||
1395 | else |
||
1396 | return 29; |
||
1397 | |||
1398 | |||
1399 | case 5: |
||
1400 | return 4; |
||
1401 | |||
1402 | case 6: |
||
1403 | if ( mk.UBatt()==-1) |
||
1404 | return 29; |
||
1405 | else |
||
1406 | return (byte)(mk.UBatt()/100+10); |
||
1407 | |||
1408 | |||
1409 | case 7: |
||
1410 | if ( mk.UBatt()==-1) |
||
1411 | return 29; |
||
1412 | else |
||
1413 | return (byte)((mk.UBatt()/10)%10+10); |
||
1414 | |||
1415 | case 8: |
||
1416 | if ( mk.UBatt()==-1) |
||
1417 | return 29; |
||
1418 | else |
||
1419 | return 9; |
||
1420 | |||
1421 | case 9: |
||
1422 | if ( mk.UBatt()==-1) |
||
1423 | return 29; |
||
1424 | else |
||
1425 | return (byte)((mk.UBatt())%10+10); |
||
1426 | |||
1427 | |||
1428 | case 10: |
||
1429 | return (byte)(((mk.stats.flying_time()/60)/10)%10+10); |
||
1430 | case 11: |
||
1431 | return (byte)(((mk.stats.flying_time()/60))%10+10); |
||
1432 | |||
1433 | case 12: |
||
1434 | return 23; |
||
1435 | |||
1436 | case 13: |
||
1437 | return (byte)(((mk.stats.flying_time()%60)/10)%10+10); |
||
1438 | case 14: |
||
1439 | return (byte)(((mk.stats.flying_time()%60))%10+10); |
||
1440 | |||
1441 | case 15: |
||
1442 | return (byte)((mk.Alt()/10000)%10+10); |
||
1443 | |||
1444 | case 16: |
||
1445 | return (byte)((mk.Alt()/1000)%10+10); |
||
1446 | |||
1447 | case 17: |
||
1448 | return (byte)((mk.Alt()/100)%10+10); |
||
1449 | case 18: |
||
1450 | return (byte)((mk.Alt()/10)%10+10); |
||
1451 | |||
1452 | case 19: |
||
1453 | return (byte)((mk.Alt())%10+10); |
||
1454 | |||
1455 | default: |
||
1456 | return 29; |
||
1457 | |||
1458 | } |
||
1459 | } |
||
1460 | public void big_symbol_paint(Graphics g,byte x,byte y,byte tile) |
||
1461 | { |
||
1462 | int big_symbols_tile_width=big_symbols_img.getWidth()/10; |
||
1463 | int big_symbols_tile_height=big_symbols_img.getHeight()/3; |
||
1464 | |||
1465 | byte tile_y=(byte)(tile/10); |
||
1466 | tile%=10; |
||
1467 | |||
1468 | g.setClip(x*big_symbols_tile_width,y*big_symbols_tile_height,(big_symbols_tile_width),big_symbols_tile_height); |
||
1469 | g.drawImage(big_symbols_img,x*big_symbols_tile_width+(-tile)*(big_symbols_tile_width),(y-tile_y)*(big_symbols_tile_height), g.TOP | g.LEFT); |
||
1470 | } |
||
1471 | |||
242 | ligi | 1472 | public void symbol_paint(Graphics g,int x,int tile,int row) |
1473 | { |
||
1474 | g.setClip(x,0,(symbols_img_tile_width),symbols_img_tile_height);; |
||
1475 | g.drawImage(symbols_img,x+(-tile)*(symbols_img_tile_width),row*(-symbols_img_tile_height), g.TOP | g.LEFT); |
||
1476 | } |
||
1477 | |||
1478 | |||
382 | ligi | 1479 | Font font_medium,font_small,font_large; |
242 | ligi | 1480 | |
1481 | |||
382 | ligi | 1482 | |
1483 | boolean regenerate_fonts=true; |
||
242 | ligi | 1484 | // drawing sections |
206 | ligi | 1485 | public void paint(Graphics g) { |
1486 | |||
1487 | canvas_width=this.getWidth(); |
||
1488 | canvas_height=this.getHeight(); |
||
1489 | |||
1490 | if (debug.showing) |
||
1491 | { |
||
1492 | debug.paint(g); |
||
1493 | return; |
||
1494 | } |
||
1495 | |||
382 | ligi | 1496 | |
206 | ligi | 1497 | if (firstrun) |
1498 | { |
||
1499 | if (settings.fullscreen) setFullScreenMode(settings.fullscreen); |
||
1500 | firstrun=false; |
||
1501 | } |
||
382 | ligi | 1502 | |
1503 | if (regenerate_fonts) |
||
1504 | { |
||
1505 | if (settings.big_fonts) |
||
1506 | { |
||
1507 | font_small = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_LARGE); |
||
1508 | font_medium = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_LARGE); |
||
1509 | font_large = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE); |
||
1510 | |||
1511 | } |
||
1512 | else |
||
1513 | { |
||
1514 | font_small = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL); |
||
1515 | font_medium = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM); |
||
1516 | font_large = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE); |
||
1517 | } |
||
1518 | |||
1519 | spacer_medium=(font_medium.getHeight()); |
||
1520 | spacer_small=(font_small.getHeight()); |
||
1521 | spacer_large=(font_large.getHeight()); |
||
1522 | regenerate_fonts=false; |
||
1523 | } |
||
1524 | |||
206 | ligi | 1525 | y_off=0; |
252 | ligi | 1526 | |
206 | ligi | 1527 | try { |
222 | ligi | 1528 | |
206 | ligi | 1529 | |
1530 | //default Font |
||
265 | ligi | 1531 | g.setFont(font_medium); |
206 | ligi | 1532 | |
1533 | |||
1534 | //draw background |
||
382 | ligi | 1535 | if ((settings.do_scrollbg)&&(bg_img!=null)) |
206 | ligi | 1536 | { |
1537 | g.setColor(0xFFFFFF); |
||
1538 | g.fillRect(0,0,canvas_width,canvas_height); |
||
1539 | g.drawImage(bg_img,bg_offset,0, g.TOP | g.LEFT); |
||
1540 | |||
1541 | if (bg_offset+bg_img.getWidth()<canvas_width) |
||
242 | ligi | 1542 | g.drawImage(bg_img,bg_offset+bg_img.getWidth(),0, g.TOP | g.LEFT); |
1543 | |||
206 | ligi | 1544 | } |
242 | ligi | 1545 | else |
1546 | { |
||
1547 | g.setColor(0xdedfff); |
||
1548 | g.fillRect(0,0,canvas_width,symbols_img_tile_height); |
||
206 | ligi | 1549 | |
242 | ligi | 1550 | g.setColor(skin_bg_color()); |
255 | ligi | 1551 | g.fillRect(0,symbols_img_tile_height,canvas_width,canvas_height-symbols_img_tile_height); |
242 | ligi | 1552 | } |
206 | ligi | 1553 | |
242 | ligi | 1554 | |
206 | ligi | 1555 | //int bar=0; |
1556 | // for ( int bar=0;bar<3;bar++) |
||
1557 | if (settings.do_scrollbg) |
||
1558 | for ( int bar=0;bar<canvas_width/(symbols_img.getWidth()/10)+1;bar++) |
||
1559 | { |
||
242 | ligi | 1560 | g.setClip(bar*(symbols_img_tile_width),0,(symbols_img_tile_width),symbols_img_tile_height);; |
1561 | g.drawImage(symbols_img,bar*(symbols_img_tile_width),0, g.TOP | g.LEFT); |
||
382 | ligi | 1562 | |
206 | ligi | 1563 | } |
1564 | |||
382 | ligi | 1565 | if (mk!=null) |
252 | ligi | 1566 | { |
382 | ligi | 1567 | int symbol_left=0; |
1568 | int symbol_spacer=5; |
||
252 | ligi | 1569 | |
382 | ligi | 1570 | |
1571 | |||
493 | ligi | 1572 | // g.setClip(symbol_left,0,symbols_img_tile_width,symbols_img_tile_height);; |
382 | ligi | 1573 | if (mk.connected) |
1574 | symbol_paint(g,symbol_left,(((mk.stats.bytes_in>>3)&1)==1)?2:3,0); |
||
206 | ligi | 1575 | |
382 | ligi | 1576 | else |
242 | ligi | 1577 | { |
382 | ligi | 1578 | if (mk.mk_url.startsWith("btspp://")) |
1579 | symbol_paint(g,symbol_left,1,0); |
||
1580 | |||
1581 | |||
242 | ligi | 1582 | } |
382 | ligi | 1583 | // g.drawImage(symbols_img,(-1)*(symbols_img.getWidth()/10),0, g.TOP | g.LEFT); |
1584 | |||
1585 | |||
1586 | |||
242 | ligi | 1587 | symbol_left+=6*(symbols_img_tile_width)/4; |
382 | ligi | 1588 | |
1589 | |||
1590 | if (mk.UBatt()!=-1) |
||
1591 | { |
||
1592 | |||
1593 | symbol_paint(g,symbol_left,4,0); |
||
1594 | symbol_left+=5 *(symbols_img_tile_width)/4; |
||
1595 | |||
1596 | if ((mk.UBatt()/100)!=0) |
||
1597 | { |
||
1598 | symbol_paint(g,symbol_left,(mk.UBatt()/100),1); |
||
1599 | symbol_left+=(symbols_img_tile_width); |
||
1600 | } |
||
1601 | |||
1602 | symbol_paint(g,symbol_left,(mk.UBatt()/10)%10,1); |
||
1603 | symbol_left+=(2*symbols_img_tile_width/3); |
||
1604 | symbol_paint(g,symbol_left,9,0); |
||
1605 | symbol_left+=(2*symbols_img_tile_width/3); |
||
1606 | symbol_paint(g,symbol_left,(mk.UBatt())%10,1); |
||
1607 | symbol_left+=6*(symbols_img_tile_width)/4; |
||
1608 | |||
1609 | |||
1610 | // g.drawString("" + (mk.UBatt()/10) + "," +(mk.UBatt()%10)+"V" , symbol_left,y_off,Graphics.TOP | Graphics.LEFT); |
||
1611 | |||
1612 | |||
1613 | //symbol_left+= g.getFont().stringWidth("88,8V");//; |
||
1614 | /* |
||
1615 | symbol_paint(g,symbol_left,6,0); |
||
1616 | symbol_left+=5*(symbols_img_tile_width)/4; |
||
1617 | */ |
||
1618 | } |
||
252 | ligi | 1619 | if (mk.SenderOkay()>0) |
245 | ligi | 1620 | { |
252 | ligi | 1621 | symbol_paint(g,symbol_left,6,0); |
1622 | symbol_left+=5*(symbols_img_tile_width)/4; |
||
382 | ligi | 1623 | |
1624 | /*symbol_paint(g,symbol_left,(mk.SenderOkay())/100,1); |
||
1625 | symbol_left+=(symbols_img_tile_width); |
||
1626 | |||
1627 | symbol_paint(g,symbol_left,(mk.SenderOkay()/10)%10,1); |
||
1628 | symbol_left+=(symbols_img_tile_width);*/ |
||
1629 | } |
||
1630 | // symbol_paint(g,symbol_left,(mk.SenderOkay())%10,1); |
||
1631 | //symbol_left+=6*(symbols_img_tile_width)/4; |
||
252 | ligi | 1632 | |
382 | ligi | 1633 | // g.drawString(""+mk.SenderOkay() ,symbol_left,y_off,Graphics.TOP | Graphics.LEFT); |
1634 | |||
1635 | |||
1636 | //symbol_left+= g.getFont().stringWidth("8")+symbol_spacer_medium; //,0,(symbols_img.getWidth()/10)+2; |
||
1637 | |||
206 | ligi | 1638 | |
1639 | |||
1640 | |||
382 | ligi | 1641 | if (mk.is_navi()) |
206 | ligi | 1642 | { |
266 | ligi | 1643 | if (mk.gps_position.ErrorCode!=0) |
1644 | { |
||
1645 | symbol_paint(g,symbol_left,7,0); |
||
1646 | symbol_left+=5*(symbols_img_tile_width)/4; |
||
1647 | } |
||
382 | ligi | 1648 | |
266 | ligi | 1649 | if ((mk.gps_position.NCFlags&2)!=0) |
1650 | { |
||
1651 | symbol_paint(g,symbol_left,8,0); |
||
1652 | symbol_left+=5*(symbols_img_tile_width)/4; |
||
1653 | } |
||
382 | ligi | 1654 | |
1655 | |||
266 | ligi | 1656 | if ((mk.gps_position.NCFlags&4)!=0) |
1657 | { |
||
1658 | symbol_paint(g,symbol_left,0,2); |
||
1659 | symbol_left+=5*(symbols_img_tile_width)/4; |
||
382 | ligi | 1660 | |
266 | ligi | 1661 | } |
382 | ligi | 1662 | |
266 | ligi | 1663 | if ((mk.gps_position.NCFlags&8)!=0) |
1664 | { |
||
1665 | symbol_paint(g,symbol_left,0,2); |
||
1666 | symbol_left+=5*(symbols_img_tile_width)/4; |
||
382 | ligi | 1667 | |
266 | ligi | 1668 | } |
382 | ligi | 1669 | |
1670 | |||
1671 | } |
||
1672 | |||
1673 | |||
1674 | if (mk.SatsInUse()!=-1) |
||
1675 | { |
||
242 | ligi | 1676 | symbol_paint(g,symbol_left,5,0); |
1677 | symbol_left+=5*(symbols_img_tile_width)/4; |
||
382 | ligi | 1678 | |
1679 | symbol_paint(g,symbol_left,(mk.SatsInUse())%10,1); |
||
242 | ligi | 1680 | symbol_left+=6*(symbols_img_tile_width)/4; |
382 | ligi | 1681 | |
206 | ligi | 1682 | } |
1683 | |||
1684 | |||
382 | ligi | 1685 | } // if mk!=null |
1686 | // unclip |
||
206 | ligi | 1687 | g.setClip(0,0,canvas_width,canvas_height); |
382 | ligi | 1688 | |
242 | ligi | 1689 | y_off+=symbols_img_tile_height; |
229 | ligi | 1690 | graph_height=(canvas_height-y_off)/2; |
1691 | line_middle_y=graph_height+y_off; |
||
206 | ligi | 1692 | g.setColor(skin_fg_color()); |
1693 | |||
1694 | switch(state) |
||
1695 | { |
||
382 | ligi | 1696 | //#if j2memap=="on" |
1697 | case STATEID_MAP: |
||
1698 | |||
1699 | root.m_map.paint(g); |
||
1700 | break; |
||
1701 | //#endif |
||
222 | ligi | 1702 | case STATEID_HORIZON: |
206 | ligi | 1703 | |
222 | ligi | 1704 | g.setStrokeStyle(Graphics.SOLID); |
1705 | g.setColor(0x6e4e1d); |
||
206 | ligi | 1706 | |
222 | ligi | 1707 | int horizon_height=(canvas_height-y_off)/2; |
1708 | int horizon_middle=y_off+horizon_height; |
||
1709 | |||
1710 | |||
266 | ligi | 1711 | int horizon_roll_pixels= ((mk.AngleRoll()*horizon_height)/600) * (settings.horizon_invert_roll?-1:1); |
222 | ligi | 1712 | |
1713 | int nick_bar_width=canvas_width/4; |
||
1714 | int nick_bar_height= nick_bar_width/2; |
||
1715 | |||
1716 | |||
1717 | int nick_size=canvas_width/4; |
||
266 | ligi | 1718 | int nick_pixels_y=((mk.AngleNick()*horizon_height)/900) * (settings.horizon_invert_nick?-1:1);; |
222 | ligi | 1719 | |
1720 | int nick_pixels_x; |
||
264 | ligi | 1721 | if ((mk.AngleRoll()*mk.AngleNick())>1) |
1722 | nick_pixels_x=-((int)Math.sqrt(mk.AngleRoll()*mk.AngleNick())*(canvas_width/2))/(900); |
||
222 | ligi | 1723 | else |
264 | ligi | 1724 | nick_pixels_x=((int)Math.sqrt(-mk.AngleRoll()*mk.AngleNick())*(canvas_width/2))/(900); |
222 | ligi | 1725 | |
265 | ligi | 1726 | |
266 | ligi | 1727 | if (horizon_roll_pixels>0) |
265 | ligi | 1728 | |
222 | ligi | 1729 | { |
265 | ligi | 1730 | |
1731 | g.fillTriangle(0,horizon_middle+horizon_roll_pixels,canvas_width,horizon_middle+horizon_roll_pixels,canvas_width,horizon_middle-horizon_roll_pixels); |
||
266 | ligi | 1732 | g.fillRect(0,horizon_middle+horizon_roll_pixels,canvas_width,canvas_height-(horizon_middle+horizon_roll_pixels)); |
265 | ligi | 1733 | } |
1734 | else |
||
1735 | { |
||
1736 | |||
266 | ligi | 1737 | g.fillTriangle(0,horizon_middle+horizon_roll_pixels,0,horizon_middle-horizon_roll_pixels,canvas_width,horizon_middle-horizon_roll_pixels); |
1738 | g.fillRect(0,horizon_middle-horizon_roll_pixels,canvas_width,canvas_height-(horizon_middle-horizon_roll_pixels)); |
||
265 | ligi | 1739 | } |
1740 | |||
1741 | |||
1742 | |||
222 | ligi | 1743 | |
1744 | g.setColor(0x254d9e); |
||
265 | ligi | 1745 | |
1746 | |||
222 | ligi | 1747 | g.fillArc((canvas_width-nick_size)/2- nick_pixels_x, horizon_middle-nick_size/2+ nick_pixels_y, nick_size, nick_size, 0,360); |
1748 | |||
265 | ligi | 1749 | |
382 | ligi | 1750 | if (mk.is_navi()) |
265 | ligi | 1751 | { |
1752 | g.setColor(0xCC2233); |
||
1753 | 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); |
||
1754 | } |
||
1755 | |||
1756 | |||
1757 | |||
222 | ligi | 1758 | // for (i=0;i<horizon_roll_pixels |
1759 | // g.fillArc(0, 0, canvas_width, canvas_width, 0,45); |
||
1760 | |||
1761 | /* |
||
1762 | int start_angle=(360+mk.gps_position.angle2wp(act_wp) - ((360+mk.debug_data.analog[26]-heading_offset)%360))%360; |
||
1763 | // start_angle=0; |
||
1764 | start_angle=(360-start_angle +90 -(45/2))%360; |
||
1765 | |||
1766 | g.fillArc(0, 0, canvas_width, canvas_width, start_angle,45); |
||
1767 | */ |
||
1768 | // g.drawArc(1, 1, canvas_width-2, canvas_width-2, start_angle,45); |
||
1769 | // g.drawArc(2, 2, canvas_width-4, canvas_width-4, start_angle ,45); |
||
1770 | |||
1771 | |||
1772 | g.setColor(skin_fg_color()); |
||
1773 | |||
1774 | |||
1775 | if (settings.expert_mode) |
||
1776 | { |
||
264 | ligi | 1777 | g.drawString("nick => " + mk.AngleNick(),0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 1778 | y_off+=spacer_medium; |
222 | ligi | 1779 | |
264 | ligi | 1780 | g.drawString("roll => " + mk.AngleRoll(),0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 1781 | y_off+=spacer_medium; |
222 | ligi | 1782 | } |
265 | ligi | 1783 | |
1784 | |||
1785 | |||
1786 | for (int c=0;c<2;c++) |
||
1787 | { |
||
1788 | if (c==0) |
||
1789 | g.setColor(0); |
||
1790 | else |
||
1791 | g.setColor(0xFFFFFF); |
||
1792 | |||
266 | ligi | 1793 | y_off=canvas_height-5; |
1794 | |||
1795 | |||
1796 | |||
1797 | g.setFont(font_small); |
||
382 | ligi | 1798 | if (mk.is_navi()) |
266 | ligi | 1799 | g.drawString("avg:" + mk.stats.avg_speed() + " max:"+ mk.stats.max_speed,10-c,y_off-c,Graphics.BOTTOM | Graphics.LEFT); |
265 | ligi | 1800 | |
266 | ligi | 1801 | g.drawString(" max:"+ mk.stats.max_alt/10,canvas_width-10-c,y_off-c,Graphics.BOTTOM | Graphics.RIGHT); |
1802 | |||
1803 | y_off-=spacer_small; |
||
1804 | |||
265 | ligi | 1805 | g.setFont(font_large); |
1806 | |||
266 | ligi | 1807 | |
382 | ligi | 1808 | if (mk.is_navi()) |
266 | ligi | 1809 | g.drawString("" + mk.gps_position.GroundSpeed_str() ,10-c*3,y_off-c*3,Graphics.BOTTOM | Graphics.LEFT); |
265 | ligi | 1810 | else |
266 | ligi | 1811 | if (settings.horizon_display_flytime) g.drawString("" + mk.stats.flying_time()+"s" ,10-c*3,y_off-c*3,Graphics.BOTTOM | Graphics.LEFT); |
265 | ligi | 1812 | |
266 | ligi | 1813 | if (settings.horizon_display_altitude) g.drawString( mk.Alt_formated()/* + "/"+status_voice.last_alt*/ ,canvas_width-10-c*3,y_off-c*3,Graphics.BOTTOM | Graphics.RIGHT); |
265 | ligi | 1814 | |
266 | ligi | 1815 | y_off-=spacer_large; |
382 | ligi | 1816 | if (mk.is_navi()&&(settings.horizon_display_flytime)) |
265 | ligi | 1817 | { |
1818 | g.setFont(font_medium); |
||
266 | ligi | 1819 | g.drawString("" + mk.stats.flying_time()+"s" ,10-c*2,y_off-c*2,Graphics.BOTTOM | Graphics.LEFT); |
265 | ligi | 1820 | } |
266 | ligi | 1821 | |
265 | ligi | 1822 | } |
1823 | |||
222 | ligi | 1824 | break; |
1825 | |||
382 | ligi | 1826 | case STATEID_DUBWISE_VALUES: |
1827 | |||
1828 | g.setFont(font_small); |
||
1829 | |||
1830 | //#if voice_mode!="no_voice" |
||
1831 | g.drawString("voice_loop_cnt"+status_voice.loop_cnt ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1832 | y_off+=spacer_small; |
||
1833 | |||
1834 | g.drawString("voice_volts_cnt"+ status_voice.volts_play_cnt ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1835 | y_off+=spacer_small; |
||
1836 | |||
1837 | g.drawString("do volts sound"+ settings.do_volts_sound ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1838 | y_off+=spacer_small; |
||
1839 | //#endif |
||
1840 | break; |
||
206 | ligi | 1841 | case STATEID_DATABUFF: |
382 | ligi | 1842 | |
265 | ligi | 1843 | g.setFont(font_small); |
206 | ligi | 1844 | |
265 | ligi | 1845 | int lines2paint=(((canvas_height-y_off)/spacer_small)); |
1846 | y_off=canvas_height-spacer_small; |
||
206 | ligi | 1847 | |
245 | ligi | 1848 | for (int pos_y=0;pos_y<lines2paint;pos_y++) |
206 | ligi | 1849 | { |
1850 | |||
1851 | g.drawString(mk.get_buff(pos_y) ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1852 | y_off-=spacer_small; |
206 | ligi | 1853 | } |
1854 | break; |
||
224 | ligi | 1855 | |
493 | ligi | 1856 | case STATEID_BIG_SYMBOLS: |
1857 | int act_tile=0; |
||
1858 | for (int sx=0;sx<5;sx++) |
||
1859 | for (int sy=0;sy<4;sy++) |
||
1860 | big_symbol_paint(g,(byte)sx,(byte)sy,big_symbol_by_pos((byte)(sx+sy*5) )); |
||
1861 | |||
1862 | |||
1863 | // g.drawImage(big_symbols_img,0,0, g.TOP | g.LEFT); |
||
1864 | break; |
||
224 | ligi | 1865 | case STATEID_SUCCESS_MSG: |
1866 | case STATEID_ERROR_MSG: |
||
214 | ligi | 1867 | if (err_img!=null) |
206 | ligi | 1868 | { |
1869 | int err_img_left=(canvas_width-err_img.getWidth()/2)/2; |
||
1870 | int err_img_top=(canvas_height-err_img.getHeight())/2; |
||
224 | ligi | 1871 | if (err_img_top<0)err_img_top=0; |
206 | ligi | 1872 | g.setClip(err_img_left,err_img_top,err_img.getWidth()/2,err_img.getHeight()); |
224 | ligi | 1873 | 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 | 1874 | } |
221 | ligi | 1875 | paint_lcd(g); |
206 | ligi | 1876 | |
224 | ligi | 1877 | break; |
206 | ligi | 1878 | |
1879 | case STATEID_GPSVIEW: |
||
1880 | |||
265 | ligi | 1881 | g.setFont(font_small); |
206 | ligi | 1882 | |
1883 | g.setStrokeStyle(Graphics.SOLID); |
||
1884 | g.setColor(0x0000ff); |
||
1885 | |||
1886 | |||
1887 | // g.fillArc(0, 0, canvas_width, canvas_width, 0,45); |
||
1888 | |||
1889 | /* |
||
1890 | int start_angle=(360+mk.gps_position.angle2wp(act_wp) - ((360+mk.debug_data.analog[26]-heading_offset)%360))%360; |
||
1891 | // start_angle=0; |
||
1892 | start_angle=(360-start_angle +90 -(45/2))%360; |
||
1893 | |||
1894 | g.fillArc(0, 0, canvas_width, canvas_width, start_angle,45); |
||
1895 | */ |
||
1896 | // g.drawArc(1, 1, canvas_width-2, canvas_width-2, start_angle,45); |
||
1897 | // g.drawArc(2, 2, canvas_width-4, canvas_width-4, start_angle ,45); |
||
1898 | |||
1899 | |||
1900 | g.setColor(skin_fg_color()); |
||
1901 | |||
1902 | g.drawString("Used Sats: " + mk.gps_position.SatsInUse + " | Packages: " + mk.stats.navi_data_count ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1903 | y_off+=spacer_small; |
206 | ligi | 1904 | |
266 | ligi | 1905 | g.drawString("Err: " + mk.gps_position.ErrorCode + " NC-Flags:" + mk.gps_position.NCFlags + " MK-Flags:" + mk.gps_position.MKFlags ,0,y_off,Graphics.TOP | Graphics.LEFT); |
1906 | y_off+=spacer_small; |
||
1907 | |||
206 | ligi | 1908 | g.drawString("Lat: " + mk.gps_position.Latitude_str() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 1909 | y_off+=spacer_small; |
206 | ligi | 1910 | |
1911 | g.drawString("Long: " + mk.gps_position.Longitude_str() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1912 | y_off+=spacer_small; |
206 | ligi | 1913 | |
1914 | g.drawString("Altitude: " + mk.gps_position.Altitude ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1915 | y_off+=spacer_small; |
211 | ligi | 1916 | |
1917 | g.drawString("GrSpeed: " + mk.gps_position.GroundSpeed_str() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1918 | y_off+=spacer_small; |
211 | ligi | 1919 | |
1920 | g.drawString("Heading: " + mk.gps_position.Heading ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1921 | y_off+=spacer_small; |
211 | ligi | 1922 | |
1923 | g.drawString("CompasHeading: " + mk.gps_position.CompasHeading ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1924 | y_off+=spacer_small; |
206 | ligi | 1925 | |
1926 | |||
1927 | g.drawString("Target-Lat: " + mk.gps_position.TargetLatitude_str() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1928 | y_off+=spacer_small; |
206 | ligi | 1929 | g.drawString("Target-Long: " + mk.gps_position.TargetLongitude_str() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 1930 | y_off+=spacer_small; |
206 | ligi | 1931 | |
1932 | g.drawString("Target-Alt: " + mk.gps_position.TargetAltitude ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1933 | y_off+=spacer_small; |
206 | ligi | 1934 | |
1935 | |||
1936 | g.drawString("Home-Lat: " + mk.gps_position.HomeLatitude_str() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1937 | y_off+=spacer_small; |
206 | ligi | 1938 | |
1939 | g.drawString("Home-Long: " + mk.gps_position.HomeLongitude_str() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1940 | y_off+=spacer_small; |
206 | ligi | 1941 | |
1942 | g.drawString("Home-Alt: " + mk.gps_position.HomeAltitude ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1943 | |||
265 | ligi | 1944 | y_off+=spacer_small; |
206 | ligi | 1945 | g.drawString("Distance : " + mk.gps_position.Distance2Target ,0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 1946 | y_off+=spacer_small; |
206 | ligi | 1947 | g.drawString("Angle: " + mk.gps_position.Angle2Target ,0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 1948 | y_off+=spacer_small; |
206 | ligi | 1949 | |
1950 | g.drawString("WayPoints: " + mk.gps_position.WayPointNumber + "/" + mk.gps_position.WayPointIndex ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1951 | y_off+=spacer_medium; |
206 | ligi | 1952 | |
1953 | |||
1954 | |||
1955 | /* |
||
1956 | g.drawString("" + mk.gps_position.NameWP[act_wp] ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1957 | y_off+=spacer_medium; |
206 | ligi | 1958 | |
1959 | g.drawString("Lat: " + mk.gps_position.WP_Latitude_str(act_wp) ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1960 | y_off+=spacer_medium; |
206 | ligi | 1961 | |
1962 | g.drawString("Long: " + mk.gps_position.WP_Longitude_str(act_wp) ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1963 | y_off+=spacer_medium; |
206 | ligi | 1964 | |
1965 | |||
1966 | g.drawString("Distance: " + mk.gps_position.distance2wp(act_wp) ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1967 | y_off+=spacer_medium; |
206 | ligi | 1968 | |
1969 | g.drawString("Angle: " + mk.gps_position.angle2wp(act_wp) ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 1970 | y_off+=spacer_medium; |
206 | ligi | 1971 | |
1972 | 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 | 1973 | y_off+=spacer_medium; |
206 | ligi | 1974 | */ |
1975 | |||
1976 | |||
1977 | break; |
||
1978 | |||
382 | ligi | 1979 | case STATEID_GET_AVRSIG: |
224 | ligi | 1980 | case STATEID_RESET_PARAMS: |
206 | ligi | 1981 | case STATEID_FLASHING: |
265 | ligi | 1982 | g.setFont(font_small); |
206 | ligi | 1983 | int msg_pos=0; |
382 | ligi | 1984 | g.drawString("Initializing Bootloader" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
1985 | y_off+=spacer_small; |
||
1986 | |||
1987 | if ((frame_pos%3)!=0) g.drawString("Please Wait!" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1988 | y_off+=spacer_small; |
||
1989 | |||
1990 | while (firmware_flasher.flash_msgs[msg_pos]!=null) |
||
206 | ligi | 1991 | { |
382 | ligi | 1992 | g.drawString(firmware_flasher.flash_msgs[msg_pos] ,0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 1993 | y_off+=spacer_small; |
206 | ligi | 1994 | msg_pos++; |
1995 | } |
||
382 | ligi | 1996 | |
1997 | g.drawString("mk:" + (mk==null) ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
1998 | y_off+=spacer_small; |
||
1999 | |||
206 | ligi | 2000 | break; |
2001 | |||
2002 | case STATEID_CAMMODE: |
||
2003 | |||
2004 | if (cam_img!=null) |
||
2005 | g.drawImage(cam_img,0,0,g.TOP | g.LEFT); |
||
382 | ligi | 2006 | g.drawString("condition: stick" +settings.remote_cam_stick + " (act:" +mk.stick_data.stick[settings.remote_cam_stick] +",thres:100) =>" + cam_condition() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2007 | y_off+=spacer_medium; |
382 | ligi | 2008 | |
2009 | |||
2010 | |||
2011 | y_off+=spacer_medium; |
||
221 | ligi | 2012 | g.drawString("width " + cam_img.getWidth(),0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2013 | y_off+=spacer_medium; |
221 | ligi | 2014 | g.drawString("height " + cam_img.getHeight(),0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2015 | y_off+=spacer_medium; |
221 | ligi | 2016 | break; |
206 | ligi | 2017 | |
2018 | case STATEID_STICKVIEW: |
||
2019 | |||
2020 | for(int tmp_y=0;tmp_y<10;tmp_y++) |
||
2021 | { |
||
258 | ligi | 2022 | 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 | 2023 | y_off+=spacer_medium; |
206 | ligi | 2024 | } |
2025 | break; |
||
2026 | |||
2027 | case STATEID_KEYCONTROL: |
||
2028 | |||
265 | ligi | 2029 | y_off+=spacer_medium; |
222 | ligi | 2030 | g.drawString("UP or DOWN =>nick " + mk.extern_control[EXTERN_CONTROL_NICK],0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2031 | y_off+=spacer_medium; |
222 | ligi | 2032 | g.drawString("LEFT or RIGHT =>roll " + mk.extern_control[EXTERN_CONTROL_ROLL],0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2033 | y_off+=spacer_medium; |
222 | ligi | 2034 | g.drawString("1 or 4 =>altitude " + mk.extern_control[EXTERN_CONTROL_HIGHT],0,y_off,Graphics.TOP | Graphics.LEFT); |
206 | ligi | 2035 | |
265 | ligi | 2036 | y_off+=spacer_medium; |
222 | ligi | 2037 | g.drawString("2 or 3 =>gier " + mk.extern_control[EXTERN_CONTROL_GIER],0,y_off,Graphics.TOP | Graphics.LEFT); |
206 | ligi | 2038 | |
265 | ligi | 2039 | y_off+=spacer_medium; |
222 | ligi | 2040 | g.drawString("6 or 9 =>gas " + mk.extern_control[EXTERN_CONTROL_GAS],0,y_off,Graphics.TOP | Graphics.LEFT); |
219 | ligi | 2041 | |
265 | ligi | 2042 | y_off+=spacer_medium; |
222 | ligi | 2043 | g.drawString("* and # =>exit",0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2044 | y_off+=spacer_medium; |
223 | ligi | 2045 | /* g.drawString("* and Fire =>Start Engines",0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2046 | y_off+=spacer_medium; |
222 | ligi | 2047 | g.drawString("* and 0 =>Stop Engines",0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2048 | y_off+=spacer_medium; |
223 | ligi | 2049 | */ |
219 | ligi | 2050 | 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 | 2051 | y_off+=spacer_medium; |
2052 | // g.drawString("bfont_medium:"+ keycontrol_bitfield[0] ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
2053 | //g.drawString("bfont_small:"+ keycontrol_bitfield[1] ,canvas_width/2,y_off,Graphics.TOP | Graphics.LEFT); |
||
206 | ligi | 2054 | |
2055 | break; |
||
2056 | |||
382 | ligi | 2057 | // case STATEID_MOTORTEST: |
2058 | |||
2059 | // motor_tester.paint(g); |
||
2060 | |||
2061 | |||
2062 | /* |
||
2063 | |||
206 | ligi | 2064 | for (int bar=0;bar<4;bar++) |
2065 | |||
2066 | { |
||
2067 | g.setColor(((bar==act_motor)|motor_test_sel_all)?0x44CC44:0x4444DD); |
||
2068 | g.fillRect(canvas_width/(8*2)+bar*2*canvas_width/8,y_off+10,canvas_width/8,y_off+20+motor_test[bar]); |
||
2069 | g.setColor(0x000000); |
||
2070 | g.drawString(""+motor_test[bar] ,canvas_width/8+bar*2*canvas_width/8,y_off+10,Graphics.TOP | Graphics.HCENTER); |
||
2071 | g.drawString(""+mk.debug_data.motor_val(bar) ,canvas_width/8+bar*2*canvas_width/8,y_off+25,Graphics.TOP | Graphics.HCENTER); |
||
2072 | } |
||
242 | ligi | 2073 | g.setColor(skin_fg_color()); |
2074 | g.drawString(""+mk.debug_data.analog[2]+"<->"+mk.debug_data.analog[3] ,0,canvas_height-30,Graphics.TOP | Graphics.LEFT); |
||
382 | ligi | 2075 | |
2076 | |||
2077 | |||
206 | ligi | 2078 | break; |
382 | ligi | 2079 | */ |
2080 | case STATEID_EDIT_PARAMS: |
||
2081 | case STATEID_SETTINGSMENU: |
||
2082 | case STATEID_MOTORTEST: |
||
206 | ligi | 2083 | |
382 | ligi | 2084 | act_editor.paint(g); |
2085 | |||
206 | ligi | 2086 | break; |
2087 | |||
2088 | |||
242 | ligi | 2089 | |
206 | ligi | 2090 | //#if fileapi=="on" |
2091 | case STATEID_FILEOPEN: |
||
265 | ligi | 2092 | y_off+=spacer_medium; |
221 | ligi | 2093 | g.drawString("act_path" + file_access.act_path() ,0,y_off,Graphics.TOP | Graphics.LEFT); |
206 | ligi | 2094 | paint_menu(g); |
2095 | break; |
||
2096 | //#endif |
||
224 | ligi | 2097 | |
261 | ligi | 2098 | |
382 | ligi | 2099 | //#if (location=="on")&&(cldc11=="on") |
2100 | |||
2101 | |||
261 | ligi | 2102 | case STATEID_SHOWPHONEGPS: |
382 | ligi | 2103 | |
265 | ligi | 2104 | y_off+=spacer_medium; |
261 | ligi | 2105 | g.drawString("lat" + phone_lat ,0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2106 | y_off+=spacer_medium; |
261 | ligi | 2107 | g.drawString("long" + phone_long ,0,y_off,Graphics.TOP | Graphics.LEFT); |
382 | ligi | 2108 | |
2109 | |||
2110 | y_off+=spacer_medium; |
||
2111 | g.drawString("cr" + (cr!=null) ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
2112 | |||
2113 | y_off+=spacer_medium; |
||
2114 | g.drawString("LocationProvider" + (lp!=null) ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
2115 | |||
2116 | y_off+=spacer_medium; |
||
2117 | g.drawString("Coordinates" + (c!=null) ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
2118 | |||
261 | ligi | 2119 | break; |
2120 | |||
382 | ligi | 2121 | //#endif |
2122 | case STATEID_SELECT_MIXER: |
||
255 | ligi | 2123 | case STATEID_SELECT_FIRMWARE: |
242 | ligi | 2124 | case STATEID_SELECT_COMPORT: |
224 | ligi | 2125 | case STATEID_PARAM_MENU: |
2126 | paint_menu(g); |
||
2127 | break; |
||
213 | ligi | 2128 | case STATEID_STRINGINPUT: |
206 | ligi | 2129 | case STATEID_ABOUT: |
2130 | case STATEID_IPINPUT: |
||
252 | ligi | 2131 | case STATEID_PARAM_MASSWRITE: |
206 | ligi | 2132 | case STATEID_READ_PARAMS: |
252 | ligi | 2133 | //#if bluetooth=="on" |
2134 | case STATEID_SCANNING: |
||
2135 | //#endif |
||
221 | ligi | 2136 | paint_lcd(g); |
206 | ligi | 2137 | break; |
2138 | |||
2139 | |||
252 | ligi | 2140 | |
206 | ligi | 2141 | case STATEID_RAWDEBUG: |
265 | ligi | 2142 | g.setFont(font_small); |
206 | ligi | 2143 | rawdebug_off_y=0; |
265 | ligi | 2144 | if ((rawdebug_cursor_y+3)*spacer_small>canvas_height) |
2145 | rawdebug_off_y=((rawdebug_cursor_y+3)*spacer_small-canvas_height)/spacer_small; |
||
2146 | for (int i=0;i<(canvas_height/spacer_small)-1;i++) |
||
206 | ligi | 2147 | { |
2148 | if (i+rawdebug_off_y==rawdebug_cursor_y) |
||
2149 | { |
||
2150 | g.setColor(0x0000CC); |
||
265 | ligi | 2151 | g.fillRect(0,y_off,canvas_width,spacer_small); |
206 | ligi | 2152 | |
2153 | g.setColor(skin_fg_color()); |
||
2154 | |||
2155 | |||
2156 | } |
||
2157 | if (i+rawdebug_off_y<32) //todo better style |
||
2158 | 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); |
||
2159 | |||
265 | ligi | 2160 | y_off+=spacer_small; |
206 | ligi | 2161 | |
2162 | } |
||
2163 | |||
2164 | |||
2165 | |||
2166 | break; |
||
2167 | |||
2168 | |||
2169 | case STATEID_CONN_DETAILS: |
||
265 | ligi | 2170 | g.setFont(font_medium); |
255 | ligi | 2171 | g.drawString(l(STRINGID_CONN)+":",0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2172 | y_off+=spacer_medium; |
2173 | g.setFont(font_small); |
||
206 | ligi | 2174 | |
2175 | g.drawString(" URL:" + mk.mk_url,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 2176 | y_off+=spacer_small; |
206 | ligi | 2177 | |
2178 | g.drawString(" Name:" + mk.name,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 2179 | y_off+=spacer_small; |
206 | ligi | 2180 | |
382 | ligi | 2181 | g.drawString(" "+mk.extended_name()+ " (" + (mk.connected?("open"+((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s"):"closed")+"):",0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2182 | y_off+=spacer_small; |
255 | ligi | 2183 | g.drawString(" Software Version:" + mk.version.version_str ,0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2184 | y_off+=spacer_small; |
255 | ligi | 2185 | |
2186 | g.drawString(" Protocol Version:" + mk.version.proto_str ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 2187 | y_off+=spacer_small; |
206 | ligi | 2188 | g.drawString(" Slave-Addr:" + mk.slave_addr,0,y_off,Graphics.TOP | Graphics.LEFT); |
2189 | |||
2190 | paint_menu(g); |
||
2191 | |||
2192 | break; |
||
2193 | |||
2194 | case STATEID_TRAFFIC: |
||
2195 | |||
265 | ligi | 2196 | g.setFont(font_medium); |
206 | ligi | 2197 | g.drawString("Packet Traffic (over "+mk.conn_time_in_s()+"s):",0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2198 | y_off+=spacer_medium; |
2199 | g.setFont(font_small); |
||
206 | ligi | 2200 | 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 | 2201 | y_off+=spacer_small; |
206 | ligi | 2202 | |
382 | ligi | 2203 | g.drawString( " crcFail:"+mk.stats.crc_fail +" unknown:" +mk.stats.other_data_count,0,y_off,Graphics.TOP | Graphics.LEFT); |
2204 | y_off+=spacer_small; |
||
206 | ligi | 2205 | |
2206 | |||
2207 | 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 | 2208 | y_off+=spacer_small; |
219 | ligi | 2209 | 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 | 2210 | y_off+=spacer_small; |
206 | ligi | 2211 | g.drawString( " debug_names:" + mk.stats.debug_names_count + " angles:" + mk.stats.angle_data_count ,0,y_off,Graphics.TOP | Graphics.LEFT); |
2212 | |||
382 | ligi | 2213 | //y_off+=spacer_small; |
2214 | // g.drawString( " other:"+mk.stats.other_data_count,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
219 | ligi | 2215 | |
265 | ligi | 2216 | y_off+=spacer_small+3; |
206 | ligi | 2217 | 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 | 2218 | y_off+=spacer_small; |
206 | ligi | 2219 | 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 | 2220 | y_off+=spacer_small; |
219 | ligi | 2221 | 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 | 2222 | y_off+=spacer_small; |
206 | ligi | 2223 | |
219 | ligi | 2224 | g.drawString( " resend:"+mk.stats.resend_count ,0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2225 | y_off+=spacer_small; |
219 | ligi | 2226 | |
206 | ligi | 2227 | paint_menu(g); |
2228 | break; |
||
2229 | |||
2230 | case STATEID_PROXY: |
||
265 | ligi | 2231 | g.setFont(font_medium); |
206 | ligi | 2232 | g.drawString("Host:",0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2233 | y_off+=spacer_medium; |
2234 | g.setFont(font_small); |
||
206 | ligi | 2235 | g.drawString(" " + mk.proxy.url + "("+((mk.proxy.connected)?"open":"closed") +")",0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2236 | y_off+=spacer_small; |
206 | ligi | 2237 | |
2238 | |||
2239 | |||
2240 | break; |
||
2241 | |||
220 | ligi | 2242 | |
211 | ligi | 2243 | // falltru wanted |
269 | ligi | 2244 | case STATEID_SETTING_OPTIONS: |
206 | ligi | 2245 | case STATEID_MAINMENU: |
2246 | case STATEID_SELECT_PARAMSET: |
||
2247 | case STATEID_HANDLE_PARAMS: |
||
2248 | case STATEID_DEVICESELECT: |
||
2249 | |||
2250 | paint_menu(g); |
||
2251 | break; |
||
2252 | |||
2253 | |||
2254 | case STATEID_GRAPH: |
||
2255 | |||
2256 | g.setClip(0,0,canvas_width,canvas_height); |
||
262 | ligi | 2257 | |
2258 | // |
||
206 | ligi | 2259 | g.setColor(0xe1dddd); |
265 | ligi | 2260 | g.setFont(font_small); |
229 | ligi | 2261 | // LEGEND |
255 | ligi | 2262 | if (settings.graph_legend) |
262 | ligi | 2263 | { |
2264 | g.setStrokeStyle(Graphics.DOTTED); |
||
2265 | for (int d=0;d<GRAPH_COUNT;d++) |
||
2266 | { |
||
2267 | |||
2268 | // g.setColor(graph_colors[d]); |
||
265 | ligi | 2269 | // g.fillRect(0,y_off +spacer_small/2-2 ,20,4); |
262 | ligi | 2270 | // g.setColor(skin_fg_color()); |
2271 | // g.drawString(graph_names[d] + mk.debug_data.analog[graph_sources[d]],23,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 2272 | // y_off+=spacer_small; |
262 | ligi | 2273 | |
2274 | g.setColor(graph_colors[d]); |
||
265 | ligi | 2275 | g.fillRect(canvas_width-20,canvas_height-spacer_medium*(d+1)+(spacer_medium)/2-2 ,20,4); |
262 | ligi | 2276 | g.setColor(skin_fg_color()); |
265 | ligi | 2277 | g.drawString(graph_names[d] ,canvas_width-23,canvas_height-spacer_medium*(d+1),Graphics.TOP | Graphics.RIGHT); |
2278 | // y_off+=spacer_small; |
||
262 | ligi | 2279 | |
2280 | } |
||
206 | ligi | 2281 | |
262 | ligi | 2282 | g.setStrokeStyle(Graphics.SOLID); |
2283 | } |
||
2284 | |||
229 | ligi | 2285 | if (settings.graph_scale) |
2286 | { |
||
2287 | |||
2288 | int scale=10; |
||
2289 | // if ((10/line_scaler)<5)scale =1; |
||
2290 | if (((10/line_scaler)*2)<(canvas_height/2) )scale =10; |
||
2291 | if (((50/line_scaler)*2)<(canvas_height/2) )scale =50; |
||
2292 | if (((100/line_scaler)*2)<(canvas_height/2) )scale =100; |
||
2293 | if (((250/line_scaler)*2)<(canvas_height/2) )scale =250; |
||
2294 | if (((500/line_scaler)*2)<(canvas_height/2) )scale =500; |
||
2295 | if (((1000/line_scaler)*2)<(canvas_height/2) )scale =1000; |
||
2296 | if (((10000/line_scaler)*2)<(canvas_height/2) )scale =10000; |
||
206 | ligi | 2297 | |
2298 | |||
2299 | |||
229 | ligi | 2300 | |
2301 | // g.drawString("scale:"+scale + "line scaler" + line_scaler,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
2302 | |||
2303 | |||
2304 | int jump=0; |
||
2305 | |||
2306 | g.drawLine(0,line_middle_y,canvas_width,line_middle_y); |
||
2307 | |||
2308 | while ((jump/line_scaler)<graph_height) |
||
2309 | { |
||
2310 | |||
2311 | g.drawString(""+jump,0,line_middle_y - jump/line_scaler,Graphics.TOP | Graphics.LEFT); |
||
2312 | if (jump!=0)g.drawString("-"+jump,0,line_middle_y + jump/line_scaler,Graphics.TOP | Graphics.LEFT); |
||
2313 | g.drawLine(0,line_middle_y - jump/line_scaler,canvas_width,line_middle_y - jump/line_scaler); |
||
2314 | g.drawLine(0,line_middle_y + jump/line_scaler,canvas_width,line_middle_y + jump/line_scaler); |
||
2315 | jump+=scale; |
||
2316 | } |
||
206 | ligi | 2317 | } |
2318 | |||
2319 | |||
2320 | |||
2321 | for (int gr=0;gr<GRAPH_COUNT;gr++) |
||
2322 | { |
||
2323 | |||
223 | ligi | 2324 | // !!TODO checkme |
206 | ligi | 2325 | g.setColor(graph_colors[gr]); |
2326 | |||
262 | ligi | 2327 | // check_local_max(mk.debug_data.analog[graph_sources[gr]]); |
206 | ligi | 2328 | |
262 | ligi | 2329 | line_scaler= mk.debug_buff_max/graph_height+1; |
206 | ligi | 2330 | |
2331 | |||
262 | ligi | 2332 | for ( int x=0;x<canvas_width-1;x++) |
206 | ligi | 2333 | { |
262 | ligi | 2334 | /*int p= (((-graph_offset+x-canvas_width-5))); |
206 | ligi | 2335 | if (p<1) |
2336 | p+=graph_data[0].length; |
||
2337 | p%=(graph_data[0].length-1); |
||
2338 | |||
2339 | draw_graph_part(g,x,graph_data[gr][p]/line_scaler,graph_data[gr][p+1]/line_scaler); |
||
262 | ligi | 2340 | */ |
2341 | |||
2342 | int p= (((mk.debug_buff_off+x-canvas_width))); |
||
2343 | if (p<0) |
||
2344 | p+=mk.debug_buff_len; |
||
2345 | p%=(mk.debug_buff_len-2); |
||
2346 | |||
2347 | |||
2348 | if (p<mk.debug_buff_lastset) |
||
2349 | |||
382 | ligi | 2350 | // draw_graph_part(g,x,mk.debug_buff[p][gr]/line_scaler,mk.debug_buff[p+1][gr]/line_scaler); |
262 | ligi | 2351 | |
382 | ligi | 2352 | g.drawLine(x,line_middle_y-mk.debug_buff[p][gr]/line_scaler,x+1,line_middle_y-mk.debug_buff[p+1][gr]/line_scaler); |
262 | ligi | 2353 | // System.out.println("--p"+p + "gr " + gr + " l " + mk.debug_buff.length +" ls:" + mk.debug_buff_lastset ); |
2354 | |||
206 | ligi | 2355 | } |
2356 | } |
||
2357 | |||
223 | ligi | 2358 | |
262 | ligi | 2359 | /* |
2360 | int[] pixels=new int[canvas_width*canvas_height]; |
||
2361 | for (int x=0;x<canvas_width;x++) |
||
2362 | for (int y=0;y<canvas_height;y++) |
||
2363 | if (x==y) pixels[x+canvas_width*y]=0xFFFFFFFF; |
||
223 | ligi | 2364 | |
262 | ligi | 2365 | Image test= Image.createRGBImage(pixels,canvas_width,canvas_height,true); |
2366 | g.drawImage(test,0,0,Graphics.TOP | Graphics.LEFT ); |
||
2367 | */ |
||
2368 | |||
206 | ligi | 2369 | break; |
2370 | |||
245 | ligi | 2371 | case STATEID_LCD: |
206 | ligi | 2372 | /* |
2373 | 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);; |
||
2374 | 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); |
||
2375 | |||
2376 | */ |
||
2377 | /* |
||
2378 | // !!TODO!! check exactly which version those Datas where introduced |
||
2379 | if (mk.version.compare(0,60)==mk.version.VERSION_PREVIOUS) |
||
2380 | { |
||
2381 | g.drawString("Voltage: " + (mk.debug_data.UBatt()/10) + "," +(mk.debug_data.UBatt()%10)+"V" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
2382 | g.drawString("Sender: " + mk.debug_data.SenderOkay(),canvas_width/2,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 2383 | y_off+=spacer_medium; |
206 | ligi | 2384 | } |
2385 | |||
2386 | 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); |
||
2387 | |||
265 | ligi | 2388 | y_off+=spacer_medium; |
206 | ligi | 2389 | |
2390 | 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 | 2391 | y_off+=spacer_medium; |
206 | ligi | 2392 | |
2393 | |||
2394 | 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 | 2395 | y_off+=spacer_medium; |
206 | ligi | 2396 | |
2397 | if (mk.connected) |
||
2398 | { |
||
2399 | g.drawString("time conn:" +((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
||
265 | ligi | 2400 | y_off+=spacer_medium; |
206 | ligi | 2401 | g.drawString("time motor>15:" +(mk_stat.motor_on_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2402 | y_off+=spacer_medium; |
206 | ligi | 2403 | g.drawString("time motor=15:" +(mk_stat.motor_stand_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
265 | ligi | 2404 | y_off+=spacer_medium; |
206 | ligi | 2405 | 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); |
2406 | |||
265 | ligi | 2407 | y_off+=spacer_medium; |
206 | ligi | 2408 | g.drawString("lcd-key:" + mk.LCD.act_key ,0,y_off,Graphics.TOP | Graphics.LEFT); |
2409 | |||
2410 | } |
||
2411 | */ |
||
2412 | |||
2413 | int spacer_left_right=(canvas_width-(20*(lcd_img.getWidth()/222)))/2; |
||
2414 | |||
2415 | y_off=canvas_height-4*lcd_img.getHeight(); |
||
2416 | |||
2417 | for ( int foo=0;foo<4;foo++) |
||
2418 | { |
||
2419 | for (int x=0;x<20;x++) |
||
2420 | { |
||
2421 | g.setClip(spacer_left_right+(lcd_img.getWidth()/222)*x,y_off,(lcd_img.getWidth()/222),lcd_img.getHeight()); |
||
2422 | 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); |
||
2423 | |||
2424 | } |
||
2425 | y_off+=lcd_img.getHeight(); |
||
2426 | } |
||
2427 | |||
2428 | g.setClip(0,0,canvas_width,canvas_height); |
||
2429 | |||
2430 | } |
||
2431 | |||
2432 | |||
2433 | |||
262 | ligi | 2434 | } catch (Exception e) { System.out.println("error in paint " + e);} |
206 | ligi | 2435 | |
382 | ligi | 2436 | |
2437 | if (debug_overlay) |
||
2438 | { |
||
2439 | |||
2440 | for(int debug_line=0;debug_line<5;debug_line++) |
||
2441 | for ( int bar=0;bar<canvas_width/(symbols_img.getWidth()/10)+1;bar++) |
||
2442 | { |
||
2443 | g.setClip(bar*(symbols_img_tile_width),canvas_height-(debug_line+1)*symbols_img_tile_height,(symbols_img_tile_width),symbols_img_tile_height);; |
||
2444 | g.drawImage(symbols_img,bar*(symbols_img_tile_width),canvas_height-(debug_line+1)*symbols_img_tile_height, g.TOP | g.LEFT); |
||
2445 | |||
2446 | } |
||
2447 | |||
2448 | g.setColor(0); |
||
2449 | g.setClip(0,0,canvas_width,canvas_height); |
||
2450 | g.drawString("freeMemory:" + Runtime.getRuntime().freeMemory() ,0,canvas_height-spacer_small,Graphics.TOP | Graphics.LEFT); |
||
2451 | g.drawString("totalMemory:" + Runtime.getRuntime().totalMemory() ,0,canvas_height-2*spacer_small,Graphics.TOP | Graphics.LEFT); |
||
2452 | |||
2453 | g.drawString("state:" + state ,0,canvas_height-3*spacer_small,Graphics.TOP | Graphics.LEFT); |
||
2454 | g.drawString("key_bitfield:" + key_bitfield ,0,canvas_height-4*spacer_small,Graphics.TOP | Graphics.LEFT); |
||
2455 | |||
2456 | } |
||
2457 | |||
2458 | |||
206 | ligi | 2459 | } |
382 | ligi | 2460 | //xda Player mPlayer; |
2461 | //xda VideoControl mVideoControl; |
||
206 | ligi | 2462 | Image cam_img; |
221 | ligi | 2463 | Image last_cam_img; |
206 | ligi | 2464 | int cam_img_seq=0; |
2465 | byte[] cam_raw; |
||
2466 | |||
2467 | private void connect_mk(String url,String name) |
||
2468 | { |
||
2469 | // mk.ufo_prober.bluetooth_probe(url); |
||
2470 | settings.connection_url=url; |
||
2471 | settings.connection_name=name; |
||
2472 | mk.connect_to(url,name); |
||
2473 | } |
||
2474 | |||
382 | ligi | 2475 | /* |
206 | ligi | 2476 | public void draw_graph_part(Graphics g,int x,int y1,int y2) |
2477 | { |
||
262 | ligi | 2478 | g.drawLine(x,line_middle_y-y1,x+1,line_middle_y-y2); |
206 | ligi | 2479 | } |
382 | ligi | 2480 | */ |
206 | ligi | 2481 | |
2482 | |||
2483 | /*********************************************** input Section **********************************************/ |
||
2484 | |||
2485 | |||
2486 | |||
2487 | // 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) "; |
||
2488 | |||
2489 | // int intro_str_pos=0; |
||
2490 | // int intro_str_delay=3; |
||
219 | ligi | 2491 | // boolean init_bootloader=false; |
206 | ligi | 2492 | |
264 | ligi | 2493 | |
382 | ligi | 2494 | |
2495 | |||
2496 | |||
206 | ligi | 2497 | public void chg_state(byte next_state) |
2498 | { |
||
382 | ligi | 2499 | //#if bluetooth=="on" |
2500 | if (next_state!=STATEID_DEVICESELECT) |
||
2501 | bt_scanner=null; |
||
2502 | //#endif |
||
2503 | if (firmware_flasher!=null) |
||
2504 | { |
||
2505 | firmware_flasher.exit_bootloader(); |
||
2506 | firmware_flasher=null; |
||
2507 | } |
||
2508 | |||
2509 | if ((mk==null)) |
||
2510 | { |
||
2511 | if ((next_state!=STATEID_SELECT_FIRMWARE)&&(next_state!=STATEID_FLASHING)) |
||
2512 | { |
||
2513 | mk = new MKCommunicator(); |
||
2514 | settings.process_all_settings(); // TODO remove |
||
2515 | if (settings.connection_url!="") |
||
2516 | connect_mk(settings.connection_url,settings.connection_name); |
||
2517 | } |
||
2518 | |||
2519 | } |
||
2520 | else |
||
2521 | { |
||
2522 | mk.watchdog.resend_timeout=0; |
||
2523 | |||
2524 | mk.destroy_debug_buff(); |
||
2525 | mk.user_intent=USER_INTENT_NONE; |
||
2526 | mk.set_debug_interval(mk.default_abo); |
||
2527 | mk.set_gpsosd_interval(mk.default_abo); |
||
2528 | } |
||
2529 | |||
2530 | if (next_state!=STATEID_ERROR_MSG) |
||
2531 | { |
||
2532 | act_editor = null; |
||
2533 | motor_tester=null; |
||
2534 | } |
||
2535 | |||
223 | ligi | 2536 | err_img=null; |
262 | ligi | 2537 | // graph_data=null; |
382 | ligi | 2538 | |
223 | ligi | 2539 | act_menu_select_bak[state]=act_menu_select; |
2540 | act_menu_select=act_menu_select_bak[next_state]; |
||
229 | ligi | 2541 | |
206 | ligi | 2542 | // prepare next state |
2543 | switch(next_state) |
||
242 | ligi | 2544 | |
206 | ligi | 2545 | { |
382 | ligi | 2546 | |
493 | ligi | 2547 | case STATEID_BIG_SYMBOLS: |
2548 | big_symbols_img=DUBwiseHelper.scaleImage(symbols_img,(this.getWidth()/5)*10); |
||
2549 | break; |
||
382 | ligi | 2550 | case STATEID_MOTORTEST: |
2551 | motor_tester=new MotorTester(); |
||
2552 | act_editor=new MKParamsEditor(this,motor_tester,STATEID_MAINMENU); |
||
2553 | break; |
||
2554 | |||
2555 | case STATEID_SELECT_MIXER: |
||
2556 | setup_menu(DUBwiseHelper.combine_str_arr(mixer_manager.names,new String[] {"back"}),null); |
||
2557 | break; |
||
2558 | |||
2559 | |||
269 | ligi | 2560 | case STATEID_SETTING_OPTIONS: |
2561 | setup_menu(setting_options_menu_items,setting_options_menu_actions); |
||
2562 | break; |
||
255 | ligi | 2563 | |
382 | ligi | 2564 | case STATEID_SHOWPHONEGPS: |
2565 | mk.user_intent=USER_INTENT_FOLLOWME; |
||
2566 | break; |
||
2567 | |||
264 | ligi | 2568 | case STATEID_GPSVIEW: |
2569 | |||
2570 | mk.user_intent=USER_INTENT_GPSOSD; |
||
2571 | break; |
||
255 | ligi | 2572 | case STATEID_SELECT_FIRMWARE: |
382 | ligi | 2573 | setup_menu(fw_loader.names,null); |
255 | ligi | 2574 | break; |
2575 | |||
2576 | |||
224 | ligi | 2577 | case STATEID_SUCCESS_MSG: |
2578 | case STATEID_ERROR_MSG: |
||
221 | ligi | 2579 | lcd_lines=new String[1]; |
224 | ligi | 2580 | |
382 | ligi | 2581 | lcd_lines[0]=act_msg; |
221 | ligi | 2582 | try |
2583 | { |
||
2584 | err_img=Image.createImage("/preflight.jpg"); |
||
2585 | } |
||
2586 | catch (Exception e) |
||
2587 | { |
||
2588 | debug.log("problem loading error image"); |
||
2589 | } |
||
2590 | |||
2591 | break; |
||
220 | ligi | 2592 | case STATEID_EDIT_PARAMS: |
382 | ligi | 2593 | act_editor = new MKParamsEditor(this,mk.params,STATEID_HANDLE_PARAMS); |
220 | ligi | 2594 | break; |
213 | ligi | 2595 | case STATEID_STRINGINPUT: |
2596 | lcd_lines=new String[2]; |
||
2597 | lcd_lines[0]=act_input_str; |
||
2598 | lcd_lines[1]="^"; |
||
2599 | |||
2600 | break; |
||
245 | ligi | 2601 | case STATEID_LCD: |
206 | ligi | 2602 | mk.user_intent=USER_INTENT_LCD; |
2603 | break; |
||
224 | ligi | 2604 | case STATEID_RESET_PARAMS: |
2605 | |||
382 | ligi | 2606 | firmware_flasher=new MKFirmwareFlasher(settings.connection_url,MKFirmwareHelper.BOOTLOADER_INTENSION_RESET_PARAMS); |
2607 | |||
2608 | |||
2609 | /* mk.bootloader_intension_flash=false; |
||
224 | ligi | 2610 | mk.bl_retrys=0; |
382 | ligi | 2611 | mk.init_bootloader=true;*/ |
224 | ligi | 2612 | break; |
2613 | |||
206 | ligi | 2614 | case STATEID_FLASHING: |
382 | ligi | 2615 | |
2616 | firmware_flasher=new MKFirmwareFlasher(settings.connection_url,MKFirmwareHelper.BOOTLOADER_INTENSION_FLASH_FIRMWARE); |
||
2617 | firmware_flasher.in=fw_loader.get_input_str(); |
||
2618 | |||
2619 | /* |
||
206 | ligi | 2620 | mk.bootloader_intension_flash=true; |
219 | ligi | 2621 | mk.bl_retrys=0; |
2622 | mk.init_bootloader=true; |
||
382 | ligi | 2623 | */ |
206 | ligi | 2624 | break; |
2625 | |||
382 | ligi | 2626 | case STATEID_GET_AVRSIG: |
2627 | |||
2628 | firmware_flasher=new MKFirmwareFlasher(settings.connection_url,MKFirmwareHelper.BOOTLOADER_INTENSION_GET_SIG); |
||
2629 | |||
2630 | |||
2631 | break; |
||
2632 | |||
206 | ligi | 2633 | //#if fileapi=="on" |
2634 | case STATEID_FILEOPEN: |
||
382 | ligi | 2635 | file_access.dirty=true; |
206 | ligi | 2636 | break; |
2637 | //#endif |
||
2638 | |||
2639 | case STATEID_STICKVIEW: |
||
2640 | mk.user_intent=USER_INTENT_RCDATA; |
||
2641 | break; |
||
2642 | case STATEID_SELECT_COMPORT: |
||
242 | ligi | 2643 | menu_items=DUBwiseHelper.split_str(System.getProperty("microedition.commports")+",back",","); |
2644 | setup_menu(menu_items,null); |
||
206 | ligi | 2645 | break; |
2646 | |||
2647 | |||
2648 | case STATEID_ABOUT: |
||
2649 | lcd_lines=credits; |
||
382 | ligi | 2650 | lcd_lines[CREDITS_VERSION]= "Version: V" + version_str; |
2651 | lcd_lines[CREDITS_VERSION+1]="Lib Vers.: " + mk.lib_version_str(); |
||
2652 | act_menu_select=(byte)(max_lines-1); |
||
206 | ligi | 2653 | break; |
382 | ligi | 2654 | |
206 | ligi | 2655 | case STATEID_CONN_DETAILS: |
242 | ligi | 2656 | setup_conn_menu();//conn_details_menu_items,conn_details_menu_actions); |
206 | ligi | 2657 | break; |
224 | ligi | 2658 | |
2659 | |||
2660 | case STATEID_PARAM_MENU: |
||
2661 | setup_menu(param_menu_items,param_menu_actions); |
||
2662 | break; |
||
206 | ligi | 2663 | case STATEID_TRAFFIC: |
2664 | setup_menu(onlyback_menu_items,back_to_conndetails_actions); |
||
2665 | break; |
||
2666 | case STATEID_CAMMODE: |
||
382 | ligi | 2667 | /*xda |
221 | ligi | 2668 | mk.user_intent=USER_INTENT_RCDATA; |
206 | ligi | 2669 | if (mVideoControl==null) |
2670 | try |
||
2671 | { |
||
2672 | debug.log("creating player\n"); |
||
2673 | mPlayer = Manager.createPlayer("capture://video?encoding=png&width=2048&height=1536"); |
||
2674 | |||
2675 | debug.log("realizing player\n"); |
||
2676 | mPlayer.realize(); |
||
2677 | |||
2678 | debug.log("get_videocontrol\n"); |
||
2679 | |||
2680 | mVideoControl = (VideoControl)mPlayer.getControl("VideoControl"); |
||
2681 | |||
2682 | debug.log("switching Canvas\n"); |
||
2683 | mVideoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this); |
||
2684 | |||
2685 | debug.log("get snap\n"); |
||
2686 | byte[] raw = mVideoControl.getSnapshot(null); |
||
2687 | |||
2688 | } |
||
2689 | catch ( Exception e) |
||
2690 | { |
||
2691 | debug.log(e.toString()); |
||
2692 | } |
||
382 | ligi | 2693 | */ |
206 | ligi | 2694 | |
2695 | break; |
||
2696 | case STATEID_KEYCONTROL: |
||
219 | ligi | 2697 | mk.user_intent= USER_INTENT_EXTERNAL_CONTROL; |
206 | ligi | 2698 | keycontrol_exit=0; |
2699 | break; |
||
2700 | |||
233 | ligi | 2701 | |
252 | ligi | 2702 | case STATEID_PARAM_MASSWRITE: |
2703 | mk.user_intent=USER_INTENT_PARAMS; |
||
2704 | lcd_lines=new String[2]; |
||
2705 | lcd_lines[0]=""; |
||
2706 | lcd_lines[1]=""; |
||
2707 | break; |
||
233 | ligi | 2708 | |
206 | ligi | 2709 | case STATEID_READ_PARAMS: |
2710 | mk.user_intent=USER_INTENT_PARAMS; |
||
2711 | lcd_lines=new String[2]; |
||
2712 | lcd_lines[0]="Reading Settings "; |
||
252 | ligi | 2713 | lcd_lines[1]=DUBwiseHelper.pound_progress(mk.watchdog.act_paramset,5); |
206 | ligi | 2714 | |
2715 | break; |
||
2716 | |||
2717 | case STATEID_IPINPUT: |
||
2718 | |||
2719 | lcd_lines=new String[3]; |
||
2720 | lcd_lines[0]="Address (IP:Port): "; |
||
2721 | break; |
||
2722 | |||
2723 | //#if bluetooth=="on" |
||
2724 | case STATEID_SCANNING: |
||
2725 | lcd_lines=new String[3]; |
||
2726 | lcd_lines[0]="Searching for"; |
||
2727 | lcd_lines[1]="Bluetooth Devices"; |
||
2728 | lcd_lines[2]="found"; |
||
2729 | |||
2730 | mk.close_connections(true); |
||
382 | ligi | 2731 | |
2732 | bt_scanner = new BTSearcher(); |
||
2733 | |||
206 | ligi | 2734 | break; |
2735 | //#endif |
||
2736 | |||
2737 | case STATEID_HANDLE_PARAMS: |
||
255 | ligi | 2738 | setup_menu(handle_params_menu_items,handle_params_menu_actions); |
206 | ligi | 2739 | break; |
2740 | |||
2741 | case STATEID_SELECT_PARAMSET: |
||
224 | ligi | 2742 | menu_items=new String[6]; |
206 | ligi | 2743 | for (int i=0;i<5;i++) |
223 | ligi | 2744 | menu_items[i]=""+(i+1)+": " + mk.params.getParamName(i) + ((i==mk.params.active_paramset)?"*":""); |
206 | ligi | 2745 | |
255 | ligi | 2746 | menu_items[5]=l(STRINGID_BACK); |
224 | ligi | 2747 | lcd_lines=new String[6]; |
206 | ligi | 2748 | break; |
2749 | |||
2750 | //#if bluetooth=="on" |
||
2751 | case STATEID_DEVICESELECT: |
||
2752 | |||
2753 | menu_items=new String[bt_scanner.remote_device_count+2]; |
||
2754 | lcd_lines=new String[bt_scanner.remote_device_count+2]; |
||
2755 | |||
2756 | for (int i=0;i<bt_scanner.remote_device_count;i++) |
||
2757 | menu_items[i]=bt_scanner.remote_device_name[i]; |
||
2758 | menu_items[bt_scanner.remote_device_count]="scan again"; |
||
2759 | menu_items[bt_scanner.remote_device_count+1]="cancel"; |
||
2760 | |||
2761 | break; |
||
2762 | //#endif |
||
2763 | |||
2764 | case STATEID_MAINMENU: |
||
214 | ligi | 2765 | setup_main_menu(); |
2766 | |||
206 | ligi | 2767 | break; |
2768 | |||
2769 | case STATEID_SETTINGSMENU: |
||
382 | ligi | 2770 | // if (settings_editor==null) |
2771 | act_editor = new MKParamsEditor(this,settings,STATEID_MAINMENU); |
||
206 | ligi | 2772 | |
2773 | break; |
||
2774 | |||
2775 | case STATEID_RAWDEBUG: |
||
2776 | mk.user_intent=USER_INTENT_RAWDEBUG; |
||
2777 | break; |
||
2778 | |||
264 | ligi | 2779 | case STATEID_HORIZON: |
2780 | // mk.user_intent=USER_INTENT_GRAPH; |
||
382 | ligi | 2781 | if (mk.is_navi()) |
2782 | mk.set_debug_interval(mk.secondary_abo); |
||
264 | ligi | 2783 | break; |
206 | ligi | 2784 | |
2785 | case STATEID_GRAPH: |
||
264 | ligi | 2786 | //mk.set_debug_interval(1); |
262 | ligi | 2787 | |
2788 | mk.setup_debug_buff(graph_sources,this.getWidth(),settings.graph_interval); |
||
2789 | |||
2790 | mk.user_intent=USER_INTENT_GRAPH; |
||
2791 | |||
2792 | |||
2793 | /* |
||
221 | ligi | 2794 | graph_data=new int[GRAPH_COUNT][this.getWidth()*2]; |
2795 | |||
2796 | for (int c=0;c<graph_data[0].length;c++) |
||
2797 | for (int d=0;d<GRAPH_COUNT;d++) |
||
2798 | graph_data[d][c]=-1; |
||
262 | ligi | 2799 | |
221 | ligi | 2800 | |
262 | ligi | 2801 | |
223 | ligi | 2802 | local_max=1; |
262 | ligi | 2803 | */ |
206 | ligi | 2804 | break; |
2805 | |||
2806 | } |
||
2807 | |||
382 | ligi | 2808 | |
2809 | |||
206 | ligi | 2810 | // switch state |
2811 | state=next_state; |
||
2812 | } // void chg_state |
||
2813 | |||
2814 | |||
2815 | public void keyReleased(int keyCode) |
||
2816 | { |
||
2817 | |||
382 | ligi | 2818 | if (state==STATEID_MAP) |
2819 | key_bitfield=0; |
||
2820 | else |
||
2821 | key_bitfield&=(0xFFFFFFFF)^keyCode2mask(keyCode); |
||
2822 | |||
206 | ligi | 2823 | switch(state) |
2824 | { |
||
382 | ligi | 2825 | /* |
2826 | case STATEID_MOTORTEST: |
||
2827 | act_motor_increase=0; |
||
2828 | break; |
||
2829 | */ |
||
206 | ligi | 2830 | |
2831 | case STATEID_KEYCONTROL: |
||
2832 | if (keyCode==KEY_POUND) |
||
2833 | keycontrol_exit &= 255^1; |
||
2834 | else |
||
2835 | if (keyCode==KEY_STAR) |
||
2836 | keycontrol_exit &= 255^2; |
||
2837 | else |
||
219 | ligi | 2838 | mod_external_control_by_keycode(keyCode,(byte)0); |
206 | ligi | 2839 | |
219 | ligi | 2840 | /* |
206 | ligi | 2841 | mk.send_keys(keycontrol_bitfield); |
219 | ligi | 2842 | */ |
206 | ligi | 2843 | break; |
2844 | } |
||
2845 | |||
2846 | } |
||
2847 | |||
2848 | |||
219 | ligi | 2849 | public void mod_external_control_by_keycode(int keyCode,byte mul) |
2850 | { |
||
2851 | |||
2852 | if (keyCode==this.KEY_NUM2) |
||
2853 | mk.extern_control[EXTERN_CONTROL_GIER]=(byte)(-mul*settings.default_extern_control[EXTERN_CONTROL_GIER]); |
||
2854 | else if (keyCode==this.KEY_NUM3) |
||
2855 | mk.extern_control[EXTERN_CONTROL_GIER]=(byte)(mul*settings.default_extern_control[EXTERN_CONTROL_GIER]); |
||
2856 | |||
2857 | else if (keyCode==this.KEY_NUM1) |
||
220 | ligi | 2858 | mk.extern_control[EXTERN_CONTROL_HIGHT]+=mul*settings.default_extern_control[EXTERN_CONTROL_HIGHT]; |
219 | ligi | 2859 | else if (keyCode==this.KEY_NUM4) |
220 | ligi | 2860 | mk.extern_control[EXTERN_CONTROL_HIGHT]-=mul*settings.default_extern_control[EXTERN_CONTROL_HIGHT]; |
219 | ligi | 2861 | |
2862 | |||
2863 | else if (keyCode==this.KEY_NUM6) |
||
220 | ligi | 2864 | { if ( mk.extern_control[EXTERN_CONTROL_GAS]<255) mk.extern_control[EXTERN_CONTROL_GAS]+=mul*settings.default_extern_control[EXTERN_CONTROL_GAS]; } |
219 | ligi | 2865 | else if (keyCode==this.KEY_NUM9) |
220 | ligi | 2866 | { if ( mk.extern_control[EXTERN_CONTROL_GAS]>0) mk.extern_control[EXTERN_CONTROL_GAS]-=mul*settings.default_extern_control[EXTERN_CONTROL_GAS]; } |
219 | ligi | 2867 | |
2868 | else switch (getGameAction (keyCode)) |
||
2869 | { |
||
2870 | case UP: |
||
2871 | mk.extern_control[EXTERN_CONTROL_NICK]=(byte)(mul*settings.default_extern_control[EXTERN_CONTROL_NICK]); |
||
2872 | break; |
||
2873 | |||
2874 | case DOWN: |
||
2875 | mk.extern_control[EXTERN_CONTROL_NICK]=(byte)(-mul*settings.default_extern_control[EXTERN_CONTROL_NICK]); |
||
2876 | |||
2877 | break; |
||
2878 | |||
2879 | |||
2880 | case LEFT: |
||
2881 | mk.extern_control[EXTERN_CONTROL_ROLL]=(byte)(mul*settings.default_extern_control[EXTERN_CONTROL_ROLL]); |
||
2882 | break; |
||
2883 | |||
2884 | case RIGHT: |
||
2885 | mk.extern_control[EXTERN_CONTROL_ROLL]=(byte)(-mul*settings.default_extern_control[EXTERN_CONTROL_ROLL]); |
||
2886 | break; |
||
2887 | |||
2888 | case FIRE: |
||
2889 | |||
2890 | break; |
||
2891 | |||
2892 | |||
2893 | } |
||
2894 | |||
2895 | } |
||
2896 | |||
242 | ligi | 2897 | |
206 | ligi | 2898 | |
242 | ligi | 2899 | public final static String PARAM_SAVE_STORE_NAME="MKParamsV1"; |
206 | ligi | 2900 | |
252 | ligi | 2901 | |
2902 | int[][] params2masswrite; |
||
2903 | int param_masswrite_write_pos; |
||
2904 | |||
264 | ligi | 2905 | //#if cldc11=="on" |
261 | ligi | 2906 | double phone_lat=0.0; |
2907 | double phone_long=0.0; |
||
264 | ligi | 2908 | //#endif |
261 | ligi | 2909 | |
382 | ligi | 2910 | //#if j2memap=="on" |
2911 | |||
2912 | Marker ufo_marker,home_marker; |
||
2913 | //#endif |
||
242 | ligi | 2914 | public void process_action(byte actionid) |
2915 | { |
||
2916 | switch(actionid) |
||
2917 | { |
||
493 | ligi | 2918 | case ACTIONID_BIG_SYMBOLS: |
2919 | chg_state(STATEID_BIG_SYMBOLS); |
||
2920 | break; |
||
382 | ligi | 2921 | |
2922 | case ACTIONID_SELECT_MIXER: |
||
2923 | chg_state(STATEID_SELECT_MIXER); |
||
2924 | break; |
||
2925 | |||
2926 | case ACTIONID_SELECT_DUBWISEDIR: |
||
2927 | chg_state(STATEID_FILEOPEN); |
||
2928 | break; |
||
2929 | |||
2930 | //#if j2memap=="on" |
||
2931 | case ACTIONID_MAP: |
||
2932 | |||
2933 | |||
2934 | int default_zoom=14; // TODO calc of distance - kopter<>home |
||
2935 | |||
2936 | try { |
||
2937 | |||
2938 | |||
2939 | |||
2940 | // ufo_marker=new Marker(UtilMidp.parseFloat(""+(mk.gps_position.Longitude/10000000d)),UtilMidp.parseFloat(""+(mk.gps_position.Latitude/10000000d))); |
||
2941 | |||
2942 | ufo_marker=new Marker(UtilMidp.parseFloat(mk.gps_position.gps_format_str(mk.gps_position.Longitude,GPS_FORMAT_DECIMAL)),UtilMidp.parseFloat(mk.gps_position.gps_format_str(mk.gps_position.Latitude,GPS_FORMAT_DECIMAL))); |
||
2943 | ufo_marker.iconImage=icon_img; |
||
2944 | ufo_marker.m_type=MarkerStyle.ICON_IMAGE; |
||
2945 | ufo_marker.name="Kopter"; |
||
2946 | ufo_marker.description="This is the Kopter!"; |
||
2947 | |||
2948 | root.m_map.m_listMyPlaces.addElement(ufo_marker); |
||
2949 | |||
2950 | root.m_map.gotoLonLat(UtilMidp.parseFloat(mk.gps_position.gps_format_str(mk.gps_position.Longitude,GPS_FORMAT_DECIMAL)),UtilMidp.parseFloat(mk.gps_position.gps_format_str(mk.gps_position.Latitude,GPS_FORMAT_DECIMAL)) ,default_zoom); |
||
2951 | } |
||
2952 | catch(Exception e) {} |
||
2953 | |||
2954 | |||
2955 | //#if location=="on" |
||
2956 | //#if cldc11=="on" |
||
2957 | if (!((phone_lat==0.0)&&(phone_long==0.0)))try { |
||
2958 | |||
2959 | home_marker=new Marker(UtilMidp.parseFloat(""+phone_long),UtilMidp.parseFloat(""+phone_lat)); |
||
2960 | home_marker.name="HomePos"; |
||
2961 | home_marker.description="This is home!"; |
||
2962 | root.m_map.m_listMyPlaces.addElement(home_marker); |
||
2963 | |||
2964 | |||
2965 | root.m_map.gotoLonLat(UtilMidp.parseFloat(""+phone_long) ,UtilMidp.parseFloat(""+phone_lat),default_zoom); |
||
2966 | |||
2967 | } |
||
2968 | catch(Exception e) {} |
||
2969 | //#endif |
||
2970 | //#endif |
||
2971 | |||
2972 | chg_state(STATEID_MAP); |
||
2973 | break; |
||
2974 | //#endif |
||
269 | ligi | 2975 | case ACTIONID_SETTING_LOADFANCY: |
2976 | settings.load_fancy_defaults(); |
||
2977 | break; |
||
2978 | |||
2979 | case ACTIONID_SETTING_LOADPLAIN: |
||
2980 | settings.load_plain_defaults(); |
||
2981 | break; |
||
2982 | |||
2983 | case ACTIONID_RECONNECT: |
||
2984 | mk.close_connections(false); |
||
2985 | break; |
||
258 | ligi | 2986 | case ACTIONID_UPDATE_DUBWISE: |
2987 | try |
||
2988 | { |
||
2989 | 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"); |
||
2990 | } |
||
2991 | catch(Exception e) { } |
||
2992 | break; |
||
2993 | |||
261 | ligi | 2994 | |
2995 | case ACTIONID_SHOWPHONEGPS: |
||
2996 | chg_state(STATEID_SHOWPHONEGPS); |
||
2997 | break; |
||
2998 | |||
242 | ligi | 2999 | case ACTIONID_PARAM_LOAD_MOBILE: |
3000 | try |
||
3001 | { |
||
3002 | RecordStore recStore = RecordStore.openRecordStore(PARAM_SAVE_STORE_NAME , true ); |
||
3003 | |||
3004 | if (recStore.getNumRecords()==1) |
||
3005 | { |
||
3006 | ByteArrayInputStream bin = new ByteArrayInputStream(recStore.getRecord(1)); |
||
3007 | DataInputStream din = new DataInputStream( bin ); |
||
252 | ligi | 3008 | |
3009 | |||
3010 | // params_version |
||
3011 | if ( mk.params.params_version!=din.readInt()) |
||
3012 | { |
||
382 | ligi | 3013 | act_msg=l(STRINGID_PARAMSINCOMPATIBLE); |
252 | ligi | 3014 | chg_state(STATEID_ERROR_MSG); |
3015 | break; |
||
3016 | } |
||
3017 | |||
3018 | int p_length=din.readInt(); |
||
3019 | params2masswrite=new int[5][p_length]; |
||
3020 | |||
3021 | for ( int p=0;p<5;p++) |
||
3022 | for ( int p_pos=0;p_pos<p_length;p_pos++) |
||
3023 | params2masswrite[p][p_pos]=din.readInt(); |
||
3024 | |||
3025 | param_masswrite_write_pos=0; |
||
3026 | chg_state(STATEID_PARAM_MASSWRITE); |
||
242 | ligi | 3027 | } |
3028 | else throw(new Exception("rms err")); |
||
3029 | recStore.closeRecordStore(); |
||
3030 | } |
||
3031 | catch (Exception e) |
||
3032 | { |
||
382 | ligi | 3033 | act_msg=l(STRINGID_NOPARAMSONMOBILE); |
242 | ligi | 3034 | chg_state(STATEID_ERROR_MSG); |
3035 | } |
||
206 | ligi | 3036 | |
242 | ligi | 3037 | |
3038 | break; |
||
3039 | |||
255 | ligi | 3040 | case ACTIONID_SELECT_FIRMWARE: |
382 | ligi | 3041 | fw_loader=new FirmwareLoader(116,this); |
255 | ligi | 3042 | chg_state(STATEID_SELECT_FIRMWARE); |
3043 | break; |
||
242 | ligi | 3044 | case ACTIONID_PARAM_COPY_MOBILE: |
3045 | read_paramset_intension_save=true; |
||
3046 | chg_state(STATEID_READ_PARAMS); |
||
3047 | break; |
||
3048 | |||
3049 | case ACTIONID_PARAM_MENU: |
||
3050 | chg_state(STATEID_PARAM_MENU); |
||
3051 | break; |
||
3052 | |||
3053 | case ACTIONID_PARAM_WRITE_OK: |
||
382 | ligi | 3054 | act_msg=l(STRINGID_PARAMWRITEOK); |
242 | ligi | 3055 | chg_state(STATEID_SUCCESS_MSG); |
3056 | break; |
||
3057 | case ACTIONID_HORIZON: |
||
3058 | chg_state(STATEID_HORIZON); |
||
3059 | break; |
||
3060 | |||
3061 | case ACTIONID_RENAME_PARAMS: |
||
3062 | act_input_str=mk.params.getParamName(mk.params.act_paramset); |
||
3063 | ipinput_pos=0; |
||
3064 | chg_state(STATEID_STRINGINPUT); |
||
3065 | break; |
||
3066 | |||
3067 | |||
3068 | case ACTIONID_BACK_TO_CONNDETAILS: |
||
3069 | chg_state(STATEID_CONN_DETAILS); |
||
3070 | break; |
||
3071 | |||
3072 | case ACTIONID_RESET_PARAMS: |
||
3073 | chg_state(STATEID_RESET_PARAMS); |
||
3074 | break; |
||
3075 | |||
3076 | case ACTIONID_FLASH: |
||
382 | ligi | 3077 | chg_state(STATEID_GET_AVRSIG); |
242 | ligi | 3078 | break; |
3079 | |||
3080 | case ACTIONID_DATABUFF: |
||
3081 | chg_state(STATEID_DATABUFF); |
||
3082 | break; |
||
3083 | |||
3084 | case ACTIONID_NC_ERRORS: |
||
382 | ligi | 3085 | act_msg=null; |
242 | ligi | 3086 | chg_state(STATEID_ERROR_MSG); |
3087 | break; |
||
3088 | |||
3089 | case ACTIONID_ABOUT: |
||
3090 | chg_state(STATEID_ABOUT); |
||
3091 | break; |
||
3092 | |||
3093 | case ACTIONID_CONN_DETAILS: |
||
3094 | chg_state(STATEID_CONN_DETAILS); |
||
3095 | break; |
||
3096 | |||
3097 | case ACTIONID_QUIT: |
||
3098 | quit=true; |
||
3099 | break; |
||
3100 | |||
3101 | case ACTIONID_SWITCH_NC: |
||
3102 | mk.switch_to_navi(); |
||
3103 | break; |
||
3104 | |||
3105 | case ACTIONID_SWITCH_FC: |
||
3106 | mk.switch_to_fc(); |
||
3107 | break; |
||
3108 | |||
3109 | case ACTIONID_SWITCH_MK3MAG: |
||
3110 | mk.switch_to_mk3mag(); |
||
3111 | break; |
||
3112 | |||
3113 | case ACTIONID_GRAPH: |
||
3114 | chg_state(STATEID_GRAPH); |
||
3115 | break; |
||
3116 | |||
3117 | case ACTIONID_KEYCONTROL: |
||
3118 | chg_state(STATEID_KEYCONTROL); |
||
3119 | break; |
||
3120 | |||
3121 | case ACTIONID_LCD : |
||
245 | ligi | 3122 | chg_state(STATEID_LCD); |
242 | ligi | 3123 | break; |
3124 | |||
3125 | |||
3126 | case ACTIONID_PROXY: |
||
3127 | |||
3128 | chg_state(STATEID_IPINPUT); |
||
3129 | break; |
||
3130 | |||
3131 | case ACTIONID_DEVICESELECT: |
||
3132 | chg_state(STATEID_SCANNING); |
||
3133 | break; |
||
3134 | |||
3135 | case ACTIONID_RAWDEBUG: |
||
3136 | chg_state(STATEID_RAWDEBUG); |
||
3137 | break; |
||
3138 | |||
3139 | case ACTIONID_SETTINGS: |
||
3140 | chg_state(STATEID_SETTINGSMENU); |
||
3141 | break; |
||
3142 | |||
269 | ligi | 3143 | case ACTIONID_SETTING_OPTIONS: |
3144 | chg_state(STATEID_SETTING_OPTIONS); |
||
3145 | break; |
||
3146 | |||
242 | ligi | 3147 | case ACTIONID_RCDATA: |
3148 | chg_state(STATEID_STICKVIEW); |
||
3149 | break; |
||
3150 | |||
3151 | case ACTIONID_CAM: |
||
3152 | chg_state(STATEID_CAMMODE); |
||
3153 | break; |
||
3154 | |||
3155 | case ACTIONID_GPSDATA: |
||
3156 | chg_state(STATEID_GPSVIEW); |
||
3157 | break; |
||
3158 | |||
3159 | |||
3160 | case ACTIONID_MOTORTEST : |
||
3161 | chg_state(STATEID_MOTORTEST); |
||
3162 | break; |
||
3163 | |||
3164 | |||
3165 | case ACTIONID_EDIT_PARAMS: |
||
3166 | chg_state(STATEID_EDIT_PARAMS); |
||
3167 | break; |
||
3168 | case ACTIONID_SELECT_PARAMS: |
||
3169 | select_paramset4edit=true; |
||
3170 | read_paramset_intension_save=false; |
||
3171 | if (settings.reload_settings) |
||
3172 | { |
||
3173 | |||
3174 | mk.watchdog.act_paramset=0; |
||
3175 | mk.params.reset(); |
||
3176 | |||
3177 | chg_state(STATEID_READ_PARAMS); |
||
3178 | } |
||
3179 | else |
||
3180 | { |
||
3181 | if (mk.watchdog.act_paramset!=5) |
||
3182 | chg_state(STATEID_READ_PARAMS); |
||
3183 | else |
||
3184 | chg_state(STATEID_SELECT_PARAMSET); |
||
3185 | } |
||
3186 | break; |
||
3187 | |||
3188 | |||
3189 | case ACTIONID_WRITE_PARAM_AS: |
||
3190 | select_paramset4edit=false; |
||
3191 | chg_state(STATEID_SELECT_PARAMSET); |
||
3192 | break; |
||
3193 | |||
3194 | case ACTIONID_WRITE_PARAMS: |
||
3195 | mk.write_params(mk.params.act_paramset); |
||
382 | ligi | 3196 | act_msg=l(STRINGID_SAVEDSETTINGS); // too optimistic |
242 | ligi | 3197 | nextstate=STATEID_HANDLE_PARAMS; |
3198 | chg_state(STATEID_SUCCESS_MSG); |
||
3199 | break; |
||
3200 | |||
3201 | case ACTIONID_UNDO_PARAMS: |
||
3202 | mk.params.use_backup(); |
||
382 | ligi | 3203 | act_msg=l(STRINGID_SETTINGSUNDOOK); // too optimistic |
242 | ligi | 3204 | nextstate=STATEID_HANDLE_PARAMS; |
3205 | chg_state(STATEID_SUCCESS_MSG); |
||
3206 | |||
3207 | break; |
||
3208 | |||
3209 | case ACTIONID_MAINMENU: |
||
3210 | chg_state(STATEID_MAINMENU); |
||
3211 | break; |
||
3212 | |||
3213 | case ACTIONID_DEBUG: |
||
382 | ligi | 3214 | chg_state(STATEID_DUBWISE_VALUES); |
3215 | // debug.showing=true; |
||
242 | ligi | 3216 | break; |
3217 | |||
3218 | case ACTIONID_TRAFFIC: |
||
3219 | chg_state(STATEID_TRAFFIC); |
||
3220 | break; |
||
3221 | |||
3222 | case ACTIONID_CONNECT_TCP: |
||
3223 | ipinput4proxy=false; |
||
3224 | chg_state(STATEID_IPINPUT); |
||
3225 | break; |
||
3226 | |||
3227 | case ACTIONID_SCAN_BT: |
||
3228 | chg_state(STATEID_SCANNING); |
||
3229 | break; |
||
3230 | |||
3231 | case ACTIONID_SELECT_COM: |
||
3232 | chg_state(STATEID_SELECT_COMPORT); |
||
3233 | break; |
||
3234 | |||
3235 | case ACTIONID_PROXY_INPUT: |
||
3236 | ipinput4proxy=true; |
||
3237 | chg_state(STATEID_IPINPUT); |
||
3238 | break; |
||
3239 | |||
3240 | } |
||
3241 | |||
3242 | } |
||
3243 | |||
3244 | |||
382 | ligi | 3245 | |
3246 | |||
3247 | |||
3248 | public void pointerDragged (int pointer_x, int pointer_y) |
||
3249 | { |
||
3250 | if ((pointer_x>canvas_width) || (pointer_y>canvas_height)) return; // bugfix/workaround - pointer in offscreen - e.g. wtk when not in fullscreen |
||
3251 | |||
3252 | System.out.println("p_y: " + pointer_y + "ch:" + canvas_height); |
||
3253 | byte act_pointer_row; |
||
3254 | |||
3255 | if (lcd_lines.length>max_lines) |
||
3256 | act_pointer_row=(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*max_lines))/lcd_img.getHeight() +lcd_off ); |
||
3257 | else |
||
3258 | act_pointer_row=(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight() ); |
||
3259 | |||
3260 | if ((act_pointer_row>=lcd_lines.length)||(act_pointer_row<0)) return; |
||
3261 | |||
3262 | switch(state) |
||
3263 | { |
||
3264 | case STATEID_PARAM_MENU: |
||
3265 | case STATEID_CONN_DETAILS: |
||
3266 | case STATEID_HANDLE_PARAMS: |
||
3267 | case STATEID_FILEOPEN: |
||
3268 | case STATEID_TRAFFIC: |
||
3269 | case STATEID_SELECT_COMPORT: |
||
3270 | case STATEID_MAINMENU: |
||
3271 | case STATEID_SETTING_OPTIONS: |
||
3272 | case STATEID_SELECT_PARAMSET: |
||
3273 | case STATEID_DEVICESELECT: |
||
3274 | case STATEID_SELECT_MIXER: |
||
3275 | |||
3276 | act_menu_select=act_pointer_row; |
||
3277 | } |
||
3278 | |||
3279 | } |
||
3280 | |||
206 | ligi | 3281 | public void pointerPressed (int pointer_x, int pointer_y) |
3282 | { |
||
242 | ligi | 3283 | |
382 | ligi | 3284 | if ((pointer_x>canvas_width) || (pointer_y>canvas_height)) return; // bugfix - pointer in offscreen - e.g. wtk when not in fullscreen |
3285 | |||
3286 | byte act_pointer_row; |
||
3287 | |||
3288 | if (lcd_lines.length>max_lines) |
||
3289 | act_pointer_row=(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*max_lines))/lcd_img.getHeight() +lcd_off ); |
||
3290 | else |
||
3291 | act_pointer_row=(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight() ); |
||
3292 | |||
3293 | |||
206 | ligi | 3294 | if (pointer_y<lcd_img.getHeight()) |
3295 | keyPressed(KEY_STAR); |
||
3296 | else |
||
382 | ligi | 3297 | { if (act_pointer_row<0) return; |
3298 | |||
242 | ligi | 3299 | if (pointer_y>canvas_height-lcd_img.getHeight()*lcd_lines.length) |
3300 | switch(state) |
||
206 | ligi | 3301 | { |
242 | ligi | 3302 | case STATEID_SETTINGSMENU: |
382 | ligi | 3303 | case STATEID_EDIT_PARAMS: |
3304 | case STATEID_MOTORTEST: |
||
3305 | act_editor.pointer_press(pointer_x,act_pointer_row ); |
||
3306 | break; |
||
3307 | /* |
||
242 | ligi | 3308 | |
382 | ligi | 3309 | // settings_editor.pointer_press(pointer_x,(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight())) ; |
3310 | settings_editor.pointer_press(pointer_x,act_pointer_row ); |
||
242 | ligi | 3311 | break; |
3312 | |||
3313 | |||
382 | ligi | 3314 | // params_editor.pointer_press(pointer_x,(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight()) ); |
3315 | |||
3316 | params_editor.pointer_press(pointer_x,act_pointer_row ); |
||
242 | ligi | 3317 | break; |
3318 | |||
382 | ligi | 3319 | |
3320 | |||
3321 | motor_tester.pointer_press(pointer_x,act_pointer_row ); |
||
3322 | |||
3323 | break; |
||
3324 | */ |
||
245 | ligi | 3325 | case STATEID_LCD: |
3326 | if (pointer_x<(canvas_width/2)) |
||
3327 | keyPressed(getKeyCode(LEFT)); |
||
3328 | else |
||
3329 | keyPressed(getKeyCode(RIGHT)); |
||
3330 | break; |
||
382 | ligi | 3331 | |
3332 | case STATEID_SELECT_MIXER: |
||
242 | ligi | 3333 | case STATEID_PARAM_MENU: |
206 | ligi | 3334 | case STATEID_CONN_DETAILS: |
242 | ligi | 3335 | case STATEID_HANDLE_PARAMS: |
206 | ligi | 3336 | case STATEID_FILEOPEN: |
3337 | case STATEID_TRAFFIC: |
||
3338 | case STATEID_SELECT_COMPORT: |
||
3339 | case STATEID_MAINMENU: |
||
269 | ligi | 3340 | case STATEID_SETTING_OPTIONS: |
206 | ligi | 3341 | case STATEID_SELECT_PARAMSET: |
3342 | case STATEID_DEVICESELECT: |
||
382 | ligi | 3343 | |
3344 | |||
242 | ligi | 3345 | // if (pointer_y>canvas_height-lcd_img.getHeight()*menu_items.length) |
3346 | // { |
||
382 | ligi | 3347 | /* |
3348 | if (lcd_lines.length>max_lines) |
||
3349 | act_menu_select=(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*max_lines))/lcd_img.getHeight() +lcd_off ); |
||
242 | ligi | 3350 | else |
382 | ligi | 3351 | act_menu_select=(byte)((pointer_y-(canvas_height-lcd_img.getHeight()*lcd_lines.length))/lcd_img.getHeight() ); |
3352 | |||
3353 | */ |
||
3354 | |||
3355 | if (act_menu_select!=act_pointer_row) |
||
3356 | act_menu_select=act_pointer_row; |
||
3357 | else |
||
3358 | keyPressed(getKeyCode(FIRE)); |
||
242 | ligi | 3359 | //} |
206 | ligi | 3360 | break; |
242 | ligi | 3361 | } |
3362 | |||
382 | ligi | 3363 | } |
206 | ligi | 3364 | } |
213 | ligi | 3365 | |
3366 | |||
3367 | int last_keycode=-1; |
||
3368 | int repeat_keycode=0; |
||
3369 | |||
206 | ligi | 3370 | public void keyPressed(int keyCode) |
3371 | { |
||
382 | ligi | 3372 | |
3373 | |||
3374 | key_bitfield|=keyCode2mask(keyCode); |
||
3375 | |||
3376 | if ((state==STATEID_MAINMENU)&&(keyCode==beta_unlock_code[beta_unlock_pos++])) |
||
3377 | { |
||
3378 | if (beta_unlock_pos==beta_unlock_code.length) |
||
3379 | { |
||
3380 | beta_unlock_pos=0; |
||
3381 | nextstate=state; |
||
3382 | act_msg="Hi Betatester" ; |
||
3383 | chg_state(STATEID_SUCCESS_MSG); |
||
3384 | settings.set_betatester(); |
||
3385 | return; |
||
3386 | } |
||
3387 | |||
3388 | } |
||
3389 | else |
||
3390 | beta_unlock_pos=0; |
||
3391 | |||
3392 | |||
3393 | |||
213 | ligi | 3394 | if (last_keycode==keyCode) |
3395 | repeat_keycode++; |
||
3396 | else |
||
3397 | { |
||
3398 | repeat_keycode=0; |
||
3399 | last_keycode=keyCode; |
||
3400 | } |
||
3401 | |||
206 | ligi | 3402 | debug.log("KeyCode:"+keyCode); |
3403 | // key-actions common in all states |
||
3404 | debug.process_key(keyCode); |
||
3405 | |||
382 | ligi | 3406 | |
3407 | if ( key_bitfield==(keyCode2mask(KEY_NUM0)|keyCode2mask(KEY_STAR))) |
||
3408 | { |
||
3409 | chg_state(STATEID_MAINMENU); |
||
3410 | return; |
||
3411 | } |
||
3412 | |||
3413 | if (state!=STATEID_MAP) |
||
3414 | { |
||
229 | ligi | 3415 | if (((keyCode==KEY_STAR) || (keyCode==settings.key_back) )&&(state!=STATEID_KEYCONTROL))//&&(state!= STATEID_STRINGINPUT)) |
206 | ligi | 3416 | { |
229 | ligi | 3417 | chg_state(STATEID_MAINMENU); |
3418 | return; |
||
206 | ligi | 3419 | } |
382 | ligi | 3420 | } |
213 | ligi | 3421 | |
221 | ligi | 3422 | if (((keyCode==KEY_POUND)||(keyCode==settings.key_fullscreen))&&(state!=STATEID_KEYCONTROL)) |
206 | ligi | 3423 | { |
220 | ligi | 3424 | settings.toggle_fullscreen(); |
3425 | |||
206 | ligi | 3426 | return; |
3427 | } |
||
3428 | |||
3429 | // key actions per state |
||
3430 | switch(state) |
||
3431 | { |
||
382 | ligi | 3432 | //#if j2memap=="on" |
3433 | case STATEID_MAP: |
||
3434 | root.m_map.keyPressed(keyCode); |
||
3435 | break; |
||
3436 | //#endif |
||
224 | ligi | 3437 | case STATEID_SUCCESS_MSG: |
3438 | chg_state(nextstate); |
||
3439 | break; |
||
3440 | case STATEID_ERROR_MSG: |
||
206 | ligi | 3441 | chg_state(STATEID_MAINMENU); |
3442 | break; |
||
213 | ligi | 3443 | case STATEID_STRINGINPUT: |
3444 | if ((keyCode>=KEY_NUM2)&&(keyCode<=KEY_NUM9)) |
||
3445 | { |
||
3446 | act_input_str=act_input_str.substring(0,ipinput_pos) + |
||
3447 | |||
3448 | |||
3449 | (char)( 97 + (keyCode-KEY_NUM2)*3 + ((keyCode>KEY_NUM7)?1:0) +(repeat_keycode%(((keyCode==KEY_NUM7)||(keyCode==KEY_NUM9))?4:3))) |
||
3450 | |||
3451 | + act_input_str.substring(ipinput_pos+1,act_input_str.length()); |
||
3452 | } |
||
3453 | else if ((keyCode==KEY_NUM0)) |
||
3454 | { |
||
3455 | act_input_str=act_input_str.substring(0,ipinput_pos) + |
||
3456 | act_input_str.substring(ipinput_pos+1,act_input_str.length()); |
||
3457 | } |
||
3458 | else |
||
3459 | { |
||
3460 | switch (getGameAction (keyCode)) |
||
3461 | { |
||
3462 | |||
3463 | case LEFT: |
||
3464 | if(ipinput_pos>0) ipinput_pos--; |
||
3465 | break; |
||
3466 | |||
3467 | case RIGHT: |
||
3468 | if(ipinput_pos<19) ipinput_pos++; |
||
3469 | break; |
||
3470 | |||
3471 | case UP: |
||
3472 | act_input_str=act_input_str.substring(0,ipinput_pos) + |
||
3473 | (char)((byte) act_input_str.charAt(ipinput_pos)-1) + act_input_str.substring(ipinput_pos+1,act_input_str.length()); |
||
3474 | |||
3475 | break; |
||
3476 | case DOWN: |
||
3477 | act_input_str=act_input_str.substring(0,ipinput_pos) + |
||
3478 | (char)((byte) act_input_str.charAt(ipinput_pos)+1) + act_input_str.substring(ipinput_pos+1,act_input_str.length()); |
||
3479 | |||
3480 | break; |
||
3481 | |||
3482 | |||
3483 | case FIRE: |
||
3484 | mk.params.set_name(act_input_str); |
||
3485 | chg_state(STATEID_HANDLE_PARAMS); |
||
3486 | break; |
||
3487 | } |
||
3488 | |||
3489 | } |
||
3490 | if (act_input_str.length()<=ipinput_pos) act_input_str+=" "; |
||
3491 | break; |
||
206 | ligi | 3492 | case STATEID_IPINPUT: |
3493 | if ((keyCode>=KEY_NUM0)&&(keyCode<=KEY_NUM9)) |
||
3494 | { |
||
223 | ligi | 3495 | 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 | 3496 | |
3497 | if(ipinput_pos<19) ipinput_pos++; |
||
3498 | if ((ipinput_pos<18)&&(((ipinput_pos+1)%4)==0))ipinput_pos++; |
||
3499 | } |
||
3500 | else |
||
3501 | switch (getGameAction (keyCode)) |
||
3502 | { |
||
3503 | case LEFT: |
||
3504 | if(ipinput_pos>0) ipinput_pos--; |
||
3505 | if (((ipinput_pos+1)%4)==0)ipinput_pos--; |
||
3506 | break; |
||
3507 | |||
3508 | case RIGHT: |
||
3509 | if(ipinput_pos<19) ipinput_pos++; |
||
3510 | if(ipinput_pos<18)if (((ipinput_pos+1)%4)==0)ipinput_pos++; |
||
3511 | break; |
||
3512 | |||
3513 | case UP: |
||
223 | ligi | 3514 | 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 | 3515 | |
3516 | break; |
||
3517 | |||
3518 | case DOWN: |
||
223 | ligi | 3519 | 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 | 3520 | |
3521 | |||
3522 | case FIRE: |
||
3523 | if (ipinput4proxy) |
||
3524 | { |
||
3525 | settings.act_proxy_ip=act_edit_ip; |
||
223 | ligi | 3526 | mk.do_proxy("socket://"+DUBwiseHelper.ip_str(settings.act_proxy_ip,false)); |
206 | ligi | 3527 | chg_state(STATEID_PROXY); |
3528 | } |
||
3529 | else |
||
3530 | { |
||
3531 | settings.act_conn_ip=act_edit_ip; |
||
223 | ligi | 3532 | connect_mk("socket://"+DUBwiseHelper.ip_str(settings.act_conn_ip,false),"TCP/IP Connection"); |
206 | ligi | 3533 | chg_state(STATEID_CONN_DETAILS); |
3534 | } |
||
3535 | |||
3536 | break; |
||
3537 | |||
3538 | } |
||
3539 | break; |
||
3540 | |||
3541 | case STATEID_GPSVIEW: |
||
3542 | if (keyCode == this.KEY_NUM0) |
||
3543 | mk.set_gps_target(mk.gps_position.Latitude,mk.gps_position.Longitude); |
||
3544 | if (keyCode == this.KEY_NUM1) |
||
3545 | mk.gps_position.push_wp(); |
||
3546 | if (keyCode == this.KEY_NUM2) |
||
3547 | chg_state(STATEID_FILEOPEN); |
||
3548 | if (keyCode == this.KEY_NUM3) |
||
3549 | mk.set_gps_target(mk.gps_position.LatWP[act_wp],mk.gps_position.LongWP[act_wp]); |
||
3550 | |||
3551 | |||
3552 | if (keyCode == this.KEY_NUM5) |
||
3553 | heading_offset= mk.debug_data.analog[26]; |
||
3554 | |||
3555 | switch (getGameAction (keyCode)) |
||
3556 | { |
||
3557 | case UP: |
||
3558 | if (act_wp!=0) act_wp--; |
||
3559 | break; |
||
3560 | |||
3561 | case DOWN: |
||
3562 | if (act_wp<mk.gps_position.last_wp) act_wp++; |
||
3563 | |||
3564 | break; |
||
3565 | |||
3566 | |||
3567 | } |
||
3568 | |||
3569 | |||
3570 | break; |
||
3571 | |||
3572 | case STATEID_ABOUT: |
||
3573 | |||
3574 | switch (getGameAction (keyCode)) |
||
3575 | { |
||
3576 | case UP: |
||
3577 | if (act_menu_select>=max_lines) |
||
3578 | act_menu_select--; |
||
3579 | break; |
||
3580 | |||
3581 | case DOWN: |
||
3582 | if (act_menu_select<lcd_lines.length-1) |
||
3583 | act_menu_select++; |
||
3584 | |||
3585 | break; |
||
3586 | |||
3587 | |||
3588 | } |
||
3589 | |||
3590 | |||
3591 | break; |
||
3592 | |||
3593 | |||
3594 | case STATEID_RAWDEBUG: |
||
3595 | |||
3596 | switch (getGameAction (keyCode)) |
||
3597 | { |
||
3598 | case UP: |
||
3599 | if (rawdebug_cursor_y==0) |
||
3600 | rawdebug_cursor_y=31; |
||
3601 | else |
||
3602 | rawdebug_cursor_y--; |
||
3603 | break; |
||
3604 | |||
3605 | case DOWN: |
||
3606 | if (rawdebug_cursor_y==31) |
||
3607 | rawdebug_cursor_y=0; |
||
3608 | else |
||
3609 | rawdebug_cursor_y++; |
||
3610 | break; |
||
3611 | |||
3612 | |||
3613 | } |
||
3614 | break; |
||
3615 | case STATEID_KEYCONTROL: |
||
3616 | if (keyCode==KEY_POUND) |
||
3617 | keycontrol_exit |= 1; |
||
3618 | else |
||
3619 | if (keyCode==KEY_STAR) |
||
3620 | keycontrol_exit |= 2; |
||
3621 | else |
||
219 | ligi | 3622 | mod_external_control_by_keycode(keyCode,(byte)1); |
3623 | |||
3624 | |||
3625 | |||
3626 | if (keycontrol_exit==3) |
||
3627 | chg_state(STATEID_MAINMENU); |
||
3628 | |||
3629 | /* |
||
206 | ligi | 3630 | if ((keyCode >= this.KEY_NUM0) && (keyCode < this.KEY_NUM8)) |
3631 | keycontrol_bitfield[0]|=1<<(keyCode-this.KEY_NUM0); |
||
3632 | else |
||
3633 | if ((keyCode >= this.KEY_NUM8) && (keyCode <= this.KEY_NUM9)) |
||
3634 | keycontrol_bitfield[1]|=1<<(keyCode-this.KEY_NUM8); |
||
3635 | |||
3636 | else |
||
3637 | switch (getGameAction (keyCode)) |
||
3638 | { |
||
3639 | case UP: |
||
3640 | keycontrol_bitfield[1]|=4; |
||
3641 | break; |
||
3642 | |||
3643 | case DOWN: |
||
3644 | keycontrol_bitfield[1]|=8; |
||
3645 | break; |
||
3646 | |||
3647 | |||
3648 | case LEFT: |
||
3649 | keycontrol_bitfield[1]|=16; |
||
3650 | break; |
||
3651 | |||
3652 | case RIGHT: |
||
3653 | keycontrol_bitfield[1]|=32; |
||
3654 | break; |
||
3655 | |||
3656 | case FIRE: |
||
3657 | keycontrol_bitfield[1]|=64; |
||
3658 | break; |
||
3659 | |||
3660 | } |
||
3661 | else |
||
3662 | mk.send_keys(keycontrol_bitfield); |
||
219 | ligi | 3663 | */ |
206 | ligi | 3664 | break; |
3665 | |||
3666 | |||
382 | ligi | 3667 | /* |
206 | ligi | 3668 | case STATEID_MOTORTEST: |
382 | ligi | 3669 | motor_tester.keypress(keyCode,getGameAction (keyCode)); |
3670 | |||
206 | ligi | 3671 | switch (getGameAction (keyCode)) |
3672 | { |
||
3673 | case UP: |
||
3674 | act_motor_increase=-1; |
||
3675 | break; |
||
3676 | |||
3677 | case DOWN: |
||
3678 | act_motor_increase=1; |
||
3679 | break; |
||
3680 | |||
3681 | case FIRE: |
||
3682 | motor_test_sel_all=!motor_test_sel_all; |
||
3683 | break; |
||
3684 | |||
3685 | case LEFT: |
||
3686 | act_motor--; |
||
3687 | if (act_motor<0) {act_motor=0; chg_state(STATEID_MAINMENU); } |
||
3688 | break; |
||
3689 | |||
3690 | case RIGHT: |
||
3691 | act_motor++; |
||
3692 | act_motor%=4; |
||
3693 | break; |
||
3694 | } |
||
3695 | |||
382 | ligi | 3696 | |
206 | ligi | 3697 | break; |
382 | ligi | 3698 | */ |
206 | ligi | 3699 | |
3700 | |||
3701 | /* |
||
3702 | case STATEID_HANDLsE_PARAMS: |
||
3703 | |||
3704 | menu_keypress(keyCode); |
||
3705 | break; |
||
3706 | */ |
||
3707 | /* |
||
3708 | case STATEID_TRAFFIC: |
||
3709 | if ( getGameAction (keyCode)==FIRE ) |
||
3710 | chg_state(STATEID_CONN_DETAILS); |
||
3711 | else |
||
3712 | menu_keypress(keyCode); |
||
3713 | break; |
||
3714 | */ |
||
3715 | |||
382 | ligi | 3716 | case STATEID_SELECT_MIXER: |
3717 | |||
3718 | case STATEID_SELECT_FIRMWARE: |
||
269 | ligi | 3719 | case STATEID_SETTING_OPTIONS: |
255 | ligi | 3720 | case STATEID_MAINMENU: |
3721 | case STATEID_SELECT_PARAMSET: |
||
3722 | case STATEID_SELECT_COMPORT: |
||
206 | ligi | 3723 | |
224 | ligi | 3724 | case STATEID_PARAM_MENU: |
206 | ligi | 3725 | case STATEID_TRAFFIC: |
3726 | case STATEID_CONN_DETAILS: |
||
3727 | case STATEID_HANDLE_PARAMS: |
||
220 | ligi | 3728 | |
255 | ligi | 3729 | //#if bluetooth=="on" |
3730 | case STATEID_DEVICESELECT: |
||
3731 | //#endif |
||
206 | ligi | 3732 | |
255 | ligi | 3733 | //#if fileapi=="on" |
3734 | case STATEID_FILEOPEN: |
||
3735 | //#endif |
||
222 | ligi | 3736 | |
255 | ligi | 3737 | menu_keypress(keyCode); |
206 | ligi | 3738 | break; |
3739 | |||
382 | ligi | 3740 | case STATEID_MOTORTEST: |
3741 | case STATEID_EDIT_PARAMS: |
||
255 | ligi | 3742 | case STATEID_SETTINGSMENU: |
382 | ligi | 3743 | act_editor.keypress(keyCode,getGameAction (keyCode)) ; |
206 | ligi | 3744 | break; |
3745 | |||
255 | ligi | 3746 | // handle menue |
3747 | // case STATEID_SELECT_SPEED_FORMAT: |
||
3748 | // case STATEID_SELECT_GPS_FORMAT: |
||
206 | ligi | 3749 | |
382 | ligi | 3750 | /* |
206 | ligi | 3751 | case STATEID_EDIT_PARAMS: |
3752 | params_editor.keypress(keyCode,getGameAction (keyCode)) ; |
||
3753 | break; |
||
382 | ligi | 3754 | */ |
245 | ligi | 3755 | case STATEID_LCD: |
206 | ligi | 3756 | |
3757 | if ((keyCode >= this.KEY_NUM0) && (keyCode <= this.KEY_NUM9)) |
||
3758 | mk.LCD.set_page(keyCode-this.KEY_NUM0); |
||
3759 | else |
||
3760 | switch (getGameAction (keyCode)) |
||
3761 | { |
||
3762 | case LEFT: |
||
3763 | case UP: |
||
3764 | mk.LCD.LCD_PREVPAGE(); |
||
3765 | break; |
||
3766 | |||
3767 | case RIGHT: |
||
3768 | case DOWN: |
||
3769 | mk.LCD.LCD_NEXTPAGE(); |
||
3770 | break; |
||
3771 | |||
3772 | |||
3773 | |||
3774 | } |
||
3775 | break; |
||
3776 | } |
||
3777 | |||
3778 | |||
3779 | |||
3780 | } |
||
3781 | |||
3782 | |||
3783 | |||
3784 | |||
3785 | |||
3786 | |||
3787 | |||
3788 | |||
3789 | } |
||
3790 | |||
3791 |