Rev 325 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 325 | Rev 390 | ||
---|---|---|---|
1 | /*************************************************************** |
1 | /*************************************************************** |
2 | * |
2 | * |
3 | * minimal canvas to test Abstraction layer on various Phones |
3 | * minimal canvas to test Abstraction layer on various Phones |
4 | * |
4 | * |
5 | * Author: Marcus -LiGi- Bueschleb |
5 | * Author: Marcus -LiGi- Bueschleb |
6 | * Project-Start: 9/2007 |
6 | * Project-Start: 9/2007 |
7 | * Mailto: ligi@smart4mobile.de |
7 | * Mailto: ligi@smart4mobile.de |
8 | * Licence: Creative Commons / Non Commercial |
8 | * Licence: Creative Commons / Non Commercial |
- | 9 | * ( see README for exact terms of usage) |
|
9 | * Big Up: Holger&Ingo |
10 | * Big Up: Holger&Ingo |
10 | ***************************************************************/ |
11 | ***************************************************************/ |
11 | 12 | ||
12 | import javax.microedition.lcdui.*; |
13 | import javax.microedition.lcdui.*; |
13 | import javax.microedition.rms.*; |
14 | import javax.microedition.rms.*; |
14 | 15 | ||
15 | 16 | ||
16 | public class MKMiniCanvas |
17 | public class MKMiniCanvas |
17 | extends Canvas |
18 | extends Canvas |
18 | implements Runnable |
19 | implements Runnable |
19 | { |
20 | { |
- | 21 | ||
20 | 22 | // name/handle for the recordStore to memorize some stuff |
|
21 | private final static String RECORD_STORE_NAME="bluetoothurl"; |
23 | private final static String RECORD_STORE_NAME="bluetoothurl"; |
22 | 24 | ||
23 | private BTSearcher bt_scanner; |
25 | private BTSearcher bt_scanner; |
24 | public MKCommunicator mk=null; |
26 | public MKCommunicator mk=null; |
25 | private MKStatistics mk_stat=null; |
27 | private MKStatistics mk_stat=null; |
26 | private MKParamsEditor params_editor=null; |
28 | private MKParamsEditor params_editor=null; |
27 | 29 | ||
28 | 30 | ||
29 | private String err=""; |
31 | private String err=""; |
30 | private DUBwise root; |
32 | private DUBwise root; |
31 | 33 | ||
32 | private Image bg_img; |
34 | private Image bg_img; |
33 | private Image bt_img; |
35 | private Image bt_img; |
34 | private Image lcd_img; |
36 | private Image lcd_img; |
35 | private Image load_img; |
37 | private Image load_img; |
36 | 38 | ||
37 | 39 | ||
38 | public int[] nick_line_pos_data; |
40 | public int[] nick_line_pos_data; |
39 | public int[] roll_line_pos_data; |
41 | public int[] roll_line_pos_data; |
40 | 42 | ||
41 | public int[] accnick_line_pos_data; |
43 | public int[] accnick_line_pos_data; |
42 | public int[] accroll_line_pos_data; |
44 | public int[] accroll_line_pos_data; |
43 | 45 | ||
44 | public int lcd_char_width=0; |
46 | public int lcd_char_width=0; |
45 | public int lcd_char_height=0; |
47 | public int lcd_char_height=0; |
46 | 48 | ||
47 | public int frame_pos=0; |
49 | public int frame_pos=0; |
48 | 50 | ||
49 | int line_scaler=20; |
51 | int line_scaler=20; |
50 | 52 | ||
51 | public int line_middle_y; |
53 | public int line_middle_y; |
52 | 54 | ||
53 | boolean quit=false; |
55 | boolean quit=false; |
54 | boolean rescan=true; |
56 | boolean rescan=true; |
55 | int bg_offset=0; |
57 | int bg_offset=0; |
- | 58 | ||
56 | 59 | // variable to hold the current state |
|
57 | public int state=-1; |
- | |
58 | 60 | public int state=-1; |
|
59 | - | ||
60 | 61 | ||
61 | // id for each state - must just be uniq - order dont matter |
62 | // id for each state - must just be uniq - order isnt important |
62 | public final static int STATEID_SCANNING =0; |
63 | public final static int STATEID_SCANNING =0; |
63 | public final static int STATEID_DEVICESELECT =1; |
64 | public final static int STATEID_DEVICESELECT =1; |
64 | public final static int STATEID_MAINMENU =2; |
65 | public final static int STATEID_MAINMENU =2; |
65 | public final static int STATEID_MOTORTEST =3; |
66 | public final static int STATEID_MOTORTEST =3; |
66 | public final static int STATEID_SELECT_PARAMSET =4; |
67 | public final static int STATEID_SELECT_PARAMSET =4; |
67 | public final static int STATEID_EDIT_PARAMS =5; |
68 | public final static int STATEID_EDIT_PARAMS =5; |
68 | public final static int STATEID_HANDLE_PARAMS =6; |
69 | public final static int STATEID_HANDLE_PARAMS =6; |
69 | public final static int STATEID_FLIGHTVIEW =7; |
70 | public final static int STATEID_FLIGHTVIEW =7; |
70 | 71 | ||
71 | 72 | ||
72 | public boolean fullscreen=false; |
73 | public boolean fullscreen=false; |
73 | public int act_motor=0; |
74 | public int act_motor=0; |
74 | public int act_motor_increase=0; |
75 | public int act_motor_increase=0; |
75 | public boolean motor_test_sel_all=false; |
76 | public boolean motor_test_sel_all=false; |
76 | 77 | ||
77 | public String[] main_menu_items={"Telemetry" , "Motor Test" , "Flight Settings","(NA)Tool Settings","Proxy","Change Device" , "Quit " }; |
78 | public String[] main_menu_items={"Telemetry" , "Motor Test" , "Flight Settings","(NA)Tool Settings","Proxy","Change Device" , "Quit " }; |
78 | public final static int MAINMENU_TELEMETRY =0; |
79 | public final static int MAINMENU_TELEMETRY =0; |
79 | public final static int MAINMENU_MOTORTES =1; |
80 | public final static int MAINMENU_MOTORTES =1; |
80 | public final static int MAINMENU_PARAMS =2; |
81 | public final static int MAINMENU_PARAMS =2; |
81 | public final static int MAINMENU_SETTINGS =3; |
82 | public final static int MAINMENU_SETTINGS =3; |
82 | public final static int MAINMENU_PROXY =4; |
83 | public final static int MAINMENU_PROXY =4; |
83 | public final static int MAINMENU_DEVICESELECT =5; |
84 | public final static int MAINMENU_DEVICESELECT =5; |
84 | public final static int MAINMENU_QUIT =6; |
85 | public final static int MAINMENU_QUIT =6; |
85 | 86 | ||
86 | int local_max=-1; |
87 | int local_max=-1; |
87 | 88 | ||
88 | int y_off=0; |
89 | int y_off=0; |
89 | int spacer=0; |
90 | int spacer=0; |
90 | int[] motor_test = {0,0,0,0}; |
91 | int[] motor_test = {0,0,0,0}; |
91 | 92 | ||
92 | 93 | ||
93 | String[] menu_items; |
94 | String[] menu_items; |
94 | int act_menu_select=0; |
95 | int act_menu_select=0; |
95 | 96 | ||
96 | String[] lcd_lines =null; |
97 | String[] lcd_lines =null; |
97 | 98 | ||
98 | public void paint_menu(Graphics g) |
99 | public void paint_menu(Graphics g) |
99 | { |
100 | { |
100 | for ( int i=0;i<menu_items.length;i++) |
101 | for ( int i=0;i<menu_items.length;i++) |
101 | lcd_lines[i]=(act_menu_select==i?"# ":" ") + menu_items[i]; |
102 | lcd_lines[i]=(act_menu_select==i?"# ":" ") + menu_items[i]; |
102 | paint_lcd(g,true); |
103 | paint_lcd(g,true); |
103 | } |
104 | } |
104 | 105 | ||
105 | public void menu_keypress(int keyCode) |
106 | public void menu_keypress(int keyCode) |
106 | { |
107 | { |
107 | switch (getGameAction (keyCode)) |
108 | switch (getGameAction (keyCode)) |
108 | { |
109 | { |
109 | case UP: |
110 | case UP: |
110 | if (act_menu_select!=0) act_menu_select--; |
111 | if (act_menu_select!=0) act_menu_select--; |
- | 112 | else |
|
- | 113 | act_menu_select=menu_items.length-1; |
|
111 | break; |
114 | break; |
112 | 115 | ||
113 | case DOWN: |
116 | case DOWN: |
114 | if (act_menu_select<(menu_items.length-1)) act_menu_select++; |
117 | if (act_menu_select<(menu_items.length-1)) act_menu_select++; |
- | 118 | else act_menu_select=0; |
|
115 | break; |
119 | break; |
116 | 120 | ||
117 | } |
121 | } |
118 | 122 | ||
119 | } |
123 | } |
120 | 124 | ||
121 | 125 | ||
122 | 126 | ||
123 | public void paint_lcd(Graphics g,boolean bottomup) |
127 | public void paint_lcd(Graphics g,boolean bottomup) |
124 | { |
128 | { |
125 | int y; |
129 | int y; |
126 | 130 | ||
127 | for(int i=0;i<lcd_lines.length;i++) |
131 | for(int i=0;i<lcd_lines.length;i++) |
128 | for (int pos=0;pos<20;pos++) |
132 | for (int pos=0;pos<20;pos++) |
129 | { |
133 | { |
130 | if (bottomup) |
134 | if (bottomup) |
131 | y=this.getHeight()-(lcd_lines.length-i)*lcd_char_height; |
135 | y=this.getHeight()-(lcd_lines.length-i)*lcd_char_height; |
132 | else |
136 | else |
133 | y=i*lcd_char_height; |
137 | y=i*lcd_char_height; |
134 | g.setClip((lcd_img.getWidth()/222)*pos,y,(lcd_img.getWidth()/222),lcd_img.getHeight()); |
138 | g.setClip((lcd_img.getWidth()/222)*pos,y,(lcd_img.getWidth()/222),lcd_img.getHeight()); |
135 | g.drawImage(lcd_img,(lcd_img.getWidth()/222)*pos-((pos<lcd_lines[i].length()?lcd_lines[i].charAt(pos):' ')-' ')*(lcd_img.getWidth()/222),y,g.TOP | g.LEFT); |
139 | g.drawImage(lcd_img,(lcd_img.getWidth()/222)*pos-((pos<lcd_lines[i].length()?lcd_lines[i].charAt(pos):' ')-' ')*(lcd_img.getWidth()/222),y,g.TOP | g.LEFT); |
136 | 140 | ||
137 | } |
141 | } |
138 | } |
142 | } |
139 | 143 | ||
140 | public MKMiniCanvas(DUBwise _root) |
144 | public MKMiniCanvas(DUBwise _root) |
141 | { |
145 | { |
142 | 146 | ||
143 | root=_root; |
147 | root=_root; |
144 | 148 | ||
145 | bt_scanner = new BTSearcher(); |
149 | bt_scanner = new BTSearcher(); |
146 | params_editor = new MKParamsEditor(this); |
150 | params_editor = new MKParamsEditor(this); |
147 | mk = new MKCommunicator(); |
151 | mk = new MKCommunicator(); |
148 | mk_stat= new MKStatistics(mk); |
152 | mk_stat= new MKStatistics(mk); |
149 | 153 | ||
150 | try |
154 | try |
151 | { |
155 | { |
152 | // load all needed images |
156 | // load all needed images |
153 | lcd_img=Image.createImage("/lcd.png"); |
157 | lcd_img=Image.createImage("/lcd.png"); |
154 | bt_img=Image.createImage("/bt.png"); |
158 | bt_img=Image.createImage("/bt.png"); |
155 | bg_img=Image.createImage("/bg.jpg"); |
159 | bg_img=Image.createImage("/bg.jpg"); |
156 | load_img=Image.createImage("/load.png"); |
160 | load_img=Image.createImage("/load.png"); |
157 | } |
161 | } |
158 | catch (Exception e) |
162 | catch (Exception e) |
159 | { |
163 | { |
160 | err+=e.toString(); |
164 | err+=e.toString(); |
161 | } |
165 | } |
162 | 166 | ||
163 | lcd_char_width=lcd_img.getWidth()/222; |
167 | lcd_char_width=lcd_img.getWidth()/222; |
164 | lcd_char_height=lcd_img.getHeight(); |
168 | lcd_char_height=lcd_img.getHeight(); |
165 | 169 | ||
166 | 170 | ||
167 | nick_line_pos_data=new int[bg_img.getWidth()]; |
171 | nick_line_pos_data=new int[bg_img.getWidth()]; |
168 | roll_line_pos_data=new int[bg_img.getWidth()]; |
172 | roll_line_pos_data=new int[bg_img.getWidth()]; |
169 | accnick_line_pos_data=new int[bg_img.getWidth()]; |
173 | accnick_line_pos_data=new int[bg_img.getWidth()]; |
170 | accroll_line_pos_data=new int[bg_img.getWidth()]; |
174 | accroll_line_pos_data=new int[bg_img.getWidth()]; |
171 | 175 | ||
172 | for (int c=0;c<bg_img.getWidth();c++) |
176 | for (int c=0;c<bg_img.getWidth();c++) |
173 | { |
177 | { |
174 | nick_line_pos_data[c]=-1; |
178 | nick_line_pos_data[c]=-1; |
175 | roll_line_pos_data[c]=-1; |
179 | roll_line_pos_data[c]=-1; |
176 | accnick_line_pos_data[c]=-1; |
180 | accnick_line_pos_data[c]=-1; |
177 | accroll_line_pos_data[c]=-1; |
181 | accroll_line_pos_data[c]=-1; |
178 | } |
182 | } |
179 | 183 | ||
180 | 184 | ||
181 | try |
185 | try |
182 | { |
186 | { |
183 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME , true ); |
187 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME , true ); |
184 | 188 | ||
185 | if (recStore.getNumRecords()==2) |
189 | if (recStore.getNumRecords()==2) |
186 | { |
190 | { |
187 | 191 | ||
188 | //byte[] recData = new byte[recStore.getRecordSize(1)]; |
192 | //byte[] recData = new byte[recStore.getRecordSize(1)]; |
189 | //int len = recStore.getRecord(1, recData, 0); |
193 | //int len = recStore.getRecord(1, recData, 0); |
190 | 194 | ||
191 | //byte[] recData2 = new byte[recStore.getRecordSize(2)]; |
195 | //byte[] recData2 = new byte[recStore.getRecordSize(2)]; |
192 | //int len2 = recStore.getRecord(2, recData, 0); |
196 | //int len2 = recStore.getRecord(2, recData, 0); |
193 | 197 | ||
194 | byte[] url_data=recStore.getRecord(1); |
198 | byte[] url_data=recStore.getRecord(1); |
195 | byte[] name_data=recStore.getRecord(2); |
199 | byte[] name_data=recStore.getRecord(2); |
196 | 200 | ||
197 | connect_mk(new String(url_data, 0, url_data.length),new String(name_data, 0, name_data.length)); |
201 | connect_mk(new String(url_data, 0, url_data.length),new String(name_data, 0, name_data.length)); |
198 | 202 | ||
199 | } |
203 | } |
200 | recStore.closeRecordStore(); |
204 | recStore.closeRecordStore(); |
201 | } |
205 | } |
202 | catch (Exception e) |
206 | catch (Exception e) |
203 | { |
207 | { |
204 | err+=e.toString(); |
208 | err+=e.toString(); |
205 | } |
209 | } |
206 | 210 | ||
207 | chg_state((mk.force_disconnect)?STATEID_SCANNING:STATEID_MAINMENU); |
211 | chg_state((mk.force_disconnect)?STATEID_SCANNING:STATEID_MAINMENU); |
208 | 212 | ||
209 | 213 | ||
210 | 214 | ||
211 | new Thread(this).start(); |
215 | new Thread(this).start(); |
212 | 216 | ||
213 | } |
217 | } |
214 | 218 | ||
215 | 219 | ||
216 | 220 | ||
217 | /****************************** Thread ******************/ |
221 | /****************************** Thread ******************/ |
218 | // ticking runnable Section |
222 | // ticking runnable Section |
219 | public void run() |
223 | public void run() |
220 | { |
224 | { |
221 | 225 | ||
222 | 226 | ||
223 | while(true) |
227 | while(true) |
224 | { |
228 | { |
225 | repaint(); |
229 | repaint(); |
226 | serviceRepaints(); |
230 | serviceRepaints(); |
227 | 231 | ||
228 | long loopStartTime = System.currentTimeMillis(); |
232 | long loopStartTime = System.currentTimeMillis(); |
229 | long sleeptime=0; |
233 | long sleeptime=0; |
230 | // ticked thing |
234 | // ticked thing |
231 | 235 | ||
232 | frame_pos++; |
236 | frame_pos++; |
233 | 237 | ||
234 | switch(state) |
238 | switch(state) |
235 | { |
239 | { |
236 | case STATEID_MOTORTEST: |
240 | case STATEID_MOTORTEST: |
237 | 241 | ||
238 | if (motor_test_sel_all) |
242 | if (motor_test_sel_all) |
239 | for (int m=0;m<4;m++) |
243 | for (int m=0;m<4;m++) |
240 | { |
244 | { |
241 | motor_test[m]+=act_motor_increase; |
245 | motor_test[m]+=act_motor_increase; |
242 | if (motor_test[m]<0)motor_test[m]=0; |
246 | if (motor_test[m]<0)motor_test[m]=0; |
243 | } |
247 | } |
244 | else |
248 | else |
245 | { |
249 | { |
246 | motor_test[act_motor]+=act_motor_increase; |
250 | motor_test[act_motor]+=act_motor_increase; |
247 | if (motor_test[act_motor]<0)motor_test[act_motor]=0; |
251 | if (motor_test[act_motor]<0)motor_test[act_motor]=0; |
248 | } |
252 | } |
249 | 253 | ||
250 | mk.motor_test(motor_test); |
254 | mk.motor_test(motor_test); |
251 | break; |
255 | break; |
252 | 256 | ||
253 | case STATEID_SCANNING: |
257 | case STATEID_SCANNING: |
- | 258 | intro_str_delay--; |
|
- | 259 | if (intro_str_delay<0) |
|
- | 260 | { |
|
- | 261 | intro_str_delay=1; |
|
- | 262 | if (intro_str_pos>intro_str.length()) |
|
- | 263 | intro_str_pos=0; |
|
- | 264 | lcd_lines[3]=intro_str.substring(intro_str_pos, (((intro_str_pos+20)>intro_str.length())?intro_str.length():intro_str_pos+20)); |
|
- | 265 | intro_str_pos++; |
|
- | 266 | } |
|
- | 267 | ||
254 | if (!bt_scanner.searching) |
268 | if (!bt_scanner.searching) |
255 | chg_state(STATEID_DEVICESELECT); |
269 | chg_state(STATEID_DEVICESELECT); |
- | 270 | ||
256 | 271 | ||
257 | break; |
272 | break; |
258 | 273 | ||
259 | 274 | ||
260 | 275 | ||
261 | } |
276 | } |
262 | 277 | ||
263 | try { |
278 | try { |
264 | nick_line_pos_data[-bg_offset] = mk.debug_data.nick_int(); |
279 | nick_line_pos_data[-bg_offset] = mk.debug_data.nick_int(); |
265 | roll_line_pos_data[-bg_offset] = mk.debug_data.roll_int(); |
280 | roll_line_pos_data[-bg_offset] = mk.debug_data.roll_int(); |
266 | accnick_line_pos_data[-bg_offset] = mk.debug_data.accnick(); |
281 | accnick_line_pos_data[-bg_offset] = mk.debug_data.accnick(); |
267 | accroll_line_pos_data[-bg_offset] = mk.debug_data.accroll(); |
282 | accroll_line_pos_data[-bg_offset] = mk.debug_data.accroll(); |
268 | } |
283 | } |
269 | catch (Exception e) |
284 | catch (Exception e) |
270 | { |
285 | { |
271 | err+=e.toString(); |
286 | err+=e.toString(); |
272 | } |
287 | } |
273 | 288 | ||
274 | 289 | ||
275 | 290 | ||
276 | 291 | ||
277 | if (quit) |
292 | if (quit) |
278 | { |
293 | { |
279 | 294 | ||
280 | 295 | ||
281 | 296 | ||
282 | try |
297 | try |
283 | { |
298 | { |
284 | RecordStore.deleteRecordStore(RECORD_STORE_NAME); |
299 | RecordStore.deleteRecordStore(RECORD_STORE_NAME); |
285 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME, true ); |
300 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME, true ); |
286 | recStore.addRecord(mk.mk_url.getBytes(), 0, mk.mk_url.getBytes().length); |
301 | recStore.addRecord(mk.mk_url.getBytes(), 0, mk.mk_url.getBytes().length); |
287 | recStore.addRecord(mk.name.getBytes(), 0, mk.name.getBytes().length); |
302 | recStore.addRecord(mk.name.getBytes(), 0, mk.name.getBytes().length); |
288 | recStore.closeRecordStore(); |
303 | recStore.closeRecordStore(); |
289 | 304 | ||
290 | } |
305 | } |
291 | catch (Exception e) |
306 | catch (Exception e) |
292 | { |
307 | { |
293 | err+=e.toString(); |
308 | err+=e.toString(); |
294 | } |
309 | } |
295 | 310 | ||
296 | root.quit(); |
311 | root.quit(); |
297 | } |
312 | } |
298 | if (rescan) |
313 | if (rescan) |
299 | { |
314 | { |
300 | 315 | ||
301 | rescan=false; |
316 | rescan=false; |
302 | } |
317 | } |
303 | 318 | ||
304 | try { |
319 | try { |
305 | //rescan=false; |
320 | //rescan=false; |
306 | bg_offset--; |
321 | bg_offset--; |
307 | if (bg_offset==-bg_img.getWidth()) |
322 | if (bg_offset==-bg_img.getWidth()) |
308 | bg_offset=0; |
323 | bg_offset=0; |
309 | com.nokia.mid.ui.DeviceControl.setLights(0,100); |
324 | com.nokia.mid.ui.DeviceControl.setLights(0,100); |
310 | //bt.tick(); |
325 | //bt.tick(); |
311 | // every state has sth to do in tick section |
326 | // every state has sth to do in tick section |
312 | } |
327 | } |
313 | catch (Exception e) |
328 | catch (Exception e) |
314 | { |
329 | { |
315 | 330 | ||
316 | } |
331 | } |
317 | 332 | ||
318 | 333 | ||
319 | // System.gc(); |
334 | // System.gc(); |
320 | 335 | ||
321 | 336 | ||
322 | 337 | ||
323 | 338 | ||
324 | sleeptime=1000/ 15 - (int) (System.currentTimeMillis()- loopStartTime); |
339 | sleeptime=1000/ 15 - (int) (System.currentTimeMillis()- loopStartTime); |
325 | 340 | ||
326 | 341 | ||
327 | if (sleeptime<0) |
342 | if (sleeptime<0) |
328 | sleeptime=100; // everyone has fi sleep |
343 | sleeptime=100; // everyone has fi sleep |
329 | 344 | ||
330 | try { Thread.sleep(sleeptime); } |
345 | try { Thread.sleep(sleeptime); } |
331 | catch (Exception e) |
346 | catch (Exception e) |
332 | { |
347 | { |
333 | err="Problem Sleeping "; |
348 | err="Problem Sleeping "; |
334 | } |
349 | } |
335 | 350 | ||
336 | } |
351 | } |
337 | } |
352 | } |
338 | 353 | ||
339 | 354 | ||
340 | 355 | ||
341 | 356 | ||
342 | 357 | ||
343 | // drawing section |
358 | // drawing section |
344 | public void paint(Graphics g) { |
359 | public void paint(Graphics g) { |
345 | y_off=0; |
360 | y_off=0; |
346 | try { |
361 | try { |
347 | 362 | ||
348 | if (mk!=null) |
363 | if (mk!=null) |
349 | { |
364 | { |
350 | line_middle_y=this.getHeight()/2; |
365 | line_middle_y=this.getHeight()/2; |
351 | if (local_max<Math.abs(mk.debug_data.nick_int())) |
366 | if (local_max<Math.abs(mk.debug_data.nick_int())) |
352 | local_max=Math.abs(mk.debug_data.nick_int()); |
367 | local_max=Math.abs(mk.debug_data.nick_int()); |
353 | if (local_max<Math.abs(mk.debug_data.roll_int())) |
368 | if (local_max<Math.abs(mk.debug_data.roll_int())) |
354 | local_max=Math.abs(mk.debug_data.roll_int()); |
369 | local_max=Math.abs(mk.debug_data.roll_int()); |
355 | if (local_max<Math.abs(mk.debug_data.accnick())) |
370 | if (local_max<Math.abs(mk.debug_data.accnick())) |
356 | local_max=Math.abs(mk.debug_data.accnick()); |
371 | local_max=Math.abs(mk.debug_data.accnick()); |
357 | if (local_max<Math.abs(mk.debug_data.accroll())) |
372 | if (local_max<Math.abs(mk.debug_data.accroll())) |
358 | local_max=Math.abs(mk.debug_data.accroll()); |
373 | local_max=Math.abs(mk.debug_data.accroll()); |
359 | line_scaler= local_max/(this.getHeight()/2)+1; |
374 | line_scaler= local_max/(this.getHeight()/2)+1; |
360 | } |
375 | } |
361 | spacer=(g.getFont().getHeight()); |
376 | spacer=(g.getFont().getHeight()); |
362 | g.setColor(0xFFFFFF); |
377 | g.setColor(0xFFFFFF); |
363 | g.fillRect(0,0,this.getWidth(),this.getHeight()); |
378 | g.fillRect(0,0,this.getWidth(),this.getHeight()); |
364 | g.drawImage(bg_img,bg_offset,0, g.TOP | g.LEFT); |
379 | g.drawImage(bg_img,bg_offset,0, g.TOP | g.LEFT); |
365 | 380 | ||
366 | if (bg_offset+bg_img.getWidth()<this.getWidth()) |
381 | if (bg_offset+bg_img.getWidth()<this.getWidth()) |
367 | g.drawImage(bg_img,bg_offset+bg_img.getWidth(),0, g.TOP | g.LEFT); |
382 | g.drawImage(bg_img,bg_offset+bg_img.getWidth(),0, g.TOP | g.LEFT); |
368 | 383 | ||
369 | 384 | ||
370 | g.setColor(0x000000); |
385 | g.setColor(0x000000); |
371 | 386 | ||
372 | switch(state) |
387 | switch(state) |
373 | { |
388 | { |
374 | case STATEID_MOTORTEST: |
389 | case STATEID_MOTORTEST: |
375 | for (int bar=0;bar<4;bar++) |
390 | for (int bar=0;bar<4;bar++) |
376 | { |
391 | { |
377 | g.setColor(((bar==act_motor)|motor_test_sel_all)?0x44CC44:0x4444DD); |
392 | g.setColor(((bar==act_motor)|motor_test_sel_all)?0x44CC44:0x4444DD); |
378 | g.fillRect(this.getWidth()/(8*2)+bar*2*this.getWidth()/8,10,this.getWidth()/8,20+motor_test[bar]); |
393 | g.fillRect(this.getWidth()/(8*2)+bar*2*this.getWidth()/8,10,this.getWidth()/8,20+motor_test[bar]); |
379 | g.setColor(0x000000); |
394 | g.setColor(0x000000); |
380 | g.drawString(""+motor_test[bar] ,this.getWidth()/8+bar*2*this.getWidth()/8,10,Graphics.TOP | Graphics.HCENTER); |
395 | g.drawString(""+motor_test[bar] ,this.getWidth()/8+bar*2*this.getWidth()/8,10,Graphics.TOP | Graphics.HCENTER); |
381 | if(bar!=4) g.drawString(""+mk.debug_data.motor_val(bar) ,this.getWidth()/8+bar*2*this.getWidth()/8,30,Graphics.TOP | Graphics.HCENTER); |
396 | if(bar!=4) g.drawString(""+mk.debug_data.motor_val(bar) ,this.getWidth()/8+bar*2*this.getWidth()/8,30,Graphics.TOP | Graphics.HCENTER); |
382 | } |
397 | } |
383 | break; |
398 | break; |
384 | 399 | ||
385 | case STATEID_EDIT_PARAMS: |
400 | case STATEID_EDIT_PARAMS: |
386 | params_editor.paint(g); |
401 | params_editor.paint(g); |
387 | break; |
402 | break; |
388 | 403 | ||
389 | case STATEID_SCANNING: |
404 | case STATEID_SCANNING: |
390 | paint_lcd(g,true); |
405 | paint_lcd(g,true); |
391 | 406 | ||
392 | g.setClip(this.getWidth()/2-load_img.getWidth()/6,this.getHeight()/2-load_img.getHeight()/8, load_img.getWidth()/4,load_img.getHeight()/3);; |
407 | g.setClip(this.getWidth()/2-load_img.getWidth()/6,this.getHeight()/2-load_img.getHeight()/8, load_img.getWidth()/4,load_img.getHeight()/3);; |
393 | g.drawImage(load_img,this.getWidth()/2-load_img.getWidth()/8 - ((((frame_pos/3)%12)%4)*(load_img.getWidth()/4)) ,this.getHeight()/2-load_img.getHeight()/6- ((((frame_pos/3)%12)/4)*(load_img.getHeight()/3)), g.TOP | g.LEFT); |
408 | g.drawImage(load_img,this.getWidth()/2-load_img.getWidth()/8 - ((((frame_pos/3)%12)%4)*(load_img.getWidth()/4)) ,this.getHeight()/2-load_img.getHeight()/6- ((((frame_pos/3)%12)/4)*(load_img.getHeight()/3)), g.TOP | g.LEFT); |
394 | g.drawImage(bt_img,this.getWidth()/2 ,this.getHeight()/2 , g.HCENTER | g.VCENTER); |
409 | g.drawImage(bt_img,this.getWidth()/2 ,this.getHeight()/2 , g.HCENTER | g.VCENTER); |
395 | break; |
410 | break; |
396 | 411 | ||
397 | case STATEID_MAINMENU: |
412 | case STATEID_MAINMENU: |
398 | g.drawString("MK-Connection(" + (mk.connected?("open"+((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s"):"close")+"):",0,y_off,Graphics.TOP | Graphics.LEFT); |
413 | g.drawString("MK-Connection(" + (mk.connected?("open"+((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s"):"close")+"):",0,y_off,Graphics.TOP | Graphics.LEFT); |
399 | y_off+=spacer; |
414 | y_off+=spacer; |
400 | g.drawString(" Name:" + mk.name,0,y_off,Graphics.TOP | Graphics.LEFT); |
415 | g.drawString(" Name:" + mk.name,0,y_off,Graphics.TOP | Graphics.LEFT); |
401 | y_off+=spacer; |
416 | y_off+=spacer; |
402 | g.drawString(" URL:" + mk.mk_url,0,y_off,Graphics.TOP | Graphics.LEFT); |
417 | g.drawString(" URL:" + mk.mk_url,0,y_off,Graphics.TOP | Graphics.LEFT); |
403 | y_off+=spacer; |
418 | y_off+=spacer; |
404 | g.drawString(" Version:" + mk.version.str,0,y_off,Graphics.TOP | Graphics.LEFT); |
419 | g.drawString(" Version:" + mk.version.str,0,y_off,Graphics.TOP | Graphics.LEFT); |
405 | y_off+=spacer; |
420 | y_off+=spacer; |
406 | g.drawString("Packet Traffic:",0,y_off,Graphics.TOP | Graphics.LEFT); |
421 | g.drawString("Packet Traffic:",0,y_off,Graphics.TOP | Graphics.LEFT); |
407 | y_off+=spacer; |
422 | y_off+=spacer; |
408 | g.drawString( " debug:"+mk.debug_data_count+ " LCD:" + mk.lcd_data_count + " vers:" + mk.version_data_count,0,y_off,Graphics.TOP | Graphics.LEFT); |
423 | g.drawString( " debug:"+mk.debug_data_count+ " LCD:" + mk.lcd_data_count + " vers:" + mk.version_data_count,0,y_off,Graphics.TOP | Graphics.LEFT); |
409 | y_off+=spacer; |
424 | y_off+=spacer; |
410 | g.drawString( " other:"+mk.other_data_count+" params:"+mk.params_data_count,0,y_off,Graphics.TOP | Graphics.LEFT); |
425 | g.drawString( " other:"+mk.other_data_count+" params:"+mk.params_data_count,0,y_off,Graphics.TOP | Graphics.LEFT); |
411 | 426 | ||
412 | 427 | ||
413 | 428 | ||
414 | 429 | ||
415 | // falltru wanted |
430 | // falltru wanted |
416 | case STATEID_SELECT_PARAMSET: |
431 | case STATEID_SELECT_PARAMSET: |
417 | case STATEID_HANDLE_PARAMS: |
432 | case STATEID_HANDLE_PARAMS: |
418 | 433 | ||
419 | case STATEID_DEVICESELECT: |
434 | case STATEID_DEVICESELECT: |
420 | paint_menu(g); |
435 | paint_menu(g); |
421 | break; |
436 | break; |
422 | 437 | ||
423 | case STATEID_FLIGHTVIEW: |
438 | case STATEID_FLIGHTVIEW: |
424 | 439 | ||
425 | 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); |
440 | 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); |
426 | 441 | ||
427 | y_off+=spacer; |
442 | y_off+=spacer; |
428 | 443 | ||
429 | 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); |
444 | 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); |
430 | y_off+=spacer; |
445 | y_off+=spacer; |
431 | 446 | ||
432 | 447 | ||
433 | 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); |
448 | 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); |
434 | y_off+=spacer; |
449 | y_off+=spacer; |
435 | 450 | ||
436 | if (mk.connected) |
451 | if (mk.connected) |
437 | { |
452 | { |
438 | g.drawString("time conn:" +((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
453 | g.drawString("time conn:" +((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
439 | y_off+=spacer; |
454 | y_off+=spacer; |
440 | g.drawString("time motor>15:" +(mk_stat.motor_on_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
455 | g.drawString("time motor>15:" +(mk_stat.motor_on_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
441 | y_off+=spacer; |
456 | y_off+=spacer; |
442 | g.drawString("time motor=15:" +(mk_stat.motor_stand_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
457 | g.drawString("time motor=15:" +(mk_stat.motor_stand_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
443 | } |
458 | } |
444 | 459 | ||
445 | 460 | ||
446 | y_off=this.getHeight()-4*lcd_img.getHeight(); |
461 | y_off=this.getHeight()-4*lcd_img.getHeight(); |
447 | 462 | ||
448 | for ( int foo=0;foo<4;foo++) |
463 | for ( int foo=0;foo<4;foo++) |
449 | { |
464 | { |
450 | for (int x=0;x<20;x++) |
465 | for (int x=0;x<20;x++) |
451 | { |
466 | { |
452 | g.setClip((lcd_img.getWidth()/222)*x,y_off,(lcd_img.getWidth()/222),lcd_img.getHeight()); |
467 | g.setClip((lcd_img.getWidth()/222)*x,y_off,(lcd_img.getWidth()/222),lcd_img.getHeight()); |
453 | g.drawImage(lcd_img,(lcd_img.getWidth()/222)*x-(mk.LCD.LCD_str[foo].charAt(x)-' ')*(lcd_img.getWidth()/222),y_off, g.TOP | g.LEFT); |
468 | g.drawImage(lcd_img,(lcd_img.getWidth()/222)*x-(mk.LCD.LCD_str[foo].charAt(x)-' ')*(lcd_img.getWidth()/222),y_off, g.TOP | g.LEFT); |
454 | 469 | ||
455 | } |
470 | } |
456 | y_off+=lcd_img.getHeight(); |
471 | y_off+=lcd_img.getHeight(); |
457 | } |
472 | } |
458 | 473 | ||
459 | g.setClip(0,0,this.getWidth(),this.getHeight()); |
474 | g.setClip(0,0,this.getWidth(),this.getHeight()); |
460 | 475 | ||
461 | 476 | ||
462 | 477 | ||
463 | 478 | ||
464 | 479 | ||
465 | // draw lines |
480 | // draw lines |
466 | 481 | ||
467 | for ( int x=0;x<this.getWidth();x++) |
482 | for ( int x=0;x<this.getWidth();x++) |
468 | 483 | ||
469 | { |
484 | { |
470 | 485 | ||
471 | int p= (((-bg_offset+x-this.getWidth()-5))); |
486 | int p= (((-bg_offset+x-this.getWidth()-5))); |
472 | if (p<1) |
487 | if (p<1) |
473 | p+=bg_img.getWidth(); |
488 | p+=bg_img.getWidth(); |
474 | p%=(bg_img.getWidth()-1); |
489 | p%=(bg_img.getWidth()-1); |
475 | 490 | ||
476 | g.setColor(0x156315); |
491 | g.setColor(0x156315); |
477 | draw_graph_part(g,x,nick_line_pos_data[p]/line_scaler,nick_line_pos_data[p+1]/line_scaler); |
492 | draw_graph_part(g,x,nick_line_pos_data[p]/line_scaler,nick_line_pos_data[p+1]/line_scaler); |
478 | g.setColor(0xCC1315); |
493 | g.setColor(0xCC1315); |
479 | draw_graph_part(g,x,roll_line_pos_data[p]/line_scaler,roll_line_pos_data[p+1]/line_scaler); |
494 | draw_graph_part(g,x,roll_line_pos_data[p]/line_scaler,roll_line_pos_data[p+1]/line_scaler); |
480 | g.setColor(0xf8ef02); |
495 | g.setColor(0xf8ef02); |
481 | draw_graph_part(g,x,accnick_line_pos_data[p]/line_scaler,accnick_line_pos_data[p+1]/line_scaler); |
496 | draw_graph_part(g,x,accnick_line_pos_data[p]/line_scaler,accnick_line_pos_data[p+1]/line_scaler); |
482 | g.setColor(0x19194d); |
497 | g.setColor(0x19194d); |
483 | draw_graph_part(g,x,accroll_line_pos_data[p]/line_scaler,accroll_line_pos_data[p+1]/line_scaler); |
498 | draw_graph_part(g,x,accroll_line_pos_data[p]/line_scaler,accroll_line_pos_data[p+1]/line_scaler); |
484 | 499 | ||
485 | 500 | ||
486 | 501 | ||
487 | } |
502 | } |
488 | 503 | ||
489 | } |
504 | } |
490 | 505 | ||
491 | 506 | ||
492 | 507 | ||
493 | } catch (Exception e) {} |
508 | } catch (Exception e) {} |
494 | } |
509 | } |
495 | 510 | ||
496 | private void connect_mk(String url,String name) |
511 | private void connect_mk(String url,String name) |
497 | { |
512 | { |
498 | mk.connect_to(url,name); |
513 | mk.connect_to(url,name); |
499 | 514 | ||
500 | } |
515 | } |
501 | 516 | ||
502 | public void draw_graph_part(Graphics g,int x,int y1,int y2) |
517 | public void draw_graph_part(Graphics g,int x,int y1,int y2) |
503 | { |
518 | { |
504 | g.fillRect(x,line_middle_y-y1,2,2 ); |
519 | g.fillRect(x,line_middle_y-y1,2,2 ); |
505 | if (y1>y2) |
520 | if (y1>y2) |
506 | g.fillRect(x,line_middle_y-y1,2,y1-y2); |
521 | g.fillRect(x,line_middle_y-y1,2,y1-y2); |
507 | else |
522 | else |
508 | g.fillRect(x,line_middle_y-y2,2,y2-y1); |
523 | g.fillRect(x,line_middle_y-y2,2,y2-y1); |
509 | } |
524 | } |
510 | 525 | ||
511 | /*********************************************** input Section **********************************************/ |
526 | /*********************************************** input Section **********************************************/ |
512 | 527 | ||
- | 528 | ||
- | 529 | 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) "; |
|
- | 530 | ||
- | 531 | int intro_str_pos=0; |
|
513 | 532 | int intro_str_delay=3; |
|
514 | 533 | ||
515 | public void chg_state(int next_state) |
534 | public void chg_state(int next_state) |
516 | { |
535 | { |
517 | act_menu_select=0; |
536 | act_menu_select=0; |
518 | // prepare next state |
537 | // prepare next state |
519 | switch(next_state) |
538 | switch(next_state) |
520 | { |
539 | { |
521 | case STATEID_SCANNING: |
540 | case STATEID_SCANNING: |
522 | lcd_lines=new String[3]; |
541 | lcd_lines=new String[4]; |
523 | lcd_lines[0]="Scanning for Devices"; |
542 | lcd_lines[0]="Scanning for Devices"; |
524 | lcd_lines[1]=" "; |
543 | lcd_lines[1]=" "; |
525 | lcd_lines[2]="DUBwise v0.37 "; |
544 | lcd_lines[2]="DUBwise v0.40 "; |
- | 545 | lcd_lines[3]=intro_str.substring(0,20); |
|
526 | mk.close_connections(true); |
546 | mk.close_connections(true); |
527 | 547 | ||
528 | bt_scanner.search(); |
548 | bt_scanner.search(); |
529 | break; |
549 | break; |
530 | 550 | ||
531 | case STATEID_HANDLE_PARAMS: |
551 | case STATEID_HANDLE_PARAMS: |
532 | menu_items=new String[2]; |
552 | menu_items=new String[2]; |
533 | menu_items[0]="write to MK"; |
553 | menu_items[0]="write to MK"; |
534 | menu_items[1]="Discard"; |
554 | menu_items[1]="Discard"; |
535 | lcd_lines=new String[2]; |
555 | lcd_lines=new String[2]; |
536 | 556 | ||
537 | break; |
557 | break; |
538 | 558 | ||
539 | case STATEID_SELECT_PARAMSET: |
559 | case STATEID_SELECT_PARAMSET: |
540 | menu_items=new String[5]; |
560 | menu_items=new String[5]; |
541 | for (int i=0;i<5;i++) |
561 | for (int i=0;i<5;i++) |
542 | menu_items[i]=mk.params.names[i]; |
562 | menu_items[i]=mk.params.names[i]; |
543 | 563 | ||
544 | lcd_lines=new String[5]; |
564 | lcd_lines=new String[5]; |
545 | break; |
565 | break; |
546 | 566 | ||
547 | case STATEID_DEVICESELECT: |
567 | case STATEID_DEVICESELECT: |
548 | menu_items=new String[bt_scanner.remote_device_count]; |
568 | menu_items=new String[bt_scanner.remote_device_count+1]; |
549 | for (int i=0;i<bt_scanner.remote_device_count;i++) |
569 | for (int i=0;i<bt_scanner.remote_device_count;i++) |
550 | menu_items[i]=bt_scanner.remote_device_name[i]; |
570 | menu_items[i]=bt_scanner.remote_device_name[i]; |
- | 571 | menu_items[bt_scanner.remote_device_count]="scan again"; |
|
551 | lcd_lines=new String[bt_scanner.remote_device_count]; |
572 | lcd_lines=new String[bt_scanner.remote_device_count+1]; |
552 | break; |
573 | break; |
553 | 574 | ||
554 | case STATEID_MAINMENU: |
575 | case STATEID_MAINMENU: |
555 | menu_items=main_menu_items; |
576 | menu_items=main_menu_items; |
556 | lcd_lines=new String[menu_items.length]; |
577 | lcd_lines=new String[menu_items.length]; |
557 | break; |
578 | break; |
558 | 579 | ||
559 | } |
580 | } |
560 | 581 | ||
561 | // switch state |
582 | // switch state |
562 | state=next_state; |
583 | state=next_state; |
563 | } |
584 | } |
564 | 585 | ||
565 | 586 | ||
566 | public void keyReleased(int keyCode) |
587 | public void keyReleased(int keyCode) |
567 | { |
588 | { |
568 | 589 | ||
569 | switch(state) |
590 | switch(state) |
570 | { |
591 | { |
571 | case STATEID_MOTORTEST: |
592 | case STATEID_MOTORTEST: |
572 | act_motor_increase=0; |
593 | act_motor_increase=0; |
573 | break; |
594 | break; |
574 | } |
595 | } |
575 | 596 | ||
576 | } |
597 | } |
577 | 598 | ||
578 | public void keyPressed(int keyCode) |
599 | public void keyPressed(int keyCode) |
579 | { |
600 | { |
580 | 601 | ||
581 | if (keyCode==KEY_STAR) |
602 | if (keyCode==KEY_STAR) |
582 | { |
603 | { |
583 | if (state==STATEID_EDIT_PARAMS) |
604 | if (state==STATEID_EDIT_PARAMS) |
584 | chg_state(STATEID_HANDLE_PARAMS); |
605 | chg_state(STATEID_HANDLE_PARAMS); |
585 | else |
606 | else |
586 | chg_state(STATEID_MAINMENU); |
607 | chg_state(STATEID_MAINMENU); |
587 | 608 | ||
588 | return; |
609 | return; |
589 | } |
610 | } |
590 | if (keyCode==KEY_POUND) |
611 | if (keyCode==KEY_POUND) |
591 | { |
612 | { |
592 | fullscreen=!fullscreen; |
613 | fullscreen=!fullscreen; |
593 | setFullScreenMode(fullscreen); |
614 | setFullScreenMode(fullscreen); |
594 | return; |
615 | return; |
595 | } |
616 | } |
596 | switch(state) |
617 | switch(state) |
597 | { |
618 | { |
598 | case STATEID_MOTORTEST: |
619 | case STATEID_MOTORTEST: |
599 | switch (getGameAction (keyCode)) |
620 | switch (getGameAction (keyCode)) |
600 | { |
621 | { |
601 | case UP: |
622 | case UP: |
602 | act_motor_increase=-1; |
623 | act_motor_increase=-1; |
603 | break; |
624 | break; |
604 | 625 | ||
605 | case DOWN: |
626 | case DOWN: |
606 | act_motor_increase=1; |
627 | act_motor_increase=1; |
607 | break; |
628 | break; |
608 | 629 | ||
609 | case FIRE: |
630 | case FIRE: |
610 | motor_test_sel_all=!motor_test_sel_all; |
631 | motor_test_sel_all=!motor_test_sel_all; |
611 | break; |
632 | break; |
612 | 633 | ||
613 | case LEFT: |
634 | case LEFT: |
614 | act_motor--; |
635 | act_motor--; |
615 | if (act_motor<0) {act_motor=0; chg_state(STATEID_MAINMENU); } |
636 | if (act_motor<0) {act_motor=0; chg_state(STATEID_MAINMENU); } |
616 | break; |
637 | break; |
617 | 638 | ||
618 | case RIGHT: |
639 | case RIGHT: |
619 | act_motor++; |
640 | act_motor++; |
620 | act_motor%=4; |
641 | act_motor%=4; |
621 | break; |
642 | break; |
622 | } |
643 | } |
623 | 644 | ||
624 | break; |
645 | break; |
625 | case STATEID_HANDLE_PARAMS: |
646 | case STATEID_HANDLE_PARAMS: |
626 | if ( getGameAction (keyCode)==FIRE ) |
647 | if ( getGameAction (keyCode)==FIRE ) |
627 | switch(act_menu_select) |
648 | switch(act_menu_select) |
628 | { |
649 | { |
629 | case 0: |
650 | case 0: |
630 | mk.write_params(); |
651 | mk.write_params(); |
631 | default: |
652 | default: |
632 | chg_state(STATEID_MAINMENU); |
653 | chg_state(STATEID_MAINMENU); |
633 | } |
654 | } |
634 | else |
655 | else |
635 | menu_keypress(keyCode); |
656 | menu_keypress(keyCode); |
636 | break; |
657 | break; |
637 | case STATEID_MAINMENU: |
658 | case STATEID_MAINMENU: |
638 | if ( getGameAction (keyCode)==FIRE ) |
659 | if ( getGameAction (keyCode)==FIRE ) |
639 | switch(act_menu_select) |
660 | switch(act_menu_select) |
640 | { |
661 | { |
641 | 662 | ||
642 | case MAINMENU_TELEMETRY : |
663 | case MAINMENU_TELEMETRY : |
643 | chg_state(STATEID_FLIGHTVIEW); |
664 | chg_state(STATEID_FLIGHTVIEW); |
644 | break; |
665 | break; |
645 | 666 | ||
646 | case MAINMENU_MOTORTES : |
667 | case MAINMENU_MOTORTES : |
647 | chg_state(STATEID_MOTORTEST); |
668 | chg_state(STATEID_MOTORTEST); |
648 | break; |
669 | break; |
649 | 670 | ||
650 | case MAINMENU_PARAMS : |
671 | case MAINMENU_PARAMS : |
651 | chg_state(STATEID_SELECT_PARAMSET); |
672 | chg_state(STATEID_SELECT_PARAMSET); |
652 | break; |
673 | break; |
653 | case MAINMENU_SETTINGS: |
674 | case MAINMENU_SETTINGS: |
654 | break; |
675 | break; |
655 | case MAINMENU_PROXY: |
676 | case MAINMENU_PROXY: |
656 | mk.do_proxy("socket://192.168.1.42:2323"); |
677 | mk.do_proxy("socket://192.168.1.42:2323"); |
657 | break; |
678 | break; |
658 | 679 | ||
659 | case MAINMENU_DEVICESELECT: |
680 | case MAINMENU_DEVICESELECT: |
660 | chg_state(STATEID_SCANNING); |
681 | chg_state(STATEID_SCANNING); |
661 | break; |
682 | break; |
662 | 683 | ||
663 | case MAINMENU_QUIT: |
684 | case MAINMENU_QUIT: |
664 | quit=true; |
685 | quit=true; |
665 | break; |
686 | break; |
666 | 687 | ||
667 | } |
688 | } |
668 | else menu_keypress(keyCode); |
689 | else menu_keypress(keyCode); |
669 | break; |
690 | break; |
670 | 691 | ||
671 | case STATEID_SELECT_PARAMSET: |
692 | case STATEID_SELECT_PARAMSET: |
672 | if ( getGameAction (keyCode)==FIRE ) |
693 | if ( getGameAction (keyCode)==FIRE ) |
673 | { |
694 | { |
674 | mk.params.act_paramset=act_menu_select; |
695 | mk.params.act_paramset=act_menu_select; |
675 | chg_state(STATEID_EDIT_PARAMS); |
696 | chg_state(STATEID_EDIT_PARAMS); |
676 | } |
697 | } |
677 | else menu_keypress(keyCode); |
698 | else menu_keypress(keyCode); |
678 | break; |
699 | break; |
679 | case STATEID_DEVICESELECT: |
700 | case STATEID_DEVICESELECT: |
- | 701 | /* |
|
680 | if ((keyCode >= this.KEY_NUM0) && (keyCode < this.KEY_NUM0+bt_scanner.remote_device_count)) |
702 | if ((keyCode >= this.KEY_NUM0) && (keyCode < this.KEY_NUM0+bt_scanner.remote_device_count)) |
681 | { |
703 | { |
682 | connect_mk("btspp://"+bt_scanner.remote_device_mac[keyCode-this.KEY_NUM0] + ":1",bt_scanner.remote_device_name[keyCode-this.KEY_NUM0]); |
704 | connect_mk("btspp://"+bt_scanner.remote_device_mac[keyCode-this.KEY_NUM0] + ":1",bt_scanner.remote_device_name[keyCode-this.KEY_NUM0]); |
683 | chg_state(STATEID_MAINMENU); |
705 | chg_state(STATEID_MAINMENU); |
684 | } |
706 | } |
685 | else |
707 | else |
- | 708 | */ |
|
- | 709 | ||
686 | if ( getGameAction (keyCode)==FIRE ) |
710 | if ( getGameAction (keyCode)==FIRE ) |
687 | { |
711 | { |
- | 712 | ||
- | 713 | if (bt_scanner.remote_device_count > act_menu_select) |
|
- | 714 | { |
|
688 | connect_mk("btspp://"+bt_scanner.remote_device_mac[act_menu_select] + ":1",bt_scanner.remote_device_name[act_menu_select]); |
715 | connect_mk("btspp://"+bt_scanner.remote_device_mac[act_menu_select] + ":1",bt_scanner.remote_device_name[act_menu_select]); |
689 | chg_state(STATEID_MAINMENU); |
716 | chg_state(STATEID_MAINMENU); |
- | 717 | } |
|
- | 718 | else |
|
- | 719 | chg_state(STATEID_SCANNING); |
|
690 | } |
720 | } |
691 | else menu_keypress(keyCode); |
721 | else menu_keypress(keyCode); |
- | 722 | ||
692 | break; |
723 | break; |
693 | 724 | ||
694 | case STATEID_EDIT_PARAMS: |
725 | case STATEID_EDIT_PARAMS: |
695 | params_editor.keypress(keyCode,getGameAction (keyCode)) ; |
726 | params_editor.keypress(keyCode,getGameAction (keyCode)) ; |
696 | break; |
727 | break; |
697 | 728 | ||
698 | case STATEID_FLIGHTVIEW: |
729 | case STATEID_FLIGHTVIEW: |
699 | 730 | ||
700 | switch (getGameAction (keyCode)) |
731 | switch (getGameAction (keyCode)) |
701 | { |
732 | { |
702 | case UP: |
733 | case UP: |
703 | mk.LCD.LCD_PREVPAGE(); |
734 | mk.LCD.LCD_PREVPAGE(); |
704 | break; |
735 | break; |
705 | 736 | ||
706 | case DOWN: |
737 | case DOWN: |
707 | mk.LCD.LCD_NEXTPAGE(); |
738 | mk.LCD.LCD_NEXTPAGE(); |
708 | break; |
739 | break; |
709 | 740 | ||
710 | case LEFT: |
741 | case LEFT: |
711 | chg_state(STATEID_MAINMENU); |
742 | chg_state(STATEID_MAINMENU); |
712 | break; |
743 | break; |
713 | 744 | ||
714 | } |
745 | } |
715 | break; |
746 | break; |
716 | } |
747 | } |
717 | 748 | ||
718 | 749 | ||
719 | 750 | ||
720 | } |
751 | } |
721 | 752 | ||
722 | 753 | ||
723 | 754 | ||
724 | 755 | ||
725 | 756 | ||
726 | 757 | ||
727 | 758 | ||
728 | 759 | ||
729 | } |
760 | } |
730 | 761 | ||
731 | 762 | ||
732 | 763 |