Subversion Repositories Projects

Rev

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