Rev 92 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
84 | ligi | 1 | package org.ligi; |
2 | |||
3 | import android.app.Activity; |
||
4 | import android.os.Bundle; |
||
5 | |||
6 | import android.app.Activity; |
||
7 | import android.os.Bundle; |
||
8 | |||
9 | import android.view.View; |
||
10 | import android.widget.TextView; |
||
11 | |||
12 | |||
13 | import android.app.Activity; |
||
14 | import android.content.Context; |
||
15 | import android.graphics.*; |
||
16 | import android.os.Bundle; |
||
17 | import android.os.*; |
||
18 | import android.view.View; |
||
92 | ligi | 19 | import android.util.Log; |
20 | import android.media.*; |
||
84 | ligi | 21 | import java.util.Random; |
92 | ligi | 22 | import java.net.*; |
23 | import java.io.*; |
||
84 | ligi | 24 | |
25 | |||
92 | ligi | 26 | import android.view.*; |
27 | |||
84 | ligi | 28 | import android.graphics.Region.Op; |
129 | ligi | 29 | import android.graphics.Bitmap.*; |
84 | ligi | 30 | |
92 | ligi | 31 | // not working atm - import org.bluez.*; |
84 | ligi | 32 | |
33 | public class DUBwiseView |
||
34 | extends View |
||
35 | implements DUBwiseDefinitions |
||
36 | |||
37 | |||
38 | { |
||
92 | ligi | 39 | |
40 | |||
41 | int state=0; |
||
42 | |||
43 | |||
44 | int state_intro_frame=0; |
||
45 | |||
46 | boolean do_sound=true; |
||
47 | boolean do_vibra=true; |
||
48 | boolean do_graph=true; |
||
49 | boolean menu_active=true; |
||
50 | |||
51 | public final int SKINID_DARK=0; |
||
52 | public final int SKINID_LIGHT=0; |
||
53 | int act_skin=0; |
||
54 | boolean keep_lighton=true; |
||
55 | |||
84 | ligi | 56 | private Paint mPaint = new Paint(); |
57 | |||
92 | ligi | 58 | // chars in bitmap |
84 | ligi | 59 | public static int LCD_CHAR_COUNT=222; |
92 | ligi | 60 | |
84 | ligi | 61 | // some images we need |
92 | ligi | 62 | private Bitmap icon_img,bg_img,lcd_tiles_img,bt_on_img,bt_off_img; |
63 | private Bitmap lcd_img=null; |
||
84 | ligi | 64 | // pos for scrolling |
65 | private int pos=0; |
||
66 | |||
67 | String str1=""; |
||
68 | String[] lcd_lines; |
||
92 | ligi | 69 | String[] menu_items; |
84 | ligi | 70 | long last_run=0; |
71 | int last_key=0; |
||
72 | |||
92 | ligi | 73 | |
74 | int auto_next_state=-1; |
||
75 | |||
84 | ligi | 76 | int wi,he; |
77 | // Activity context; |
||
78 | |||
92 | ligi | 79 | DUBwise root; |
80 | MKParamEditor param_editor; |
||
81 | // Activity root; |
||
84 | ligi | 82 | int lcd_top; |
92 | ligi | 83 | int act_menu_select=0; |
84 | int[] motortest_vals={0,0,0,0}; |
||
84 | ligi | 85 | |
92 | ligi | 86 | public DUBwiseView(DUBwise context) { |
84 | ligi | 87 | super(context); |
92 | ligi | 88 | root=context; |
89 | param_editor=new MKParamEditor(root); |
||
90 | chg_state_(STATEID_MAINMENU); |
||
91 | |||
84 | ligi | 92 | // needed to get Key Events |
93 | setFocusable(true); |
||
92 | ligi | 94 | |
95 | |||
84 | ligi | 96 | } |
97 | |||
92 | ligi | 98 | |
99 | public void chg_state(int next_state) |
||
100 | { |
||
101 | auto_next_state=next_state; |
||
102 | |||
103 | } |
||
104 | |||
105 | public void chg_state_(int next_state) |
||
106 | { |
||
107 | auto_next_state=-1; |
||
108 | menu_active=false; |
||
109 | state_intro_frame=0; |
||
110 | if (next_state!=state)act_menu_select=0; |
||
111 | // prepare next state |
||
112 | switch(next_state) |
||
113 | { |
||
114 | |||
115 | case STATEID_EDIT_PARAMS: |
||
116 | lcd_lines=param_editor.public_lcd_lines; |
||
117 | calc_lcd(); |
||
118 | break; |
||
119 | |||
120 | case STATEID_HANDLE_PARAMS: |
||
121 | menu_items=new String[2]; |
||
122 | menu_items[0]="write to MK"; |
||
123 | menu_items[1]="Discard"; |
||
124 | lcd_lines=new String[2]; |
||
125 | |||
126 | break; |
||
127 | |||
128 | case STATEID_SELECT_PARAMSET: |
||
129 | menu_items=new String[5]; |
||
130 | for (int i=0;i<5;i++) |
||
131 | menu_items[i]=root.mk.params.names[i]; |
||
132 | |||
133 | lcd_lines=new String[5]; |
||
134 | break; |
||
135 | |||
136 | case STATEID_MAINMENU: |
||
137 | menu_active=true; |
||
138 | menu_items=main_menu_items; |
||
139 | lcd_lines=new String[menu_items.length]; |
||
140 | |||
141 | |||
142 | for (int y=0;y<main_menu_items.length;y++) |
||
143 | lcd_lines[y]=" " + main_menu_items[y]; |
||
144 | |||
145 | break; |
||
146 | |||
147 | case STATEID_SETTINGSMENU: |
||
148 | |||
149 | menu_items=new String[settings_menu_items.length]; |
||
150 | for(int cnt=0;cnt<settings_menu_items.length;cnt++) |
||
151 | menu_items[cnt]=settings_menu_items[cnt]; |
||
152 | |||
153 | menu_items[0]+=(act_skin==SKINID_DARK)?"Dark":"Light"; |
||
154 | menu_items[1]+=(!do_sound)?"Off":"On"; |
||
155 | menu_items[2]+=(!do_vibra)?"Off":"On"; |
||
156 | menu_items[3]+=(!do_graph)?"Off":"On"; |
||
157 | menu_items[4]+=(!root.fullscreen)?"Off":"On"; |
||
158 | menu_items[5]+=(!keep_lighton)?"Off":"On"; |
||
159 | |||
160 | lcd_lines=new String[menu_items.length]; |
||
161 | break; |
||
162 | |||
163 | } |
||
164 | |||
165 | // switch state |
||
166 | if (lcd_img!=null)calc_lcd(); |
||
167 | state=next_state; |
||
168 | } |
||
169 | |||
84 | ligi | 170 | |
171 | public Bitmap resize_to_screen(Bitmap orig,float x_scale_,float y_scale_) |
||
172 | { |
||
173 | // createa matrix for the manipulation |
||
174 | Matrix matrix = new Matrix(); |
||
175 | float x_scale,y_scale; |
||
176 | if (y_scale_!=0f) |
||
129 | ligi | 177 | y_scale= (getHeight()*y_scale_ )/orig.getHeight(); |
84 | ligi | 178 | else // take x_scale |
129 | ligi | 179 | y_scale=(getWidth()*x_scale_ )/orig.getWidth(); |
84 | ligi | 180 | |
181 | if (x_scale_!=0f) |
||
129 | ligi | 182 | x_scale= (getWidth()*x_scale_ )/orig.getWidth(); |
84 | ligi | 183 | else |
129 | ligi | 184 | x_scale= (getHeight()*y_scale_ )/orig.getHeight(); |
84 | ligi | 185 | |
186 | matrix.postScale(x_scale , y_scale); |
||
129 | ligi | 187 | return Bitmap.createBitmap(orig, 0, 0,(int)( orig.getWidth()),(int)( orig.getHeight()), matrix,true);//BitmapContfig.ARGB_8888 ); |
84 | ligi | 188 | } |
189 | |||
190 | |||
191 | public boolean onKeyDown(int keyCode, KeyEvent event) |
||
192 | { |
||
129 | ligi | 193 | |
92 | ligi | 194 | |
195 | if ( keyCode==KeyEvent.KEYCODE_BACK) |
||
196 | { |
||
197 | if ( state==STATEID_MAINMENU) |
||
198 | root.finish(); |
||
199 | else |
||
200 | chg_state(STATEID_MAINMENU); |
||
201 | } |
||
202 | switch (state) |
||
203 | { |
||
204 | case STATEID_EDIT_PARAMS: |
||
205 | param_editor.keypress(keyCode,keyCode); |
||
206 | lcd_lines=param_editor.public_lcd_lines; |
||
207 | calc_lcd(); |
||
84 | ligi | 208 | break; |
92 | ligi | 209 | case STATEID_MAINMENU: |
210 | switch ( keyCode) |
||
211 | { |
||
212 | case KeyEvent.KEYCODE_DPAD_DOWN : |
||
213 | act_menu_select++; |
||
214 | break; |
||
84 | ligi | 215 | |
92 | ligi | 216 | case KeyEvent.KEYCODE_DPAD_UP : |
217 | act_menu_select--; |
||
218 | break; |
||
219 | |||
220 | case KeyEvent.KEYCODE_DPAD_CENTER : |
||
221 | menu_reaction(); |
||
222 | break; |
||
223 | |||
224 | } |
||
84 | ligi | 225 | break; |
92 | ligi | 226 | |
227 | case STATEID_FLIGHTVIEW: |
||
228 | |||
229 | switch ( keyCode) |
||
230 | { |
||
84 | ligi | 231 | |
92 | ligi | 232 | case KeyEvent.KEYCODE_DPAD_DOWN : |
233 | root.mk.LCD.LCD_NEXTPAGE(); |
||
234 | lcd_lines=root.mk.LCD.get_act_page(); |
||
235 | |||
236 | break; |
||
237 | |||
238 | case KeyEvent.KEYCODE_DPAD_UP : |
||
239 | root.mk.LCD.LCD_PREVPAGE(); |
||
240 | lcd_lines=root.mk.LCD.get_act_page(); |
||
241 | |||
242 | break; |
||
243 | |||
244 | |||
245 | } |
||
246 | calc_lcd(); |
||
84 | ligi | 247 | break; |
248 | } |
||
249 | |||
92 | ligi | 250 | // last_key=keyCode; |
251 | // if(lcd_img!=null) |
||
84 | ligi | 252 | calc_lcd(); |
253 | invalidate(); |
||
254 | return true; |
||
255 | } |
||
256 | |||
92 | ligi | 257 | public void menu_reaction() |
258 | { |
||
259 | switch (act_menu_select) |
||
260 | { |
||
261 | |||
262 | case MAINMENU_PARAMS: |
||
263 | chg_state(STATEID_EDIT_PARAMS); |
||
264 | break; |
||
265 | |||
266 | case MAINMENU_STICKS: |
||
267 | chg_state(STATEID_STICKVIEW); |
||
268 | break; |
||
269 | |||
270 | case MAINMENU_TELEMETRY: |
||
129 | ligi | 271 | chg_state(STATEID_FLIGHTVIEW); |
272 | // root.setContentView(new DUBwiseMapView(root)); |
||
92 | ligi | 273 | break; |
274 | |||
275 | case MAINMENU_RAWDEBUG: |
||
276 | chg_state(STATEID_RAWDEBUG); |
||
277 | break; |
||
278 | |||
279 | case MAINMENU_KEYCONTROL: |
||
280 | chg_state(STATEID_KEYCONTROL); |
||
281 | break; |
||
282 | |||
283 | |||
284 | case MAINMENU_MOTORTEST: |
||
285 | // root.mk.motor_test( motortest_vals); |
||
286 | chg_state(STATEID_MOTORTEST); |
||
287 | break; |
||
288 | |||
289 | case MAINMENU_QUIT: |
||
290 | |||
291 | root.quit(); |
||
292 | break; |
||
293 | } |
||
294 | } |
||
295 | |||
296 | |||
297 | |||
298 | |||
299 | int flight_x,flight_y; |
||
300 | |||
301 | @Override public boolean onTouchEvent(MotionEvent event) { |
||
302 | |||
303 | |||
129 | ligi | 304 | if ((event.getAction() ==MotionEvent.ACTION_UP)&&(event.getY()<bt_on_img.getHeight())) |
92 | ligi | 305 | { |
306 | if ( state==STATEID_MAINMENU) |
||
307 | root.finish(); |
||
308 | else |
||
309 | chg_state(STATEID_MAINMENU); |
||
310 | } |
||
311 | |||
312 | switch(state) |
||
313 | { |
||
314 | case STATEID_KEYCONTROL: |
||
315 | if (event.getAction() ==MotionEvent.ACTION_UP) |
||
316 | { |
||
317 | flight_x=getWidth()/2-getWidth()/8; |
||
318 | flight_y=getHeight()/2-getWidth()/8; |
||
319 | } |
||
320 | else |
||
321 | { |
||
322 | if(new RectF(getWidth()/8,(getHeight()-getWidth())/2-getWidth()/8,getWidth()-getWidth()/8,getHeight()-getWidth()/8).contains(event.getX(),event.getY())) |
||
323 | { |
||
324 | |||
325 | flight_x=(int)event.getX(); |
||
326 | flight_y=(int)event.getY(); |
||
327 | |||
328 | } |
||
329 | } |
||
330 | break; |
||
331 | case STATEID_MAINMENU: |
||
332 | if ((event.getAction() ==MotionEvent.ACTION_DOWN)||(event.getAction() ==MotionEvent.ACTION_MOVE)) |
||
333 | { |
||
334 | if (event.getY()>lcd_top) |
||
335 | { |
||
129 | ligi | 336 | act_menu_select=(int)((event.getY()-lcd_top)/lcd_tiles_img.getHeight()); |
92 | ligi | 337 | calc_lcd(); |
338 | } |
||
339 | } |
||
340 | |||
341 | if (event.getAction() ==MotionEvent.ACTION_UP) |
||
342 | |||
343 | { |
||
344 | if (event.getY()>lcd_top) |
||
345 | { |
||
129 | ligi | 346 | act_menu_select=(int)((event.getY()-lcd_top)/lcd_tiles_img.getHeight()); |
92 | ligi | 347 | menu_reaction(); |
348 | } |
||
349 | } |
||
350 | calc_lcd(); |
||
351 | |||
352 | break; |
||
353 | |||
354 | |||
355 | case STATEID_MOTORTEST: |
||
356 | if (new RectF(getWidth()/2 - getWidth()/8,getHeight()/2 -getWidth()/8 - (getWidth()/2 - getWidth()/8),getWidth()/2 + getWidth()/8,getHeight()/2 -getWidth()/8).contains(event.getX(),event.getY())) |
||
357 | motortest_vals[0]= (int)(event.getY()-getHeight()/2+getWidth()/8)*(-1)-5; |
||
358 | |||
359 | if (new RectF(getWidth()/2 - getWidth()/8,getHeight()/2 + getWidth()/8,getWidth()/2 + getWidth()/8,getHeight()/2+getWidth()/8 + (getWidth()/2 - getWidth()/8)).contains(event.getX(),event.getY())) |
||
360 | motortest_vals[1]= (int)(event.getY()-getHeight()/2-getWidth()/8)-5; |
||
361 | |||
362 | // left |
||
363 | if (new RectF(0,getHeight()/2 - getWidth()/8,getWidth()/2 - getWidth()/8,getHeight()/2+getWidth()/8).contains(event.getX(),event.getY())) |
||
364 | motortest_vals[2]= (int)(event.getX()-getWidth()/2+getWidth()/8)*(-1)-5; |
||
365 | |||
366 | if (new RectF(getWidth()/2+getWidth()/8,getHeight()/2 - getWidth()/8,getWidth(),getHeight()/2+getWidth()/8).contains(event.getX(),event.getY())) |
||
367 | motortest_vals[3]= (int)(event.getX()-getWidth()/2-getWidth()/8)-5; |
||
368 | |||
369 | for (int tmp=0;tmp<4;tmp++) |
||
370 | if (motortest_vals[tmp]<0)motortest_vals[tmp]=0; |
||
371 | |||
372 | root.mk.motor_test( motortest_vals); |
||
373 | break; |
||
374 | } |
||
375 | |||
376 | |||
377 | return true; |
||
378 | |||
379 | |||
380 | } |
||
381 | |||
382 | |||
383 | |||
384 | |||
84 | ligi | 385 | @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) |
386 | { |
||
92 | ligi | 387 | |
84 | ligi | 388 | bg_img = resize_to_screen(BitmapFactory.decodeResource(getResources(), R.drawable.starfield),0f,1f); |
92 | ligi | 389 | lcd_tiles_img = resize_to_screen(BitmapFactory.decodeResource(getResources(), R.drawable.lcd_green),0.05f*LCD_CHAR_COUNT,0f); |
390 | icon_img = resize_to_screen(BitmapFactory.decodeResource(getResources(), R.drawable.icon),0.15f,0f); |
||
391 | |||
392 | bt_off_img = resize_to_screen(BitmapFactory.decodeResource(getResources(), R.drawable.bt_off),0.06f,0f); |
||
393 | bt_on_img = resize_to_screen(BitmapFactory.decodeResource(getResources(), R.drawable.bt_on),0.06f,0f); |
||
394 | calc_lcd(); |
||
395 | |||
84 | ligi | 396 | } |
397 | |||
92 | ligi | 398 | |
84 | ligi | 399 | public void calc_lcd() |
400 | { |
||
92 | ligi | 401 | |
129 | ligi | 402 | lcd_top=getHeight()-lcd_lines.length*lcd_tiles_img.getHeight(); |
84 | ligi | 403 | Paint paint = mPaint; |
129 | ligi | 404 | lcd_img= Bitmap.createBitmap(getWidth(),lcd_lines.length*lcd_tiles_img.getHeight()+100,Bitmap.Config.ARGB_8888); |
84 | ligi | 405 | Canvas lcd_canvas=new Canvas(); |
406 | |||
129 | ligi | 407 | lcd_canvas.setBitmap(lcd_img); |
84 | ligi | 408 | lcd_canvas.drawColor(Color.WHITE); |
129 | ligi | 409 | int char_width=(int)(lcd_tiles_img.getWidth()/LCD_CHAR_COUNT); |
84 | ligi | 410 | for ( int lcd_line=0 ; lcd_line < lcd_lines.length ; lcd_line++) |
411 | for (int char_pos=0;char_pos<20;char_pos++) |
||
412 | { |
||
413 | int act_char=0; |
||
414 | |||
415 | if (char_pos<lcd_lines[lcd_line].length()) |
||
416 | act_char=lcd_lines[lcd_line].charAt(char_pos)-32; |
||
417 | |||
92 | ligi | 418 | if ((menu_active)&&(act_menu_select==lcd_line)&& (char_pos==0)) |
84 | ligi | 419 | act_char=30; |
420 | |||
129 | ligi | 421 | lcd_canvas.clipRect(new RectF(char_pos*char_width,lcd_tiles_img.getHeight()*lcd_line,(char_pos+1)*char_width,lcd_tiles_img.getHeight()*(lcd_line+1)),Op.REPLACE ); |
84 | ligi | 422 | |
129 | ligi | 423 | lcd_canvas.drawBitmap(lcd_tiles_img,(char_pos-act_char)*(char_width),lcd_tiles_img.getHeight()*(lcd_line) , paint); |
84 | ligi | 424 | |
425 | |||
426 | } |
||
427 | } |
||
428 | |||
92 | ligi | 429 | // fixme -> put in own timed thread - not in draw invalidate loop |
84 | ligi | 430 | public void tick() |
431 | { |
||
432 | pos--; |
||
433 | pos%=bg_img.getWidth(); |
||
434 | //SystemClock.sleep(50); |
||
92 | ligi | 435 | |
436 | if (auto_next_state==-1) |
||
437 | switch(state) |
||
438 | { |
||
439 | case STATEID_FLIGHTVIEW: |
||
129 | ligi | 440 | root.mk.trigger_debug_data(); |
92 | ligi | 441 | lcd_lines=root.mk.LCD.get_act_page(); |
442 | calc_lcd(); |
||
443 | if (state_intro_frame<200) |
||
444 | state_intro_frame+=5; |
||
445 | break; |
||
446 | case STATEID_EDIT_PARAMS: |
||
447 | |||
448 | |||
449 | case STATEID_MAINMENU: |
||
450 | if (state_intro_frame<200) |
||
451 | state_intro_frame+=5; |
||
452 | break; |
||
453 | |||
454 | case STATEID_RAWDEBUG: |
||
455 | case STATEID_MOTORTEST: |
||
456 | if (state_intro_frame<150) |
||
457 | state_intro_frame+=5; |
||
458 | break; |
||
459 | |||
460 | case STATEID_KEYCONTROL: |
||
461 | case STATEID_STICKVIEW: |
||
462 | if (state_intro_frame<100) |
||
463 | state_intro_frame+=3; |
||
464 | break; |
||
465 | |||
466 | } |
||
467 | else |
||
468 | { |
||
469 | if (state_intro_frame>10) |
||
470 | state_intro_frame-=7; |
||
471 | else |
||
472 | { |
||
473 | state_intro_frame=0; |
||
474 | chg_state_(auto_next_state); |
||
475 | } |
||
476 | |||
477 | |||
478 | |||
479 | } |
||
480 | |||
84 | ligi | 481 | } |
482 | |||
483 | |||
484 | @Override protected void onDraw(Canvas canvas) { |
||
92 | ligi | 485 | |
486 | |||
487 | |||
84 | ligi | 488 | tick(); |
489 | |||
490 | Paint paint = mPaint; |
||
491 | paint.setAntiAlias(true); |
||
492 | |||
92 | ligi | 493 | paint.setARGB(255,0,0,0); |
84 | ligi | 494 | canvas.drawBitmap(bg_img,pos,0 , paint); |
495 | |||
129 | ligi | 496 | if ((bg_img.getWidth()+pos)<(getWidth())) |
497 | canvas.drawBitmap(bg_img,pos+bg_img.getWidth(),0 , paint); |
||
84 | ligi | 498 | |
92 | ligi | 499 | |
500 | switch ( state ) |
||
501 | { |
||
502 | case STATEID_EDIT_PARAMS: |
||
503 | case STATEID_FLIGHTVIEW: |
||
129 | ligi | 504 | |
92 | ligi | 505 | paint.setARGB(state_intro_frame ,0,0,0); |
506 | canvas.drawBitmap(lcd_img,0,lcd_top , paint); |
||
507 | break; |
||
508 | |||
509 | case STATEID_MOTORTEST: |
||
510 | |||
511 | paint.setARGB(state_intro_frame,100,100,100); |
||
512 | |||
513 | |||
514 | //front |
||
515 | |||
516 | canvas.drawRoundRect(new RectF(getWidth()/2 - getWidth()/8,getHeight()/2 -getWidth()/8 - (getWidth()/2 - getWidth()/8),getWidth()/2 + getWidth()/8,getHeight()/2 -getWidth()/8),5,5,paint); |
||
517 | |||
518 | // back |
||
519 | canvas.drawRoundRect(new RectF(getWidth()/2 - getWidth()/8,getHeight()/2 + getWidth()/8,getWidth()/2 + getWidth()/8,getHeight()/2+getWidth()/8 + (getWidth()/2 - getWidth()/8)),5,5,paint); |
||
520 | |||
521 | // left |
||
522 | canvas.drawRoundRect(new RectF(0,getHeight()/2 - getWidth()/8,getWidth()/2 - getWidth()/8,getHeight()/2+getWidth()/8),5,5,paint); |
||
523 | |||
524 | canvas.drawRoundRect(new RectF(getWidth()/2+getWidth()/8,getHeight()/2 - getWidth()/8,getWidth(),getHeight()/2+getWidth()/8),5,5,paint); |
||
525 | |||
526 | |||
527 | paint.setARGB(100,30,30,255); |
||
528 | |||
529 | canvas.drawRoundRect(new RectF(getWidth()/2 - getWidth()/8,getHeight()/2 -getWidth()/8 - motortest_vals[0],getWidth()/2 + getWidth()/8,getHeight()/2 -getWidth()/8),5,5,paint); |
||
530 | |||
531 | // back |
||
532 | canvas.drawRoundRect(new RectF(getWidth()/2 - getWidth()/8,getHeight()/2 + getWidth()/8,getWidth()/2 + getWidth()/8,getHeight()/2+getWidth()/8 + motortest_vals[1]),5,5,paint); |
||
533 | |||
534 | // left |
||
535 | canvas.drawRoundRect(new RectF(getWidth()/2-getWidth()/8- motortest_vals[2],getHeight()/2 - getWidth()/8,getWidth()/2 - getWidth()/8,getHeight()/2+getWidth()/8),5,5,paint); |
||
536 | |||
537 | canvas.drawRoundRect(new RectF(getWidth()/2+getWidth()/8,getHeight()/2 - getWidth()/8,getWidth()/2+getWidth()/8+ motortest_vals[3],getHeight()/2+getWidth()/8),5,5,paint); |
||
538 | |||
539 | |||
540 | paint.setARGB(state_intro_frame+70,0,250,0); |
||
541 | paint.setTextAlign(Paint.Align.CENTER); |
||
542 | |||
543 | canvas.drawText("Front:"+ motortest_vals[0],getWidth()/2 ,getHeight()/2 -getWidth()/8-10,paint); |
||
544 | |||
545 | canvas.drawText("Back:"+ motortest_vals[1],getWidth()/2 ,getHeight()/2 +getWidth()/8+15,paint); |
||
546 | |||
547 | canvas.drawText("Left:"+ motortest_vals[2],getWidth()/4 ,getHeight()/2 ,paint); |
||
548 | canvas.drawText("Right:"+ motortest_vals[3],3*getWidth()/4 ,getHeight()/2 ,paint); |
||
549 | break; |
||
550 | |||
551 | case STATEID_RAWDEBUG: |
||
552 | paint.setARGB(state_intro_frame,50,50,200); |
||
553 | |||
84 | ligi | 554 | |
92 | ligi | 555 | for(int y_p=0;y_p<16;y_p++) |
556 | canvas.drawRoundRect(new RectF(0,(getHeight()/32)*y_p*2,getWidth(),(getHeight()/32)*(y_p*2+1)),5,5,paint); |
||
84 | ligi | 557 | |
92 | ligi | 558 | |
559 | |||
560 | paint.setARGB(state_intro_frame,0,250,0); |
||
561 | |||
562 | for(int y_p=0;y_p<32;y_p++) |
||
563 | { |
||
564 | canvas.drawText( root.mk.debug_data.names[y_p],0,(getHeight()/32)*(y_p+1)-2,paint); |
||
565 | canvas.drawText( ""+root.mk.debug_data.analog[y_p],getWidth()/3,(getHeight()/32)*(y_p+1)-2,paint); |
||
566 | } |
||
567 | |||
568 | |||
569 | |||
570 | |||
571 | break; |
||
572 | |||
573 | case STATEID_KEYCONTROL: |
||
129 | ligi | 574 | canvas.rotate((root.mk.debug_data.analog[18]*(-90))/3000,getWidth()/2,getHeight()/2); |
575 | paint.setARGB(state_intro_frame,177,129,0); |
||
576 | // roll rect |
||
577 | canvas.drawRect(-getWidth(),getHeight()/2,2*getWidth(),3*getHeight()/2,paint); |
||
578 | |||
579 | int bar_height=20; |
||
580 | // nick rect |
||
581 | paint.setARGB(state_intro_frame,0,200,0); |
||
582 | canvas.drawRoundRect(new RectF(getWidth()/3,getHeight()/2 -bar_height/2 + root.mk.debug_data.analog[17]*getHeight()/(3*3000) ,2*getWidth()/3, getHeight()/2+ root.mk.debug_data.analog[17]*getHeight()/(3*3000)+bar_height),5,5,paint); |
||
583 | |||
584 | |||
585 | |||
586 | |||
587 | canvas.restore(); |
||
588 | |||
92 | ligi | 589 | paint.setARGB(state_intro_frame,0,0,255); |
590 | // canvas.drawRoundRect(new RectF(getWidth()/2-getWidth()/8,getHeight()/2-getWidth()/8,getWidth()/2+getWidth()/8,getHeight()/2+getWidth()/8),5,5,paint); |
||
591 | |||
592 | canvas.drawRoundRect(new RectF(flight_x,flight_y,flight_x+getWidth()/8,flight_y+getWidth()/8),5,5,paint); |
||
593 | paint.setARGB(255,0,0,0); |
||
594 | break; |
||
595 | |||
596 | case STATEID_STICKVIEW: |
||
597 | paint.setARGB(state_intro_frame,50,50,200); |
||
598 | |||
599 | for(int y_p=0;y_p<10;y_p++) |
||
600 | canvas.drawRoundRect(new RectF(getWidth()/3 +((root.mk.stick_data.stick[y_p]<0)?(((root.mk.stick_data.stick[y_p]*getWidth()/3)/127)):0) ,(getHeight()/10)*y_p,getWidth()-getWidth()/3+((root.mk.stick_data.stick[y_p]>0)?(((root.mk.stick_data.stick[y_p]*getWidth()/3)/127)):0) ,(getHeight()/10)*(y_p+1)),15,15,paint); |
||
601 | paint.setARGB(state_intro_frame*2+50,0,255,0); |
||
602 | paint.setTextAlign(Paint.Align.CENTER); |
||
603 | for(int y_p=0;y_p<10;y_p++) |
||
604 | canvas.drawText("Chan " + (y_p+1) + "("+root.mk.stick_data.stick[y_p]+")",getWidth()/2,(getHeight()/20)*(y_p*2+1),paint); |
||
605 | paint.setTextAlign(Paint.Align.LEFT); |
||
606 | |||
607 | |||
608 | canvas.drawText("RC-Signal: " + root.mk.debug_data.SenderOkay(),0,10,paint); |
||
609 | break; |
||
610 | |||
611 | case STATEID_MAINMENU: |
||
612 | paint.setARGB(state_intro_frame ,0,0,0); |
||
613 | canvas.drawBitmap(lcd_img,0,lcd_top , paint); |
||
614 | |||
615 | |||
616 | int spacer=15; |
||
617 | |||
618 | int y_pos=10; |
||
619 | |||
620 | paint.setColor(Color.GREEN); |
||
621 | // canvas.drawText("LastKeyCode:"+last_key,0,10,paint); |
||
622 | paint.setTextAlign(Paint.Align.LEFT); |
||
623 | if (root.mk.connected) |
||
624 | { |
||
625 | canvas.drawText("Connected to MK with Version:"+root.mk.version.major+"."+root.mk.version.minor,0,y_pos,paint); |
||
626 | y_pos+=spacer; |
||
627 | canvas.drawText(" Power Source: " +( root.mk.debug_data.UBatt()/10) + "." + ( root.mk.debug_data.UBatt()%10) + " Volts | RC-Signal: " + root.mk.debug_data.SenderOkay(),0,y_pos,paint); |
||
628 | y_pos+=spacer; |
||
629 | canvas.drawText(" debug:"+root.mk.debug_data_count+ " LCD:" + root.mk.lcd_data_count + "(Pages:" + root.mk.LCD.pages + ") vers:" + root.mk.version_data_count,0,y_pos,paint); |
||
630 | y_pos+=spacer; |
||
631 | canvas.drawText(" other:"+root.mk.other_data_count+" params:"+root.mk.params_data_count,0,y_pos,paint); |
||
632 | } |
||
633 | else |
||
634 | { |
||
635 | canvas.drawText("No QuadroKopter Communication established.",0,y_pos,paint); |
||
636 | y_pos+=spacer; |
||
637 | } |
||
638 | break; |
||
639 | } |
||
640 | |||
641 | |||
642 | |||
643 | paint.setARGB(255,255,255,255); |
||
644 | // icon indicating QC is connected |
||
645 | // !!FIXME!! -10 by screensize |
||
129 | ligi | 646 | canvas.drawBitmap(icon_img,getWidth()-icon_img.getWidth(),-10 , paint); |
92 | ligi | 647 | if (root.mk.ready()) |
129 | ligi | 648 | canvas.drawBitmap(bt_on_img,getWidth()-icon_img.getWidth()-bt_on_img.getWidth()-5,5 , paint); |
92 | ligi | 649 | else |
129 | ligi | 650 | canvas.drawBitmap(bt_off_img,getWidth()-icon_img.getWidth()-bt_on_img.getWidth()-5,5 , paint); |
92 | ligi | 651 | |
652 | |||
653 | paint.setARGB(255,0,0,0); |
||
84 | ligi | 654 | invalidate(); |
655 | } |
||
656 | } |