Subversion Repositories Projects

Rev

Rev 84 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 84 Rev 92
Line 14... Line 14...
14
import android.content.Context;
14
import android.content.Context;
15
import android.graphics.*;
15
import android.graphics.*;
16
import android.os.Bundle;
16
import android.os.Bundle;
17
import android.os.*;
17
import android.os.*;
18
import android.view.View;
18
import android.view.View;
19
 
-
 
-
 
19
import android.util.Log;
-
 
20
import android.media.*;
20
import java.util.Random;
21
import java.util.Random;
-
 
22
import java.net.*;
-
 
23
import java.io.*;
-
 
24
 
Line 21... Line 25...
21
 
25
 
22
import android.view.Window;
-
 
23
import android.view.WindowManager;
-
 
Line 24... Line 26...
24
import android.view.KeyEvent;
26
import android.view.*;
Line 25... Line 27...
25
 
27
 
Line 26... Line 28...
26
import android.graphics.Region.Op;
28
import android.graphics.Region.Op;
27
 
29
 
28
import org.bluez.*;
30
// not working atm - import org.bluez.*;
Line 29... Line 31...
29
 
31
 
-
 
32
public class DUBwiseView
-
 
33
    extends View
-
 
34
    implements DUBwiseDefinitions
-
 
35
               
-
 
36
 
-
 
37
{
-
 
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;
30
public class DUBwiseView
49
 
Line -... Line 50...
-
 
50
    public final int SKINID_DARK=0;
31
    extends View
51
    public final int SKINID_LIGHT=0;
32
    implements DUBwiseDefinitions
-
 
33
               
-
 
Line -... Line 52...
-
 
52
    int act_skin=0;
-
 
53
    boolean keep_lighton=true;
-
 
54
 
34
 
55
    private Paint   mPaint = new Paint();
35
{
56
 
Line 36... Line 57...
36
    private Paint   mPaint = new Paint();
57
    // chars in bitmap
37
 
58
    public static int LCD_CHAR_COUNT=222;
-
 
59
 
38
    public static int LCD_CHAR_COUNT=222;
60
    // some images we need
39
    // some images we need
61
    private Bitmap  icon_img,bg_img,lcd_tiles_img,bt_on_img,bt_off_img;
Line -... Line 62...
-
 
62
    private Bitmap lcd_img=null;
-
 
63
    // pos for scrolling
-
 
64
    private int pos=0;
40
    private Bitmap  bg_img,lcd_tiles,lcd_img;
65
 
41
 
66
    String str1="";
Line 42... Line -...
42
    // pos for scrolling
-
 
-
 
67
    String[] lcd_lines;
-
 
68
    String[] menu_items;
43
    private int pos=0;
69
    long last_run=0;
44
 
70
    int last_key=0;
45
    String str1="";
71
 
-
 
72
 
Line 46... Line 73...
46
    String[] lcd_lines;
73
    int auto_next_state=-1;
47
    long last_run=0;
74
 
48
    int last_key=0;
75
    int wi,he;
49
 
76
    //     Activity context;
50
    int wi,he;
-
 
51
    //     Activity context;
77
 
52
 
78
    DUBwise root;
53
       
79
    MKParamEditor param_editor;
54
    Activity root;
80
    //    Activity root;
-
 
81
    int lcd_top;
-
 
82
    int act_menu_select=0;
-
 
83
    int[] motortest_vals={0,0,0,0};
-
 
84
 
-
 
85
    public DUBwiseView(DUBwise context) {
-
 
86
        super(context);
-
 
87
        root=context;
-
 
88
        param_editor=new MKParamEditor(root);
-
 
89
        chg_state_(STATEID_MAINMENU);
-
 
90
 
-
 
91
        // needed to get Key Events
-
 
92
        setFocusable(true);
-
 
93
 
-
 
94
 
-
 
95
    }
-
 
96
 
-
 
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";
55
    int lcd_top;
155
                menu_items[3]+=(!do_graph)?"Off":"On";
Line 56... Line 156...
56
    int menu_y=0;
156
                menu_items[4]+=(!root.fullscreen)?"Off":"On";
57
 
157
                menu_items[5]+=(!keep_lighton)?"Off":"On";
Line 87... Line 187...
87
    }
187
    }
Line 88... Line 188...
88
 
188
 
89
 
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();
90
    public boolean onKeyDown(int keyCode, KeyEvent event)
196
                mp.start();
91
    {
197
            }
-
 
198
        catch ( Exception e)
-
 
199
            {
-
 
200
               
-
 
201
            }
-
 
202
           
92
        switch ( keyCode)
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:
93
            {
215
                param_editor.keypress(keyCode,keyCode);
94
            case KeyEvent.KEYCODE_DPAD_DOWN :
216
                lcd_lines=param_editor.public_lcd_lines;
-
 
217
                calc_lcd();
-
 
218
                break;
-
 
219
            case STATEID_MAINMENU:
-
 
220
                switch ( keyCode)
-
 
221
                    {
-
 
222
                    case KeyEvent.KEYCODE_DPAD_DOWN :
Line 95... Line 223...
95
                menu_y++;
223
                        act_menu_select++;
96
                break;
224
                        break;
-
 
225
       
-
 
226
                    case KeyEvent.KEYCODE_DPAD_UP :
-
 
227
                        act_menu_select--;
-
 
228
                        break;
-
 
229
 
-
 
230
                    case KeyEvent.KEYCODE_DPAD_CENTER :
-
 
231
                        menu_reaction();
97
       
232
                        break;
-
 
233
                       
-
 
234
                    }
-
 
235
                break;
-
 
236
               
-
 
237
            case STATEID_FLIGHTVIEW:
-
 
238
               
-
 
239
                switch ( keyCode)
-
 
240
                    {
-
 
241
 
Line -... Line 242...
-
 
242
                    case KeyEvent.KEYCODE_DPAD_DOWN :
-
 
243
                        root.mk.LCD.LCD_NEXTPAGE();
98
            case KeyEvent.KEYCODE_DPAD_UP :
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
 
99
                menu_y--;
252
                        break;
100
                break;
253
 
101
 
254
                       
Line 102... Line 255...
102
            case KeyEvent.KEYCODE_DPAD_CENTER :
255
                    }
-
 
256
                calc_lcd();
103
                root.finish();
257
                break;
104
                break;
258
            }
105
            }
259
 
106
 
260
        //      last_key=keyCode;
Line -... Line 261...
-
 
261
        //      if(lcd_img!=null)
-
 
262
        calc_lcd();
-
 
263
        invalidate();
-
 
264
        return true;
-
 
265
    }
-
 
266
 
-
 
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
 
107
        last_key=keyCode;
388
           
108
        calc_lcd();
389
        }
109
        invalidate();
390
 
110
        return true;
391
 
111
    }
392
 
-
 
393
 
-
 
394
    @Override protected void onSizeChanged(int w, int h, int oldw, int oldh)
-
 
395
    {
-
 
396
 
112
 
397
        bg_img = resize_to_screen(BitmapFactory.decodeResource(getResources(), R.drawable.starfield),0f,1f);
-
 
398
        lcd_tiles_img = resize_to_screen(BitmapFactory.decodeResource(getResources(), R.drawable.lcd_green),0.05f*LCD_CHAR_COUNT,0f);
113
    @Override protected void onSizeChanged(int w, int h, int oldw, int oldh)
399
        icon_img = resize_to_screen(BitmapFactory.decodeResource(getResources(), R.drawable.icon),0.15f,0f);
Line -... Line 400...
-
 
400
 
114
    {
401
        bt_off_img = resize_to_screen(BitmapFactory.decodeResource(getResources(), R.drawable.bt_off),0.06f,0f);
115
       
402
        bt_on_img = resize_to_screen(BitmapFactory.decodeResource(getResources(), R.drawable.bt_on),0.06f,0f);
-
 
403
        calc_lcd();    
116
        bg_img = resize_to_screen(BitmapFactory.decodeResource(getResources(), R.drawable.starfield),0f,1f);
404
 
117
        lcd_tiles = resize_to_screen(BitmapFactory.decodeResource(getResources(), R.drawable.lcd_green),0.05f*LCD_CHAR_COUNT,0f);
405
    }
118
        calc_lcd();
406
 
119
    }
407
 
Line 120... Line 408...
120
 
408
    public void calc_lcd()
121
    public void calc_lcd()
409
    {
122
    {
410
 
123
        lcd_top=getHeight()-lcd_lines.length*lcd_tiles.height();
411
        lcd_top=getHeight()-lcd_lines.length*lcd_tiles_img.height();
124
        Paint paint = mPaint;
412
        Paint paint = mPaint;
125
        lcd_img= Bitmap.createBitmap(getWidth(),lcd_lines.length*lcd_tiles.height()+100,false);
413
        lcd_img= Bitmap.createBitmap(getWidth(),lcd_lines.length*lcd_tiles_img.height()+100,false);
126
        Canvas lcd_canvas=new Canvas();
414
        Canvas lcd_canvas=new Canvas();
Line 127... Line 415...
127
 
415
 
128
        lcd_canvas.setDevice(lcd_img);
416
        lcd_canvas.setDevice(lcd_img);
Line 129... Line 417...
129
        lcd_canvas.drawColor(Color.WHITE);
417
        lcd_canvas.drawColor(Color.WHITE);
130
        int char_width=(int)(lcd_tiles.width()/LCD_CHAR_COUNT);
418
        int char_width=(int)(lcd_tiles_img.width()/LCD_CHAR_COUNT);
Line 131... Line 419...
131
        for ( int lcd_line=0 ; lcd_line < lcd_lines.length ; lcd_line++)
419
        for ( int lcd_line=0 ; lcd_line < lcd_lines.length ; lcd_line++)
Line 132... Line 420...
132
            for (int char_pos=0;char_pos<20;char_pos++)
420
            for (int char_pos=0;char_pos<20;char_pos++)
Line 133... Line 421...
133
                {
421
                {
134
                    int act_char=0;
422
                    int act_char=0;
Line -... Line 423...
-
 
423
                   
135
                   
424
                    if (char_pos<lcd_lines[lcd_line].length())
136
                    if (char_pos<lcd_lines[lcd_line].length())
425
                        act_char=lcd_lines[lcd_line].charAt(char_pos)-32;
137
                        act_char=lcd_lines[lcd_line].charAt(char_pos)-32;
426
                   
138
                   
427
                    if ((menu_active)&&(act_menu_select==lcd_line)&& (char_pos==0))
139
                    if ((menu_y==lcd_line)&& (char_pos==0))
428
                        act_char=30;
-
 
429
                   
-
 
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 );
-
 
431
                             
-
 
432
                    lcd_canvas.drawBitmap(lcd_tiles_img,(char_pos-act_char)*(char_width),lcd_tiles_img.height()*(lcd_line) , paint);
-
 
433
                                                                     
-
 
434
 
-
 
435
                }
-
 
436
    }
-
 
437
     
-
 
438
    // fixme -> put in own timed thread - not in draw invalidate loop
-
 
439
    public void tick()
-
 
440
    {
-
 
441
        pos--;
-
 
442
        pos%=bg_img.getWidth();
-
 
443
        //SystemClock.sleep(50);
-
 
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
                   
140
                        act_char=30;
475
                }
Line 141... Line 476...
141
                   
476
        else
-
 
477
            {
-
 
478
                if (state_intro_frame>10)
-
 
479
                    state_intro_frame-=7;
142
                    lcd_canvas.clipRect(new RectF(char_pos*char_width,lcd_tiles.height()*lcd_line,(char_pos+1)*char_width,lcd_tiles.height()*(lcd_line+1)),Op.REPLACE );
480
                else
Line 143... Line 481...
143
                             
481
                   {
144
                    lcd_canvas.drawBitmap(lcd_tiles,(char_pos-act_char)*(char_width),lcd_tiles.height()*(lcd_line) , paint);
482
                       state_intro_frame=0;
Line 145... Line -...
145
                                                                     
-
 
-
 
483
                       chg_state_(auto_next_state);
146
 
484
                   }
Line 147... Line 485...
147
                }
485
               
148
    }
486
               
Line -... Line 487...
-
 
487
 
-
 
488
            }
-
 
489
           
-
 
490
    }
-
 
491
 
-
 
492
 
149
     
493
    @Override protected void onDraw(Canvas canvas) {
-
 
494
 
-
 
495
 
-
 
496
           
-
 
497
        tick();
-
 
498
 
-
 
499
        Paint paint = mPaint;
-
 
500
        paint.setAntiAlias(true);
-
 
501
 
-
 
502
        paint.setARGB(255,0,0,0);      
-
 
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
 
-
 
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);
Line -... Line 541...
-
 
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
 
-
 
562
               
-
 
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);
-
 
565
 
-
 
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);
150
    public void tick()
591
               
151
    {
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);
Line -... Line 623...
-
 
623
                        y_pos+=spacer;
152
        pos--;
624
                        canvas.drawText(" other:"+root.mk.other_data_count+" params:"+root.mk.params_data_count,0,y_pos,paint);
153
        pos%=bg_img.getWidth();
625
                    }
154
        //SystemClock.sleep(50);
626
                else