26,6 → 26,7 |
import android.view.*; |
|
import android.graphics.Region.Op; |
import android.graphics.Bitmap.*; |
|
// not working atm - import org.bluez.*; |
|
173,35 → 174,24 |
Matrix matrix = new Matrix(); |
float x_scale,y_scale; |
if (y_scale_!=0f) |
y_scale= (getHeight()*y_scale_ )/orig.height(); |
y_scale= (getHeight()*y_scale_ )/orig.getHeight(); |
else // take x_scale |
y_scale=(getWidth()*x_scale_ )/orig.width(); |
y_scale=(getWidth()*x_scale_ )/orig.getWidth(); |
|
if (x_scale_!=0f) |
x_scale= (getWidth()*x_scale_ )/orig.width(); |
x_scale= (getWidth()*x_scale_ )/orig.getWidth(); |
else |
x_scale= (getHeight()*y_scale_ )/orig.height(); |
x_scale= (getHeight()*y_scale_ )/orig.getHeight(); |
|
matrix.postScale(x_scale , y_scale); |
return Bitmap.createBitmap(orig, 0, 0,(int)( orig.width()),(int)( orig.height()), matrix, true); |
return Bitmap.createBitmap(orig, 0, 0,(int)( orig.getWidth()),(int)( orig.getHeight()), matrix,true);//BitmapContfig.ARGB_8888 ); |
} |
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) |
{ |
/* try |
{ |
MediaPlayer mp = MediaPlayer.create(root, R.raw.voice_sample_1); |
mp.prepare(); |
mp.start(); |
} |
catch ( Exception e) |
{ |
|
} |
|
*/ |
|
if ( keyCode==KeyEvent.KEYCODE_BACK) |
{ |
if ( state==STATEID_MAINMENU) |
279,6 → 269,7 |
|
case MAINMENU_TELEMETRY: |
chg_state(STATEID_FLIGHTVIEW); |
// root.setContentView(new DUBwiseMapView(root)); |
break; |
|
case MAINMENU_RAWDEBUG: |
310,7 → 301,7 |
@Override public boolean onTouchEvent(MotionEvent event) { |
|
|
if ((event.getAction() ==MotionEvent.ACTION_UP)&&(event.getY()<bt_on_img.height())) |
if ((event.getAction() ==MotionEvent.ACTION_UP)&&(event.getY()<bt_on_img.getHeight())) |
{ |
if ( state==STATEID_MAINMENU) |
root.finish(); |
342,7 → 333,7 |
{ |
if (event.getY()>lcd_top) |
{ |
act_menu_select=(int)((event.getY()-lcd_top)/lcd_tiles_img.height()); |
act_menu_select=(int)((event.getY()-lcd_top)/lcd_tiles_img.getHeight()); |
calc_lcd(); |
} |
} |
352,7 → 343,7 |
{ |
if (event.getY()>lcd_top) |
{ |
act_menu_select=(int)((event.getY()-lcd_top)/lcd_tiles_img.height()); |
act_menu_select=(int)((event.getY()-lcd_top)/lcd_tiles_img.getHeight()); |
menu_reaction(); |
} |
} |
408,14 → 399,14 |
public void calc_lcd() |
{ |
|
lcd_top=getHeight()-lcd_lines.length*lcd_tiles_img.height(); |
lcd_top=getHeight()-lcd_lines.length*lcd_tiles_img.getHeight(); |
Paint paint = mPaint; |
lcd_img= Bitmap.createBitmap(getWidth(),lcd_lines.length*lcd_tiles_img.height()+100,false); |
lcd_img= Bitmap.createBitmap(getWidth(),lcd_lines.length*lcd_tiles_img.getHeight()+100,Bitmap.Config.ARGB_8888); |
Canvas lcd_canvas=new Canvas(); |
|
lcd_canvas.setDevice(lcd_img); |
lcd_canvas.setBitmap(lcd_img); |
lcd_canvas.drawColor(Color.WHITE); |
int char_width=(int)(lcd_tiles_img.width()/LCD_CHAR_COUNT); |
int char_width=(int)(lcd_tiles_img.getWidth()/LCD_CHAR_COUNT); |
for ( int lcd_line=0 ; lcd_line < lcd_lines.length ; lcd_line++) |
for (int char_pos=0;char_pos<20;char_pos++) |
{ |
427,9 → 418,9 |
if ((menu_active)&&(act_menu_select==lcd_line)&& (char_pos==0)) |
act_char=30; |
|
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 ); |
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 ); |
|
lcd_canvas.drawBitmap(lcd_tiles_img,(char_pos-act_char)*(char_width),lcd_tiles_img.height()*(lcd_line) , paint); |
lcd_canvas.drawBitmap(lcd_tiles_img,(char_pos-act_char)*(char_width),lcd_tiles_img.getHeight()*(lcd_line) , paint); |
|
|
} |
445,8 → 436,8 |
if (auto_next_state==-1) |
switch(state) |
{ |
|
case STATEID_FLIGHTVIEW: |
root.mk.trigger_debug_data(); |
lcd_lines=root.mk.LCD.get_act_page(); |
calc_lcd(); |
if (state_intro_frame<200) |
502,8 → 493,8 |
paint.setARGB(255,0,0,0); |
canvas.drawBitmap(bg_img,pos,0 , paint); |
|
if ((bg_img.width()+pos)<(getWidth())) |
canvas.drawBitmap(bg_img,pos+bg_img.width(),0 , paint); |
if ((bg_img.getWidth()+pos)<(getWidth())) |
canvas.drawBitmap(bg_img,pos+bg_img.getWidth(),0 , paint); |
|
|
switch ( state ) |
510,6 → 501,7 |
{ |
case STATEID_EDIT_PARAMS: |
case STATEID_FLIGHTVIEW: |
|
paint.setARGB(state_intro_frame ,0,0,0); |
canvas.drawBitmap(lcd_img,0,lcd_top , paint); |
break; |
579,6 → 571,21 |
break; |
|
case STATEID_KEYCONTROL: |
canvas.rotate((root.mk.debug_data.analog[18]*(-90))/3000,getWidth()/2,getHeight()/2); |
paint.setARGB(state_intro_frame,177,129,0); |
// roll rect |
canvas.drawRect(-getWidth(),getHeight()/2,2*getWidth(),3*getHeight()/2,paint); |
|
int bar_height=20; |
// nick rect |
paint.setARGB(state_intro_frame,0,200,0); |
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); |
|
|
|
|
canvas.restore(); |
|
paint.setARGB(state_intro_frame,0,0,255); |
// canvas.drawRoundRect(new RectF(getWidth()/2-getWidth()/8,getHeight()/2-getWidth()/8,getWidth()/2+getWidth()/8,getHeight()/2+getWidth()/8),5,5,paint); |
|
636,11 → 643,11 |
paint.setARGB(255,255,255,255); |
// icon indicating QC is connected |
// !!FIXME!! -10 by screensize |
canvas.drawBitmap(icon_img,getWidth()-icon_img.width(),-10 , paint); |
canvas.drawBitmap(icon_img,getWidth()-icon_img.getWidth(),-10 , paint); |
if (root.mk.ready()) |
canvas.drawBitmap(bt_on_img,getWidth()-icon_img.width()-bt_on_img.width()-5,5 , paint); |
canvas.drawBitmap(bt_on_img,getWidth()-icon_img.getWidth()-bt_on_img.getWidth()-5,5 , paint); |
else |
canvas.drawBitmap(bt_off_img,getWidth()-icon_img.width()-bt_on_img.width()-5,5 , paint); |
canvas.drawBitmap(bt_off_img,getWidth()-icon_img.getWidth()-bt_on_img.getWidth()-5,5 , paint); |
|
|
paint.setARGB(255,0,0,0); |