Subversion Repositories Projects

Rev

Rev 92 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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