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