Rev 92 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 92 | Rev 129 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | 24 | ||
Line 25... | Line 25... | ||
25 | 25 | ||
- | 26 | import android.view.*; |
|
Line 26... | Line 27... | ||
26 | import android.view.*; |
27 | |
Line 27... | Line 28... | ||
27 | 28 | import android.graphics.Region.Op; |
|
28 | import android.graphics.Region.Op; |
29 | import android.graphics.Bitmap.*; |
Line 171... | Line 172... | ||
171 | { |
172 | { |
172 | // createa matrix for the manipulation |
173 | // createa matrix for the manipulation |
173 | Matrix matrix = new Matrix(); |
174 | Matrix matrix = new Matrix(); |
174 | float x_scale,y_scale; |
175 | float x_scale,y_scale; |
175 | if (y_scale_!=0f) |
176 | if (y_scale_!=0f) |
176 | y_scale= (getHeight()*y_scale_ )/orig.height(); |
177 | y_scale= (getHeight()*y_scale_ )/orig.getHeight(); |
177 | else // take x_scale |
178 | else // take x_scale |
178 | y_scale=(getWidth()*x_scale_ )/orig.width(); |
179 | y_scale=(getWidth()*x_scale_ )/orig.getWidth(); |
Line 179... | Line 180... | ||
179 | 180 | ||
180 | if (x_scale_!=0f) |
181 | if (x_scale_!=0f) |
181 | x_scale= (getWidth()*x_scale_ )/orig.width(); |
182 | x_scale= (getWidth()*x_scale_ )/orig.getWidth(); |
182 | else |
183 | else |
Line 183... | Line 184... | ||
183 | x_scale= (getHeight()*y_scale_ )/orig.height(); |
184 | x_scale= (getHeight()*y_scale_ )/orig.getHeight(); |
184 | 185 | ||
185 | matrix.postScale(x_scale , y_scale); |
186 | matrix.postScale(x_scale , y_scale); |
Line 186... | Line 187... | ||
186 | return Bitmap.createBitmap(orig, 0, 0,(int)( orig.width()),(int)( orig.height()), matrix, true); |
187 | return Bitmap.createBitmap(orig, 0, 0,(int)( orig.getWidth()),(int)( orig.getHeight()), matrix,true);//BitmapContfig.ARGB_8888 ); |
187 | } |
188 | } |
188 | - | ||
189 | - | ||
190 | public boolean onKeyDown(int keyCode, KeyEvent event) |
- | |
191 | { |
- | |
192 | /* try |
- | |
193 | { |
- | |
194 | MediaPlayer mp = MediaPlayer.create(root, R.raw.voice_sample_1); |
- | |
195 | mp.prepare(); |
- | |
196 | mp.start(); |
- | |
197 | } |
- | |
198 | catch ( Exception e) |
189 | |
199 | { |
- | |
Line 200... | Line 190... | ||
200 | |
190 | |
201 | } |
191 | public boolean onKeyDown(int keyCode, KeyEvent event) |
202 | |
192 | { |
203 | */ |
193 | |
Line 276... | Line 266... | ||
276 | case MAINMENU_STICKS: |
266 | case MAINMENU_STICKS: |
277 | chg_state(STATEID_STICKVIEW); |
267 | chg_state(STATEID_STICKVIEW); |
278 | break; |
268 | break; |
Line 279... | Line 269... | ||
279 | 269 | ||
280 | case MAINMENU_TELEMETRY: |
270 | case MAINMENU_TELEMETRY: |
- | 271 | chg_state(STATEID_FLIGHTVIEW); |
|
281 | chg_state(STATEID_FLIGHTVIEW); |
272 | // root.setContentView(new DUBwiseMapView(root)); |
Line 282... | Line 273... | ||
282 | break; |
273 | break; |
283 | 274 | ||
284 | case MAINMENU_RAWDEBUG: |
275 | case MAINMENU_RAWDEBUG: |
Line 308... | Line 299... | ||
308 | int flight_x,flight_y; |
299 | int flight_x,flight_y; |
Line 309... | Line 300... | ||
309 | 300 | ||
Line 310... | Line 301... | ||
310 | @Override public boolean onTouchEvent(MotionEvent event) { |
301 | @Override public boolean onTouchEvent(MotionEvent event) { |
311 | 302 | ||
312 | 303 | ||
313 | if ((event.getAction() ==MotionEvent.ACTION_UP)&&(event.getY()<bt_on_img.height())) |
304 | if ((event.getAction() ==MotionEvent.ACTION_UP)&&(event.getY()<bt_on_img.getHeight())) |
314 | { |
305 | { |
315 | if ( state==STATEID_MAINMENU) |
306 | if ( state==STATEID_MAINMENU) |
Line 340... | Line 331... | ||
340 | case STATEID_MAINMENU: |
331 | case STATEID_MAINMENU: |
341 | if ((event.getAction() ==MotionEvent.ACTION_DOWN)||(event.getAction() ==MotionEvent.ACTION_MOVE)) |
332 | if ((event.getAction() ==MotionEvent.ACTION_DOWN)||(event.getAction() ==MotionEvent.ACTION_MOVE)) |
342 | { |
333 | { |
343 | if (event.getY()>lcd_top) |
334 | if (event.getY()>lcd_top) |
344 | { |
335 | { |
345 | act_menu_select=(int)((event.getY()-lcd_top)/lcd_tiles_img.height()); |
336 | act_menu_select=(int)((event.getY()-lcd_top)/lcd_tiles_img.getHeight()); |
346 | calc_lcd(); |
337 | calc_lcd(); |
347 | } |
338 | } |
348 | } |
339 | } |
Line 349... | Line 340... | ||
349 | 340 | ||
Line 350... | Line 341... | ||
350 | if (event.getAction() ==MotionEvent.ACTION_UP) |
341 | if (event.getAction() ==MotionEvent.ACTION_UP) |
351 | 342 | ||
352 | { |
343 | { |
353 | if (event.getY()>lcd_top) |
344 | if (event.getY()>lcd_top) |
354 | { |
345 | { |
355 | act_menu_select=(int)((event.getY()-lcd_top)/lcd_tiles_img.height()); |
346 | act_menu_select=(int)((event.getY()-lcd_top)/lcd_tiles_img.getHeight()); |
356 | menu_reaction(); |
347 | menu_reaction(); |
357 | } |
348 | } |
Line 406... | Line 397... | ||
406 | 397 | ||
407 | 398 | ||
Line 408... | Line 399... | ||
408 | public void calc_lcd() |
399 | public void calc_lcd() |
409 | { |
400 | { |
410 | 401 | ||
411 | lcd_top=getHeight()-lcd_lines.length*lcd_tiles_img.height(); |
402 | lcd_top=getHeight()-lcd_lines.length*lcd_tiles_img.getHeight(); |
Line 412... | Line 403... | ||
412 | Paint paint = mPaint; |
403 | Paint paint = mPaint; |
413 | lcd_img= Bitmap.createBitmap(getWidth(),lcd_lines.length*lcd_tiles_img.height()+100,false); |
404 | lcd_img= Bitmap.createBitmap(getWidth(),lcd_lines.length*lcd_tiles_img.getHeight()+100,Bitmap.Config.ARGB_8888); |
414 | Canvas lcd_canvas=new Canvas(); |
405 | Canvas lcd_canvas=new Canvas(); |
415 | 406 | ||
416 | lcd_canvas.setDevice(lcd_img); |
407 | lcd_canvas.setBitmap(lcd_img); |
417 | lcd_canvas.drawColor(Color.WHITE); |
408 | lcd_canvas.drawColor(Color.WHITE); |
418 | int char_width=(int)(lcd_tiles_img.width()/LCD_CHAR_COUNT); |
409 | int char_width=(int)(lcd_tiles_img.getWidth()/LCD_CHAR_COUNT); |
Line 425... | Line 416... | ||
425 | act_char=lcd_lines[lcd_line].charAt(char_pos)-32; |
416 | act_char=lcd_lines[lcd_line].charAt(char_pos)-32; |
Line 426... | Line 417... | ||
426 | 417 | ||
427 | if ((menu_active)&&(act_menu_select==lcd_line)&& (char_pos==0)) |
418 | if ((menu_active)&&(act_menu_select==lcd_line)&& (char_pos==0)) |
Line 428... | Line 419... | ||
428 | act_char=30; |
419 | act_char=30; |
Line 429... | Line 420... | ||
429 | 420 | ||
Line 430... | Line 421... | ||
430 | lcd_canvas.clipRect(new RectF(char_pos*char_width,lcd_tiles_img.height()*lcd_line,(char_pos+1)*char_width,lcd_tiles_img.height()*(lcd_line+1)),Op.REPLACE ); |
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 ); |
431 | 422 | ||
Line 443... | Line 434... | ||
443 | //SystemClock.sleep(50); |
434 | //SystemClock.sleep(50); |
Line 444... | Line 435... | ||
444 | 435 | ||
445 | if (auto_next_state==-1) |
436 | if (auto_next_state==-1) |
446 | switch(state) |
437 | switch(state) |
447 | { |
- | |
448 | 438 | { |
|
- | 439 | case STATEID_FLIGHTVIEW: |
|
449 | case STATEID_FLIGHTVIEW: |
440 | root.mk.trigger_debug_data(); |
450 | lcd_lines=root.mk.LCD.get_act_page(); |
441 | lcd_lines=root.mk.LCD.get_act_page(); |
451 | calc_lcd(); |
442 | calc_lcd(); |
452 | if (state_intro_frame<200) |
443 | if (state_intro_frame<200) |
453 | state_intro_frame+=5; |
444 | state_intro_frame+=5; |
Line 500... | Line 491... | ||
500 | paint.setAntiAlias(true); |
491 | paint.setAntiAlias(true); |
Line 501... | Line 492... | ||
501 | 492 | ||
502 | paint.setARGB(255,0,0,0); |
493 | paint.setARGB(255,0,0,0); |
Line 503... | Line 494... | ||
503 | canvas.drawBitmap(bg_img,pos,0 , paint); |
494 | canvas.drawBitmap(bg_img,pos,0 , paint); |
504 | 495 | ||
Line 505... | Line 496... | ||
505 | if ((bg_img.width()+pos)<(getWidth())) |
496 | if ((bg_img.getWidth()+pos)<(getWidth())) |
506 | canvas.drawBitmap(bg_img,pos+bg_img.width(),0 , paint); |
497 | canvas.drawBitmap(bg_img,pos+bg_img.getWidth(),0 , paint); |
507 | 498 | ||
508 | 499 | ||
- | 500 | switch ( state ) |
|
509 | switch ( state ) |
501 | { |
510 | { |
502 | case STATEID_EDIT_PARAMS: |
511 | case STATEID_EDIT_PARAMS: |
503 | case STATEID_FLIGHTVIEW: |
Line 512... | Line 504... | ||
512 | case STATEID_FLIGHTVIEW: |
504 | |
Line 577... | Line 569... | ||
577 | 569 | ||
Line 578... | Line 570... | ||
578 | 570 | ||
- | 571 | break; |
|
- | 572 | ||
- | 573 | case STATEID_KEYCONTROL: |
|
- | 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 | ||
579 | break; |
586 | |
580 | 587 | canvas.restore(); |
|
Line 581... | Line 588... | ||
581 | case STATEID_KEYCONTROL: |
588 | |
582 | paint.setARGB(state_intro_frame,0,0,255); |
589 | paint.setARGB(state_intro_frame,0,0,255); |
Line 634... | Line 641... | ||
634 | 641 | ||
635 | 642 | ||
636 | paint.setARGB(255,255,255,255); |
643 | paint.setARGB(255,255,255,255); |
637 | // icon indicating QC is connected |
644 | // icon indicating QC is connected |
638 | // !!FIXME!! -10 by screensize |
645 | // !!FIXME!! -10 by screensize |
639 | canvas.drawBitmap(icon_img,getWidth()-icon_img.width(),-10 , paint); |
646 | canvas.drawBitmap(icon_img,getWidth()-icon_img.getWidth(),-10 , paint); |
640 | if (root.mk.ready()) |
647 | if (root.mk.ready()) |
641 | canvas.drawBitmap(bt_on_img,getWidth()-icon_img.width()-bt_on_img.width()-5,5 , paint); |
648 | canvas.drawBitmap(bt_on_img,getWidth()-icon_img.getWidth()-bt_on_img.getWidth()-5,5 , paint); |
Line 642... | Line 649... | ||
642 | else |
649 | else |
643 | canvas.drawBitmap(bt_off_img,getWidth()-icon_img.width()-bt_on_img.width()-5,5 , paint); |
650 | canvas.drawBitmap(bt_off_img,getWidth()-icon_img.getWidth()-bt_on_img.getWidth()-5,5 , paint); |
644 | 651 |