Rev 221 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 221 | Rev 231 | ||
---|---|---|---|
Line 1... | Line 1... | ||
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 | * Big Up: Holger&Ingo * |
9 | * Big Up: Holger&Ingo |
10 | *********************************************************************************************************************************/ |
10 | ***************************************************************/ |
Line 11... | Line 11... | ||
11 | 11 | ||
12 | import javax.microedition.lcdui.*; |
12 | import javax.microedition.lcdui.*; |
Line 13... | Line 13... | ||
13 | import javax.microedition.rms.*; |
13 | import javax.microedition.rms.*; |
14 | 14 | ||
15 | 15 | ||
16 | public class MKMiniCanvas |
16 | public class MKMiniCanvas |
Line 17... | Line 17... | ||
17 | extends Canvas |
17 | extends Canvas |
18 | implements Runnable |
18 | implements Runnable |
Line 43... | Line 43... | ||
43 | int line_scaler=20; |
43 | int line_scaler=20; |
Line 44... | Line 44... | ||
44 | 44 | ||
Line 45... | Line 45... | ||
45 | public int line_middle_y; |
45 | public int line_middle_y; |
46 | 46 | ||
Line 47... | Line 47... | ||
47 | public MKMiniCanvas(MKMiniMidlet _root) |
47 | public MKMiniCanvas(MKMiniMidlet _root) |
Line 48... | Line 48... | ||
48 | { |
48 | { |
49 | 49 | ||
50 | root=_root; |
50 | root=_root; |
51 | 51 | ||
52 | try |
52 | try |
53 | { |
53 | { |
54 | lcd_img=Image.createImage("/lcd.png"); |
54 | lcd_img=Image.createImage("/lcd.png"); |
55 | bt_img=Image.createImage("/bt.png"); |
55 | bt_img=Image.createImage("/bt.png"); |
56 | bg_img=Image.createImage("/bg.jpg"); |
56 | bg_img=Image.createImage("/bg.jpg"); |
57 | load_img=Image.createImage("/load.png"); |
57 | load_img=Image.createImage("/load.png"); |
58 | } |
58 | } |
Line 59... | Line 59... | ||
59 | catch (Exception e) |
59 | catch (Exception e) |
60 | { |
60 | { |
61 | err+=e.toString(); |
61 | err+=e.toString(); |
62 | } |
62 | } |
Line 63... | Line 63... | ||
63 | 63 | ||
64 | 64 | ||
65 | nick_line_pos_data=new int[bg_img.getWidth()]; |
65 | nick_line_pos_data=new int[bg_img.getWidth()]; |
66 | roll_line_pos_data=new int[bg_img.getWidth()]; |
66 | roll_line_pos_data=new int[bg_img.getWidth()]; |
67 | accnick_line_pos_data=new int[bg_img.getWidth()]; |
67 | accnick_line_pos_data=new int[bg_img.getWidth()]; |
68 | accroll_line_pos_data=new int[bg_img.getWidth()]; |
68 | accroll_line_pos_data=new int[bg_img.getWidth()]; |
69 | 69 | ||
Line 70... | Line 70... | ||
70 | for (int c=0;c<bg_img.getWidth();c++) |
70 | for (int c=0;c<bg_img.getWidth();c++) |
71 | { |
71 | { |
Line 72... | Line 72... | ||
72 | nick_line_pos_data[c]=-1; |
72 | nick_line_pos_data[c]=-1; |
73 | roll_line_pos_data[c]=-1; |
73 | roll_line_pos_data[c]=-1; |
74 | accnick_line_pos_data[c]=-1; |
74 | accnick_line_pos_data[c]=-1; |
Line 75... | Line 75... | ||
75 | accroll_line_pos_data[c]=-1; |
75 | accroll_line_pos_data[c]=-1; |
76 | } |
- | |
77 | - | ||
78 | - | ||
79 | // mk = new MKCommunicator("btspp://000BCE016B5B:1"); |
- | |
80 | //connect_mk("btspp://000BCE016B4F:1"); |
- | |
81 | - | ||
82 | - | ||
83 | try |
- | |
84 | { |
76 | } |
- | 77 | ||
- | 78 | ||
85 | RecordStore recStore = RecordStore.openRecordStore("bturl", true ); |
79 | // mk = new MKCommunicator("btspp://000BCE016B5B:1"); |
- | 80 | //connect_mk("btspp://000BCE016B4F:1"); |
|
86 | 81 | ||
- | 82 | ||
- | 83 | try |
|
- | 84 | { |
|
- | 85 | RecordStore recStore = RecordStore.openRecordStore("bturl", true ); |
|
- | 86 | ||
Line 87... | Line 87... | ||
87 | if (recStore.getNumRecords()==1) |
87 | if (recStore.getNumRecords()==1) |
Line 88... | Line 88... | ||
88 | { |
88 | { |
Line 89... | Line 89... | ||
89 | byte[] recData = new byte[recStore.getRecordSize(1)]; |
89 | byte[] recData = new byte[recStore.getRecordSize(1)]; |
Line 90... | Line 90... | ||
90 | int len = recStore.getRecord(1, recData, 0); |
90 | int len = recStore.getRecord(1, recData, 0); |
91 | rescan=false; |
91 | rescan=false; |
92 | connect_mk(new String(recData, 0, len)); |
92 | connect_mk(new String(recData, 0, len)); |
Line 115... | Line 115... | ||
115 | public void run() |
115 | public void run() |
116 | { |
116 | { |
Line 117... | Line 117... | ||
117 | 117 | ||
118 | while(true) |
118 | while(true) |
- | 119 | { |
|
- | 120 | repaint(); |
|
- | 121 | serviceRepaints(); |
|
119 | { |
122 | |
120 | long loopStartTime = System.currentTimeMillis(); |
123 | long loopStartTime = System.currentTimeMillis(); |
121 | long sleeptime=0; |
124 | long sleeptime=0; |
Line 122... | Line 125... | ||
122 | // ticked thing |
125 | // ticked thing |
Line -... | Line 126... | ||
- | 126 | ||
- | 127 | frame_pos++; |
|
- | 128 | ||
- | 129 | ||
- | 130 | ||
- | 131 | switch(state) |
|
- | 132 | { |
|
- | 133 | case STATEID_MOTORTEST: |
|
- | 134 | ||
- | 135 | if (motor_test_sel_all) |
|
- | 136 | for (int m=0;m<4;m++) |
|
- | 137 | { |
|
- | 138 | motor_test[m]+=act_motor_increase; |
|
- | 139 | if (motor_test[m]<0)motor_test[m]=0; |
|
- | 140 | } |
|
- | 141 | else |
|
- | 142 | { |
|
- | 143 | motor_test[act_motor]+=act_motor_increase; |
|
- | 144 | if (motor_test[act_motor]<0)motor_test[act_motor]=0; |
|
- | 145 | } |
|
- | 146 | ||
- | 147 | mk.motor_test(motor_test); |
|
123 | 148 | break; |
|
124 | frame_pos++; |
149 | } |
125 | 150 | ||
126 | try { |
151 | try { |
127 | nick_line_pos_data[-bg_offset] = mk.debug_data.nick_int(); |
152 | nick_line_pos_data[-bg_offset] = mk.debug_data.nick_int(); |
128 | roll_line_pos_data[-bg_offset] = mk.debug_data.roll_int(); |
153 | roll_line_pos_data[-bg_offset] = mk.debug_data.roll_int(); |
129 | accnick_line_pos_data[-bg_offset] = mk.debug_data.accnick(); |
154 | accnick_line_pos_data[-bg_offset] = mk.debug_data.accnick(); |
130 | accroll_line_pos_data[-bg_offset] = mk.debug_data.accroll(); |
155 | accroll_line_pos_data[-bg_offset] = mk.debug_data.accroll(); |
131 | } |
156 | } |
132 | catch (Exception e) |
157 | catch (Exception e) |
Line 159... | Line 184... | ||
159 | 184 | ||
160 | root.quit(); |
185 | root.quit(); |
161 | } |
186 | } |
162 | if (rescan) |
187 | if (rescan) |
163 | { |
188 | { |
164 | if (mk!=null) mk.close_connections(true); |
189 | if (mk!=null) mk.close_connections(true); |
165 | mk=null; |
190 | mk=null; |
166 | bt_scanner.search_again(); |
191 | bt_scanner.search_again(); |
Line -... | Line 192... | ||
- | 192 | } |
|
167 | } |
193 | |
168 | 194 | try { |
|
169 | rescan=false; |
195 | rescan=false; |
170 | bg_offset--; |
196 | bg_offset--; |
171 | if (bg_offset==-bg_img.getWidth()) |
197 | if (bg_offset==-bg_img.getWidth()) |
172 | bg_offset=0; |
198 | bg_offset=0; |
173 | com.nokia.mid.ui.DeviceControl.setLights(0,100); |
199 | com.nokia.mid.ui.DeviceControl.setLights(0,100); |
- | 200 | //bt.tick(); |
|
- | 201 | // every state has sth to do in tick section |
|
- | 202 | } |
|
- | 203 | catch (Exception e) |
|
- | 204 | { |
|
Line 174... | Line 205... | ||
174 | //bt.tick(); |
205 | |
175 | // every state has sth to do in tick section |
- | |
176 | - | ||
- | 206 | } |
|
- | 207 | ||
Line 177... | Line 208... | ||
177 | 208 | ||
Line 178... | Line 209... | ||
178 | // System.gc(); |
209 | // System.gc(); |
179 | repaint(); |
210 | |
Line 180... | Line 211... | ||
180 | serviceRepaints(); |
211 | |
181 | 212 | ||
182 | 213 | ||
183 | sleeptime=1000/ 15 - (int) (System.currentTimeMillis()- loopStartTime); |
214 | sleeptime=1000/ 15 - (int) (System.currentTimeMillis()- loopStartTime); |
184 | 215 | ||
Line 185... | Line 216... | ||
185 | 216 | ||
186 | if (sleeptime<0) |
217 | if (sleeptime<0) |
Line -... | Line 218... | ||
- | 218 | sleeptime=100; // everyone has fi sleep |
|
187 | sleeptime=100; // everyone has fi sleep |
219 | |
- | 220 | try { Thread.sleep(sleeptime); } |
|
- | 221 | catch (Exception e) |
|
- | 222 | { |
|
188 | 223 | err="Problem Sleeping "; |
|
Line -... | Line 224... | ||
- | 224 | } |
|
- | 225 | ||
189 | try { Thread.sleep(sleeptime); } |
226 | } |
190 | catch (Exception e) |
227 | } |
191 | { |
- | |
192 | err="Problem Sleeping "; |
- | |
193 | } |
- | |
194 | - | ||
195 | } |
- | |
196 | } |
- | |
197 | - | ||
198 | - | ||
199 | - | ||
200 | - | ||
201 | int local_max=-1; |
- | |
202 | - | ||
203 | // drawing section |
- | |
204 | public void paint(Graphics g) { |
- | |
205 | - | ||
206 | if (mk!=null) |
- | |
207 | { |
- | |
208 | line_middle_y=this.getHeight()/2; |
- | |
209 | if (local_max<Math.abs(mk.debug_data.nick_int())) |
- | |
210 | local_max=Math.abs(mk.debug_data.nick_int()); |
- | |
Line 211... | Line 228... | ||
211 | if (local_max<Math.abs(mk.debug_data.roll_int())) |
228 | |
Line 212... | Line 229... | ||
212 | local_max=Math.abs(mk.debug_data.roll_int()); |
229 | |
213 | if (local_max<Math.abs(mk.debug_data.accnick())) |
230 | |
- | 231 | public int state=-1; |
|
- | 232 | ||
- | 233 | public final static int STATEID_MOTORTEST=2; |
|
- | 234 | ||
- | 235 | ||
- | 236 | int local_max=-1; |
|
- | 237 | ||
- | 238 | int[] motor_test = {0,0,0,0}; |
|
- | 239 | ||
- | 240 | // drawing section |
|
- | 241 | public void paint(Graphics g) { |
|
- | 242 | ||
- | 243 | try { |
|
- | 244 | ||
- | 245 | if (mk!=null) |
|
Line 214... | Line -... | ||
214 | local_max=Math.abs(mk.debug_data.accnick()); |
- | |
215 | if (local_max<Math.abs(mk.debug_data.accroll())) |
246 | { |
216 | local_max=Math.abs(mk.debug_data.accroll()); |
247 | line_middle_y=this.getHeight()/2; |
Line 217... | Line -... | ||
217 | line_scaler= local_max/(this.getHeight()/2)+1; |
- | |
218 | } |
- | |
Line 219... | Line -... | ||
219 | int spacer=(g.getFont().getHeight()); |
- | |
220 | g.setColor(0xFFFFFF); |
- | |
221 | g.fillRect(0,0,this.getWidth(),this.getHeight()); |
- | |
222 | g.drawImage(bg_img,bg_offset,0, g.TOP | g.LEFT); |
- | |
223 | if (bg_offset+bg_img.getWidth()<this.getWidth()) |
- | |
224 | g.drawImage(bg_img,bg_offset+bg_img.getWidth(),0, g.TOP | g.LEFT); |
- | |
225 | - | ||
226 | g.setColor(0x000000); |
- | |
227 | - | ||
228 | if (mk==null) |
- | |
229 | { |
- | |
Line -... | Line 248... | ||
- | 248 | if (local_max<Math.abs(mk.debug_data.nick_int())) |
|
- | 249 | local_max=Math.abs(mk.debug_data.nick_int()); |
|
- | 250 | if (local_max<Math.abs(mk.debug_data.roll_int())) |
|
- | 251 | local_max=Math.abs(mk.debug_data.roll_int()); |
|
- | 252 | if (local_max<Math.abs(mk.debug_data.accnick())) |
|
- | 253 | local_max=Math.abs(mk.debug_data.accnick()); |
|
- | 254 | if (local_max<Math.abs(mk.debug_data.accroll())) |
|
- | 255 | local_max=Math.abs(mk.debug_data.accroll()); |
|
- | 256 | line_scaler= local_max/(this.getHeight()/2)+1; |
|
- | 257 | } |
|
- | 258 | int spacer=(g.getFont().getHeight()); |
|
- | 259 | g.setColor(0xFFFFFF); |
|
Line -... | Line 260... | ||
- | 260 | g.fillRect(0,0,this.getWidth(),this.getHeight()); |
|
- | 261 | g.drawImage(bg_img,bg_offset,0, g.TOP | g.LEFT); |
|
- | 262 | ||
- | 263 | if (bg_offset+bg_img.getWidth()<this.getWidth()) |
|
- | 264 | g.drawImage(bg_img,bg_offset+bg_img.getWidth(),0, g.TOP | g.LEFT); |
|
Line 230... | Line 265... | ||
230 | 265 | ||
231 | 266 | ||
232 | if (bt_scanner.searching) |
267 | |
233 | { |
- | |
Line -... | Line 268... | ||
- | 268 | ||
234 | 269 | switch(state) |
|
Line -... | Line 270... | ||
- | 270 | { |
|
- | 271 | case STATEID_MOTORTEST: |
|
- | 272 | for (int bar=0;bar<4;bar++) |
|
- | 273 | { |
|
235 | 274 | g.setColor(((bar==act_motor)|motor_test_sel_all)?0x44CC44:0x4444DD); |
|
- | 275 | g.fillRect(this.getWidth()/(8*2)+bar*2*this.getWidth()/8,10,this.getWidth()/8,20+motor_test[bar]); |
|
- | 276 | g.setColor(0x000000); |
|
- | 277 | g.drawString(""+motor_test[bar] ,this.getWidth()/8+bar*2*this.getWidth()/8,10,Graphics.TOP | Graphics.HCENTER); |
|
- | 278 | if(bar!=4) g.drawString(""+mk.debug_data.motor_val(bar) ,this.getWidth()/8+bar*2*this.getWidth()/8,30,Graphics.TOP | Graphics.HCENTER); |
|
- | 279 | } |
|
- | 280 | break; |
|
Line 236... | Line -... | ||
236 | g.drawString("scanning for BT-Devices",this.getWidth()/2,this.getHeight()/2+load_img.getHeight()/8,Graphics.TOP | Graphics.HCENTER); |
- | |
237 | - | ||
Line 238... | Line -... | ||
238 | g.setClip(this.getWidth()/2-load_img.getWidth()/6,this.getHeight()/2-load_img.getHeight()/8, load_img.getWidth()/4,load_img.getHeight()/3);; |
- | |
239 | 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); |
- | |
240 | g.drawImage(bt_img,this.getWidth()/2 ,this.getHeight()/2 , g.HCENTER | g.VCENTER); |
- | |
Line 241... | Line -... | ||
241 | } |
- | |
242 | else |
- | |
243 | { |
- | |
244 | g.drawString("Press key 0-"+(bt_scanner.remote_device_count-1) + " to continue" ,0,0,Graphics.TOP | Graphics.LEFT); |
- | |
245 | for (int i=0;i<bt_scanner.remote_device_count;i++) |
- | |
246 | g.drawString("#"+i+">" + bt_scanner.remote_device_name[i]+"("+bt_scanner.remote_device_mac[i]+")",0,spacer+spacer*i,Graphics.TOP | Graphics.LEFT); |
- | |
247 | - | ||
248 | } |
- | |
Line -... | Line 281... | ||
- | 281 | ||
- | 282 | default: |
|
- | 283 | g.setColor(0x000000); |
|
- | 284 | ||
Line 249... | Line 285... | ||
249 | 285 | if (mk==null) |
|
Line 250... | Line -... | ||
250 | - | ||
251 | - | ||
252 | - | ||
253 | } |
286 | { |
254 | else // MK is connected |
- | |
255 | { |
- | |
256 | int y_off=0; |
- | |
Line 257... | Line -... | ||
257 | - | ||
- | 287 | ||
258 | 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+")",0,y_off,Graphics.TOP | Graphics.LEFT); |
288 | |
Line 259... | Line 289... | ||
259 | 289 | if (bt_scanner.searching) |
|
- | 290 | { |
|
- | 291 | ||
Line -... | Line 292... | ||
- | 292 | ||
- | 293 | g.drawString("scanning for BT-Devices",this.getWidth()/2,this.getHeight()/2+load_img.getHeight()/8,Graphics.TOP | Graphics.HCENTER); |
|
- | 294 | ||
- | 295 | g.setClip(this.getWidth()/2-load_img.getWidth()/6,this.getHeight()/2-load_img.getHeight()/8, load_img.getWidth()/4,load_img.getHeight()/3);; |
|
- | 296 | 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); |
|
- | 297 | g.drawImage(bt_img,this.getWidth()/2 ,this.getHeight()/2 , g.HCENTER | g.VCENTER); |
|
- | 298 | } |
|
- | 299 | else |
|
- | 300 | { |
|
- | 301 | g.drawString("Press key 0-"+(bt_scanner.remote_device_count-1) + " to continue" ,0,0,Graphics.TOP | Graphics.LEFT); |
|
- | 302 | for (int i=0;i<bt_scanner.remote_device_count;i++) |
|
- | 303 | g.drawString("#"+i+">" + bt_scanner.remote_device_name[i]+"("+bt_scanner.remote_device_mac[i]+")",0,spacer+spacer*i,Graphics.TOP | Graphics.LEFT); |
|
- | 304 | ||
- | 305 | } |
|
- | 306 | ||
- | 307 | ||
- | 308 | ||
- | 309 | ||
- | 310 | } |
|
260 | y_off+=spacer; |
311 | else // MK is connected |
- | 312 | { |
|
- | 313 | int y_off=0; |
|
Line 261... | Line 314... | ||
261 | 314 | ||
Line 262... | Line 315... | ||
262 | 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); |
315 | 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+")",0,y_off,Graphics.TOP | Graphics.LEFT); |
263 | y_off+=spacer; |
316 | |
Line 264... | Line 317... | ||
264 | 317 | y_off+=spacer; |
|
Line 265... | Line 318... | ||
265 | 318 | ||
Line 266... | Line 319... | ||
266 | 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); |
319 | 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); |
267 | y_off+=spacer; |
320 | y_off+=spacer; |
268 | 321 | ||
269 | if (mk.connected) |
322 | |
270 | { |
323 | 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); |
271 | g.drawString("time conn:" +((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
324 | y_off+=spacer; |
272 | y_off+=spacer; |
325 | |
273 | g.drawString("time motor>15:" +(mk_stat.motor_on_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
326 | if (mk.connected) |
274 | y_off+=spacer; |
327 | { |
275 | g.drawString("time motor=15:" +(mk_stat.motor_stand_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
328 | g.drawString("time conn:" +((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
276 | } |
329 | y_off+=spacer; |
277 | 330 | g.drawString("time motor>15:" +(mk_stat.motor_on_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
|
278 | 331 | y_off+=spacer; |
|
Line 279... | Line 332... | ||
279 | y_off=this.getHeight()-4*19; |
332 | g.drawString("time motor=15:" +(mk_stat.motor_stand_time/1000) +"s" ,0,y_off,Graphics.TOP | Graphics.LEFT); |
- | 333 | } |
|
- | 334 | ||
- | 335 | ||
- | 336 | y_off=this.getHeight()-4*lcd_img.getHeight(); |
|
280 | 337 | ||
Line 281... | Line 338... | ||
281 | for ( int foo=0;foo<4;foo++) |
338 | for ( int foo=0;foo<4;foo++) |
282 | { |
339 | { |
283 | 340 | for (int x=0;x<20;x++) |
|
Line 341... | Line 398... | ||
341 | } |
398 | } |
Line 342... | Line 399... | ||
342 | 399 | ||
343 | /*********************************************** input Section **********************************************/ |
400 | /*********************************************** input Section **********************************************/ |
344 | // keys |
401 | // keys |
- | 402 | public boolean fullscreen=false; |
|
- | 403 | public int act_motor=0; |
|
- | 404 | public int act_motor_increase=0; |
|
- | 405 | public boolean motor_test_sel_all=false; |
|
- | 406 | ||
- | 407 | public void chg_state(int _state) |
|
- | 408 | { |
|
- | 409 | state=_state; |
|
- | 410 | } |
|
- | 411 | ||
- | 412 | ||
- | 413 | public void keyReleased(int keyCode) |
|
- | 414 | { |
|
- | 415 | ||
- | 416 | switch(state) |
|
- | 417 | { |
|
- | 418 | case STATEID_MOTORTEST: |
|
- | 419 | act_motor_increase=0; |
|
- | 420 | break; |
|
- | 421 | } |
|
- | 422 | ||
Line 345... | Line 423... | ||
345 | public boolean fullscreen=false; |
423 | } |
346 | 424 | ||
Line 347... | Line -... | ||
347 | public void keyPressed(int keyCode) |
- | |
348 | { |
- | |
349 | 425 | public void keyPressed(int keyCode) |
|
350 | if ((mk==null)&&(keyCode >= this.KEY_NUM0) && (keyCode < this.KEY_NUM0+bt_scanner.remote_device_count)) |
426 | { |
- | 427 | ||
351 | connect_mk("btspp://"+bt_scanner.remote_device_mac[keyCode-this.KEY_NUM0] + ":1"); |
428 | switch(state) |
352 | else |
429 | { |
- | 430 | case STATEID_MOTORTEST: |
|
- | 431 | switch (getGameAction (keyCode)) |
|
- | 432 | { |
|
Line -... | Line 433... | ||
- | 433 | case UP: |
|
- | 434 | act_motor_increase=-1; |
|
- | 435 | break; |
|
- | 436 | ||
- | 437 | case DOWN: |
|
- | 438 | act_motor_increase=1; |
|
- | 439 | break; |
|
- | 440 | ||
353 | { |
441 | case FIRE: |
354 | switch (keyCode) |
442 | motor_test_sel_all=!motor_test_sel_all; |
- | 443 | break; |
|
- | 444 | ||
- | 445 | case LEFT: |
|
- | 446 | act_motor--; |
|
355 | { |
447 | if (act_motor<0) {act_motor=0; chg_state(-1); } |
- | 448 | break; |
|
356 | 449 | ||
- | 450 | case RIGHT: |
|
Line 357... | Line 451... | ||
357 | case KEY_STAR: |
451 | act_motor++; |
- | 452 | act_motor%=4; |
|
358 | mk.other_data_count=23; |
453 | break; |
359 | quit=true; |
454 | } |
360 | break; |
455 | |
361 | - | ||
362 | case KEY_POUND: |
456 | break; |
363 | //rescan=true; |
- | |
364 | fullscreen=!fullscreen; |
457 | |
365 | setFullScreenMode(fullscreen); |
458 | default: |
366 | break; |
- | |
367 | } |
459 | if ((mk==null)&&(keyCode >= this.KEY_NUM0) && (keyCode < this.KEY_NUM0+bt_scanner.remote_device_count)) |
Line -... | Line 460... | ||
- | 460 | connect_mk("btspp://"+bt_scanner.remote_device_mac[keyCode-this.KEY_NUM0] + ":1"); |
|
- | 461 | else |
|
- | 462 | { |
|
- | 463 | switch (keyCode) |
|
- | 464 | { |
|
- | 465 | ||
- | 466 | case KEY_STAR: |
|
- | 467 | mk.other_data_count=23; |
|
- | 468 | quit=true; |
|
- | 469 | break; |
|
- | 470 | ||
- | 471 | case KEY_POUND: |
|
- | 472 | //rescan=true; |
|
- | 473 | fullscreen=!fullscreen; |
|
- | 474 | setFullScreenMode(fullscreen); |
|
- | 475 | ||
- | 476 | break; |
|
- | 477 | } |
|
368 | switch (getGameAction (keyCode)) |
478 | switch (getGameAction (keyCode)) |
369 | { |
479 | { |
- | 480 | case UP: |
|
- | 481 | mk.LCD.LCD_PREVPAGE(); |
|
- | 482 | break; |
|
- | 483 | ||
370 | case UP: |
484 | case DOWN: |
- | 485 | mk.LCD.LCD_NEXTPAGE(); |
|
371 | mk.LCD.LCD_PREVPAGE(); |
486 | break; |
- | 487 | ||
372 | break; |
488 | case RIGHT: |
Line 373... | Line -... | ||
373 | - | ||
374 | case DOWN: |
489 | state=STATEID_MOTORTEST; |
375 | mk.LCD.LCD_NEXTPAGE(); |
490 | break; |