Subversion Repositories Projects

Rev

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

Rev 62 Rev 70
Line 16... Line 16...
16
    extends Canvas
16
    extends Canvas
17
    implements Runnable
17
    implements Runnable
18
{
18
{
Line 19... Line 19...
19
 
19
 
20
    // name/handle for the recordStore to memorize some stuff
20
    // name/handle for the recordStore to memorize some stuff
Line 21... Line 21...
21
    private final static String RECORD_STORE_NAME="bluetoothurl";
21
    private final static String RECORD_STORE_NAME="DUBSETT";
22
   
22
   
23
    private BTSearcher bt_scanner;
23
    private BTSearcher bt_scanner;
24
    public MKCommunicator mk=null;
24
    public MKCommunicator mk=null;
Line 30... Line 30...
30
//#endif
30
//#endif
Line 31... Line 31...
31
 
31
 
32
    private String err="";
32
    private String err="";
Line -... Line 33...
-
 
33
    private DUBwise root;
Line -... Line 34...
-
 
34
 
-
 
35
    byte[] settings_arr;
-
 
36
 
-
 
37
    public boolean do_vibra=true;
Line 33... Line 38...
33
    private DUBwise root;
38
    public boolean do_sound=true;
34
 
39
    public boolean do_graph=true;
35
 
40
    public boolean keep_lighton=false;
36
 
41
 
Line 78... Line 83...
78
    public final static int STATEID_HANDLE_PARAMS    =6;
83
    public final static int STATEID_HANDLE_PARAMS    =6;
79
    public final static int STATEID_FLIGHTVIEW       =7;
84
    public final static int STATEID_FLIGHTVIEW       =7;
80
    public final static int STATEID_RAWDEBUG         =8;
85
    public final static int STATEID_RAWDEBUG         =8;
81
    //    public final static int STATEID_RAWDEBUG         =8;
86
    //    public final static int STATEID_RAWDEBUG         =8;
82
    public final static int STATEID_KEYCONTROL       =9;
87
    public final static int STATEID_KEYCONTROL       =9;
-
 
88
    public final static int STATEID_SETTINGSMENU     =10;
Line 83... Line 89...
83
 
89
 
84
 
90
 
85
    public boolean fullscreen=false;
91
    public boolean fullscreen=false;
86
    public int act_motor=0;
92
    public int act_motor=0;
Line 87... Line 93...
87
    public int act_motor_increase=0;
93
    public int act_motor_increase=0;
88
    public boolean motor_test_sel_all=false;
94
    public boolean motor_test_sel_all=false;
89
 
95
 
90
    public String[] main_menu_items={"Telemetry","Raw Debug", "MK-KeyControl", "Motor Test" , "Flight Settings","Change Skin","Proxy","Change Device" , "Quit " };
96
    public String[] main_menu_items={"Telemetry","Raw Debug", "MK-KeyControl", "Motor Test" , "Flight Settings","Tool Settings","Proxy","Change Device" , "Quit " };
91
    public final static int MAINMENU_TELEMETRY     =0;
97
    public final static int MAINMENU_TELEMETRY     =0;
92
    public final static int MAINMENU_RAWDEBUG      =1+MAINMENU_TELEMETRY;
98
    public final static int MAINMENU_RAWDEBUG      =1+MAINMENU_TELEMETRY;
93
    public final static int MAINMENU_KEYCONTROL    =1+MAINMENU_RAWDEBUG;
99
    public final static int MAINMENU_KEYCONTROL    =1+MAINMENU_RAWDEBUG;
94
    public final static int MAINMENU_MOTORTEST     =1+MAINMENU_KEYCONTROL;
100
    public final static int MAINMENU_MOTORTEST     =1+MAINMENU_KEYCONTROL;
95
    public final static int MAINMENU_PARAMS        =1+MAINMENU_MOTORTEST;
101
    public final static int MAINMENU_PARAMS        =1+MAINMENU_MOTORTEST;
96
    public final static int MAINMENU_SETTINGS      =1+MAINMENU_PARAMS;
102
    public final static int MAINMENU_SETTINGSMENU  =1+MAINMENU_PARAMS;
-
 
103
    public final static int MAINMENU_PROXY         =1+MAINMENU_SETTINGSMENU;
-
 
104
    public final static int MAINMENU_DEVICESELECT  =1+MAINMENU_PROXY;
-
 
105
    public final static int MAINMENU_QUIT          =1+MAINMENU_DEVICESELECT;
-
 
106
 
-
 
107
    public String[] settings_menu_items={"Skin ","Sound ","Vibra " ,"Graph ","FullScreen " ,"Keep BGLight " ,"Back" };
-
 
108
    public final static int SETTINGSMENU_CHANGESKIN   =0;
-
 
109
    public final static int SETTINGSMENU_SOUNDTOGGLE  =1;
-
 
110
    public final static int SETTINGSMENU_VIBRATOGGLE  =2;
-
 
111
    public final static int SETTINGSMENU_GRAPHTOGGLE  =3;
-
 
112
    public final static int SETTINGSMENU_FULLSCREENTOGGLE  =4;
-
 
113
    public final static int SETTINGSMENU_LIGHTTOGGLE  =5;
Line 97... Line 114...
97
    public final static int MAINMENU_PROXY         =1+MAINMENU_SETTINGS;
114
    public final static int SETTINGSMENU_BACK      =6;
Line 98... Line 115...
98
    public final static int MAINMENU_DEVICESELECT  =1+MAINMENU_PROXY;
115
 
99
    public final static int MAINMENU_QUIT          =1+MAINMENU_DEVICESELECT;
116
 
Line 213... Line 230...
213
 
230
 
214
        mk = new MKCommunicator(root);
231
        mk = new MKCommunicator(root);
Line 215... Line 232...
215
        mk_stat= new MKStatistics(mk);
232
        mk_stat= new MKStatistics(mk);
216
 
233
 
217
//#if voice_mode!="no_voice"
234
//#if voice_mode!="no_voice"
218
        status_voice=new MKStatusVoice(mk);
-
 
Line 219... Line 235...
219
//#endif
235
        status_voice=new MKStatusVoice(mk,this);
220
        load_images();
236
//#endif
221
   
237
   
Line 222... Line 238...
222
       
238
       
223
        try
239
        try
Line 224... Line 240...
224
            {
240
            {
225
                RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME , true );
241
                RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME , true );
Line 226... Line 242...
226
 
242
 
227
                if (recStore.getNumRecords()==2)
243
                if (recStore.getNumRecords()==3)
Line 228... Line 244...
228
                    {
244
                    {
229
 
245
 
-
 
246
                        //byte[] recData = new byte[recStore.getRecordSize(1)];
-
 
247
                        //int len = recStore.getRecord(1, recData, 0);
-
 
248
 
-
 
249
                        //byte[] recData2 = new byte[recStore.getRecordSize(2)];
-
 
250
                        //int len2 = recStore.getRecord(2, recData, 0);
-
 
251
                       
-
 
252
                        byte[] url_data=recStore.getRecord(1);
-
 
253
                        byte[] name_data=recStore.getRecord(2);
Line 230... Line 254...
230
                        //byte[] recData = new byte[recStore.getRecordSize(1)];
254
                        settings_arr=recStore.getRecord(3);
Line 231... Line 255...
231
                        //int len = recStore.getRecord(1, recData, 0);
255
                       
232
 
256
                        act_skin=settings_arr[0];
233
                        //byte[] recData2 = new byte[recStore.getRecordSize(2)];
257
                        do_sound=(settings_arr[1]==1);
234
                        //int len2 = recStore.getRecord(2, recData, 0);
258
                        do_vibra=(settings_arr[2]==1);
235
                       
259
                        do_graph=(settings_arr[3]==1);
-
 
260
                        fullscreen=(settings_arr[4]==1);
-
 
261
                        keep_lighton=(settings_arr[5]==1);
236
                        byte[] url_data=recStore.getRecord(1);
262
 
237
                        byte[] name_data=recStore.getRecord(2);
263
                        connect_mk(new String(url_data, 0, url_data.length),new String(name_data, 0, name_data.length));
Line -... Line 264...
-
 
264
 
-
 
265
                    }
-
 
266
                recStore.closeRecordStore();
238
 
267
            }
Line 239... Line 268...
239
                        connect_mk(new String(url_data, 0, url_data.length),new String(name_data, 0, name_data.length));
268
        catch (Exception e)
Line 240... Line 269...
240
 
269
            {
Line -... Line 270...
-
 
270
                settings_arr=new byte[10];
Line 241... Line 271...
241
                    }
271
 
242
                recStore.closeRecordStore();
272
                err+=e.toString();
243
            }
273
            }
244
        catch (Exception e)
274
 
Line 264... Line 294...
264
 
294
 
265
        while(true)
295
        while(true)
266
            {
296
            {
Line -... Line 297...
-
 
297
                try {
267
                try {
298
 
268
 
299
 
Line 269... Line 300...
269
                repaint();
300
                repaint();
270
                serviceRepaints();
301
                serviceRepaints();
Line 344... Line 375...
344
                            {
375
                            {
345
                                RecordStore.deleteRecordStore(RECORD_STORE_NAME);
376
                                RecordStore.deleteRecordStore(RECORD_STORE_NAME);
346
                                RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME, true );
377
                                RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME, true );
347
                                recStore.addRecord(mk.mk_url.getBytes(), 0, mk.mk_url.getBytes().length);
378
                                recStore.addRecord(mk.mk_url.getBytes(), 0, mk.mk_url.getBytes().length);
348
                                recStore.addRecord(mk.name.getBytes(), 0, mk.name.getBytes().length);
379
                                recStore.addRecord(mk.name.getBytes(), 0, mk.name.getBytes().length);
-
 
380
                                settings_arr=new byte[10];
-
 
381
                                settings_arr[0]=(byte)act_skin;
-
 
382
                                settings_arr[1]=(byte)(do_sound?1:0);
-
 
383
                                settings_arr[2]=(byte)(do_vibra?1:0);
-
 
384
                                settings_arr[3]=(byte)(do_graph?1:0);
-
 
385
                                settings_arr[4]=(byte)(fullscreen?1:0);
-
 
386
                                settings_arr[5]=(byte)(keep_lighton?1:0);
-
 
387
                                 
-
 
388
                                recStore.addRecord(settings_arr, 0, settings_arr.length);
-
 
389
                               
-
 
390
 
-
 
391
 
349
                                recStore.closeRecordStore();
392
                                recStore.closeRecordStore();
Line 350... Line 393...
350
 
393
 
351
                            }
394
                            }
352
                        catch (Exception e)
395
                        catch (Exception e)
Line 365... Line 408...
365
                try {
408
                try {
366
                    //rescan=false;
409
                    //rescan=false;
367
                    bg_offset--;
410
                    bg_offset--;
368
                    if (bg_offset==-bg_img.getWidth())
411
                    if (bg_offset==-bg_img.getWidth())
369
                        bg_offset=0;
412
                        bg_offset=0;
370
                    //com.nokia.mid.ui.DeviceControl.setLights(0,100);
413
                    if (keep_lighton) com.nokia.mid.ui.DeviceControl.setLights(0,100);
371
                    //bt.tick();
414
                    //bt.tick();
372
                    // every state has sth to do in tick section
415
                    // every state has sth to do in tick section
373
                }
416
                }
374
                catch (Exception e)
417
                catch (Exception e)
375
                    {
418
                    {
Line 403... Line 446...
403
            }
446
            }
404
    }
447
    }
Line -... Line 448...
-
 
448
 
Line 405... Line 449...
405
 
449
     
406
     
450
 
-
 
451
    boolean firstrun=true;
-
 
452
 
-
 
453
 
-
 
454
    // drawing section
-
 
455
    public void paint(Graphics g) {
407
 
456
        if (firstrun)
408
 
457
            {
Line 409... Line 458...
409
 
458
                if (fullscreen) setFullScreenMode(fullscreen);
410
    // drawing section
459
                firstrun=false;
Line 547... Line 596...
547
                    y_off+=spacer1;
596
                    y_off+=spacer1;
548
                    g.drawString( " other:"+mk.other_data_count+" params:"+mk.params_data_count,0,y_off,Graphics.TOP | Graphics.LEFT);
597
                    g.drawString( " other:"+mk.other_data_count+" params:"+mk.params_data_count,0,y_off,Graphics.TOP | Graphics.LEFT);
Line 549... Line -...
549
 
-
 
-
 
598
 
550
 
599
 
551
 
600
 
552
 
601
                case STATEID_SETTINGSMENU:
Line 553... Line 602...
553
                    // falltru wanted
602
                    // falltru wanted
Line 609... Line 658...
609
 
658
 
Line 610... Line 659...
610
 
659
 
Line 611... Line 660...
611
               
660
               
Line 612... Line 661...
612
                    // draw lines
661
                    // draw lines
613
 
662
 
Line 677... Line 726...
677
    int intro_str_pos=0;
726
    int intro_str_pos=0;
678
    int intro_str_delay=3;
727
    int intro_str_delay=3;
Line 679... Line 728...
679
 
728
 
680
    public void chg_state(int next_state)
729
    public void chg_state(int next_state)
681
    {
730
    {
682
        act_menu_select=0;
731
        if (next_state!=state)act_menu_select=0;
683
        // prepare next state
732
        // prepare next state
684
        switch(next_state)
733
        switch(next_state)
685
            {
734
            {
686
            case STATEID_KEYCONTROL:
735
            case STATEID_KEYCONTROL:
Line 721... Line 770...
721
                    menu_items[i]=bt_scanner.remote_device_name[i];
770
                    menu_items[i]=bt_scanner.remote_device_name[i];
722
                menu_items[bt_scanner.remote_device_count]="scan again";
771
                menu_items[bt_scanner.remote_device_count]="scan again";
723
                lcd_lines=new String[bt_scanner.remote_device_count+1];
772
                lcd_lines=new String[bt_scanner.remote_device_count+1];
724
                break;
773
                break;
Line -... Line 774...
-
 
774
 
725
 
775
 
726
            case STATEID_MAINMENU:
776
            case STATEID_MAINMENU:
727
                menu_items=main_menu_items;
777
                menu_items=main_menu_items;
728
                lcd_lines=new String[menu_items.length];
778
                lcd_lines=new String[menu_items.length];
Line -... Line 779...
-
 
779
                break;
-
 
780
 
-
 
781
            case STATEID_SETTINGSMENU:
-
 
782
               
-
 
783
                menu_items=new String[settings_menu_items.length];
-
 
784
                for(int cnt=0;cnt<settings_menu_items.length;cnt++)
-
 
785
                    menu_items[cnt]=settings_menu_items[cnt];
-
 
786
 
-
 
787
                menu_items[0]+=(act_skin==SKINID_DARK)?"Dark":"Light";
-
 
788
                menu_items[1]+=(!do_sound)?"Off":"On";
-
 
789
                menu_items[2]+=(!do_vibra)?"Off":"On";
-
 
790
                menu_items[3]+=(!do_graph)?"Off":"On";
-
 
791
                menu_items[4]+=(!fullscreen)?"Off":"On";
-
 
792
                menu_items[5]+=(!keep_lighton)?"Off":"On";
-
 
793
 
-
 
794
                lcd_lines=new String[menu_items.length];
729
                break;
795
                break;
Line 730... Line 796...
730
 
796
 
731
            }
797
            }
732
               
798
               
Line 927... Line 993...
927
                            chg_state(STATEID_MAINMENU);
993
                            chg_state(STATEID_MAINMENU);
928
                        }
994
                        }
929
                else
995
                else
930
                    menu_keypress(keyCode);
996
                    menu_keypress(keyCode);
931
                break;
997
                break;
-
 
998
 
932
            case STATEID_MAINMENU:
999
            case STATEID_SETTINGSMENU:
933
                if ( getGameAction (keyCode)==FIRE )
1000
                if ( getGameAction (keyCode)==FIRE )
934
                    switch(act_menu_select)
1001
                    switch(act_menu_select)
935
                        {
1002
                        {
936
                        case MAINMENU_SETTINGS:
1003
                        case SETTINGSMENU_CHANGESKIN:
937
                            act_skin++;
1004
                            act_skin++;
938
                            act_skin=(byte)(act_skin%2);
1005
                            act_skin=(byte)(act_skin%2);
939
                            load_images();
1006
                            load_images();
-
 
1007
                            chg_state(STATEID_SETTINGSMENU);
-
 
1008
                            break;
-
 
1009
                        case SETTINGSMENU_SOUNDTOGGLE:
-
 
1010
                            do_sound=!do_sound;
-
 
1011
                            chg_state(STATEID_SETTINGSMENU);
-
 
1012
                            break;
-
 
1013
                        case SETTINGSMENU_VIBRATOGGLE:
-
 
1014
                            do_vibra=!do_vibra;
-
 
1015
                            chg_state(STATEID_SETTINGSMENU);
-
 
1016
                            break;
-
 
1017
 
-
 
1018
                        case SETTINGSMENU_GRAPHTOGGLE:
-
 
1019
                            do_graph=!do_graph;
-
 
1020
                            chg_state(STATEID_SETTINGSMENU);
-
 
1021
                            break;
-
 
1022
 
-
 
1023
 
-
 
1024
                        case SETTINGSMENU_FULLSCREENTOGGLE:
-
 
1025
                            fullscreen=!fullscreen;
-
 
1026
                            setFullScreenMode(fullscreen);
-
 
1027
                            chg_state(STATEID_SETTINGSMENU);
-
 
1028
                            break;
-
 
1029
 
-
 
1030
                        case SETTINGSMENU_LIGHTTOGGLE:
-
 
1031
                            keep_lighton =!keep_lighton;
-
 
1032
                            chg_state(STATEID_SETTINGSMENU);
-
 
1033
                            break;
-
 
1034
 
-
 
1035
                        case SETTINGSMENU_BACK:
-
 
1036
                            chg_state(STATEID_MAINMENU);
-
 
1037
                            chg_state(STATEID_SETTINGSMENU);
-
 
1038
                            break;
-
 
1039
                           
-
 
1040
                        }
-
 
1041
                else menu_keypress(keyCode);
-
 
1042
                break;
-
 
1043
 
-
 
1044
            case STATEID_MAINMENU:
-
 
1045
                if ( getGameAction (keyCode)==FIRE )
-
 
1046
                    switch(act_menu_select)
-
 
1047
                        {
-
 
1048
                        case MAINMENU_SETTINGSMENU:
-
 
1049
                         
-
 
1050
                            chg_state(STATEID_SETTINGSMENU);
940
                            break;
1051
                            break;
Line 941... Line 1052...
941
 
1052
 
942
                        case MAINMENU_KEYCONTROL:
1053
                        case MAINMENU_KEYCONTROL:
943
                            chg_state(STATEID_KEYCONTROL);
1054
                            chg_state(STATEID_KEYCONTROL);