Subversion Repositories FlightCtrl

Rev

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

Rev 325 Rev 390
Line 3... Line 3...
3
 * minimal canvas to test Abstraction layer on various Phones
3
 * minimal canvas to test Abstraction layer on various Phones
4
 *                                                          
4
 *                                                          
5
 * Author:        Marcus -LiGi- Bueschleb                    
5
 * Author:        Marcus -LiGi- Bueschleb                    
6
 * Project-Start: 9/2007                                    
6
 * Project-Start: 9/2007                                    
7
 * Mailto:        ligi@smart4mobile.de                      
7
 * Mailto:        ligi@smart4mobile.de                      
8
 * Licence:       Creative Commons / Non Commercial          
8
 * Licence:       Creative Commons / Non Commercial
-
 
9
 *                ( see README for exact terms of usage)
9
 * Big Up:        Holger&Ingo                                
10
 * Big Up:        Holger&Ingo                                
10
 ***************************************************************/
11
 ***************************************************************/
Line 11... Line 12...
11
 
12
 
12
import javax.microedition.lcdui.*;
13
import javax.microedition.lcdui.*;
Line 16... Line 17...
16
public class MKMiniCanvas
17
public class MKMiniCanvas
17
    extends Canvas
18
    extends Canvas
18
    implements Runnable
19
    implements Runnable
19
{
20
{
Line -... Line 21...
-
 
21
 
20
 
22
    // name/handle for the recordStore to memorize some stuff
Line 21... Line 23...
21
    private final static String RECORD_STORE_NAME="bluetoothurl";
23
    private final static String RECORD_STORE_NAME="bluetoothurl";
22
   
24
   
23
    private BTSearcher bt_scanner;
25
    private BTSearcher bt_scanner;
Line 52... Line 54...
52
 
54
 
53
    boolean quit=false;
55
    boolean quit=false;
54
    boolean rescan=true;
56
    boolean rescan=true;
Line -... Line 57...
-
 
57
    int bg_offset=0;
55
    int bg_offset=0;
58
 
56
 
-
 
57
    public int state=-1;
59
    // variable to hold the current state
58
   
-
 
59
 
60
    public int state=-1;
60
 
61
 
61
    // id  for each state - must just be uniq - order dont matter
62
    // id  for each state - must just be uniq - order isnt important
62
    public final static int STATEID_SCANNING         =0;
63
    public final static int STATEID_SCANNING         =0;
63
    public final static int STATEID_DEVICESELECT     =1;
64
    public final static int STATEID_DEVICESELECT     =1;
64
    public final static int STATEID_MAINMENU         =2;
65
    public final static int STATEID_MAINMENU         =2;
Line 106... Line 107...
106
    {
107
    {
107
        switch (getGameAction (keyCode))
108
        switch (getGameAction (keyCode))
108
            {
109
            {
109
            case UP:
110
            case UP:
110
                if (act_menu_select!=0) act_menu_select--;
111
                if (act_menu_select!=0) act_menu_select--;
-
 
112
                else
-
 
113
                    act_menu_select=menu_items.length-1;
111
                break;
114
                break;
Line 112... Line 115...
112
               
115
               
113
            case DOWN:
116
            case DOWN:
-
 
117
                if (act_menu_select<(menu_items.length-1)) act_menu_select++;
114
                if (act_menu_select<(menu_items.length-1)) act_menu_select++;
118
                else act_menu_select=0;
Line 115... Line 119...
115
                break;
119
                break;
Line 116... Line 120...
116
       
120
       
Line 249... Line 253...
249
 
253
 
250
                        mk.motor_test(motor_test);
254
                        mk.motor_test(motor_test);
Line 251... Line 255...
251
                        break;
255
                        break;
-
 
256
 
-
 
257
                    case STATEID_SCANNING:
-
 
258
                        intro_str_delay--;
-
 
259
                        if (intro_str_delay<0)
-
 
260
                            {
-
 
261
                                intro_str_delay=1;
-
 
262
                                if (intro_str_pos>intro_str.length())
-
 
263
                                    intro_str_pos=0;
-
 
264
                                lcd_lines[3]=intro_str.substring(intro_str_pos,  (((intro_str_pos+20)>intro_str.length())?intro_str.length():intro_str_pos+20));
-
 
265
                                intro_str_pos++;
252
 
266
                            }
253
                    case STATEID_SCANNING:
267
               
Line -... Line 268...
-
 
268
                        if (!bt_scanner.searching)
254
                        if (!bt_scanner.searching)
269
                                chg_state(STATEID_DEVICESELECT);
Line 255... Line 270...
255
                                chg_state(STATEID_DEVICESELECT);
270
 
Line 509... Line 524...
509
    }
524
    }
Line 510... Line 525...
510
 
525
 
Line -... Line 526...
-
 
526
    /*********************************************** input Section **********************************************/
-
 
527
 
-
 
528
 
-
 
529
    public final String intro_str="   Digital Ufo Broadcasting with intelligent service equipment by Marcus -LiGi- Bueschleb ; Big Up Holger / Ingo for the MikroKopter Project (http://www.mikrokopter.de) ";
Line 511... Line 530...
511
    /*********************************************** input Section **********************************************/
530
 
512
 
531
    int intro_str_pos=0;
513
 
532
    int intro_str_delay=3;
514
 
533
 
515
    public void chg_state(int next_state)
534
    public void chg_state(int next_state)
516
    {
535
    {
517
        act_menu_select=0;
536
        act_menu_select=0;
518
        // prepare next state
537
        // prepare next state
519
        switch(next_state)
538
        switch(next_state)
520
            {
539
            {
521
            case STATEID_SCANNING:
540
            case STATEID_SCANNING:
-
 
541
                lcd_lines=new String[4];
522
                lcd_lines=new String[3];
542
                lcd_lines[0]="Scanning for Devices";
Line 523... Line 543...
523
                lcd_lines[0]="Scanning for Devices";
543
                lcd_lines[1]="                    ";
524
                lcd_lines[1]="                    ";
544
                lcd_lines[2]="DUBwise v0.40       ";
Line 543... Line 563...
543
 
563
 
544
                lcd_lines=new String[5];
564
                lcd_lines=new String[5];
Line 545... Line 565...
545
                break;
565
                break;
546
 
566
 
547
            case STATEID_DEVICESELECT:
567
            case STATEID_DEVICESELECT:
548
                menu_items=new String[bt_scanner.remote_device_count];
568
                menu_items=new String[bt_scanner.remote_device_count+1];
-
 
569
                for (int i=0;i<bt_scanner.remote_device_count;i++)
549
                for (int i=0;i<bt_scanner.remote_device_count;i++)
570
                    menu_items[i]=bt_scanner.remote_device_name[i];
550
                    menu_items[i]=bt_scanner.remote_device_name[i];
571
                menu_items[bt_scanner.remote_device_count]="scan again";
Line 551... Line 572...
551
                lcd_lines=new String[bt_scanner.remote_device_count];
572
                lcd_lines=new String[bt_scanner.remote_device_count+1];
552
                break;
573
                break;
553
 
574
 
Line 675... Line 696...
675
                        chg_state(STATEID_EDIT_PARAMS);
696
                        chg_state(STATEID_EDIT_PARAMS);
676
                    }
697
                    }
677
                else menu_keypress(keyCode);
698
                else menu_keypress(keyCode);
678
                break;
699
                break;
679
            case STATEID_DEVICESELECT:
700
            case STATEID_DEVICESELECT:
-
 
701
                /*
680
                if ((keyCode >= this.KEY_NUM0) && (keyCode < this.KEY_NUM0+bt_scanner.remote_device_count))
702
                if ((keyCode >= this.KEY_NUM0) && (keyCode < this.KEY_NUM0+bt_scanner.remote_device_count))
681
                    {
703
                    {
682
                    connect_mk("btspp://"+bt_scanner.remote_device_mac[keyCode-this.KEY_NUM0] + ":1",bt_scanner.remote_device_name[keyCode-this.KEY_NUM0]);
704
                    connect_mk("btspp://"+bt_scanner.remote_device_mac[keyCode-this.KEY_NUM0] + ":1",bt_scanner.remote_device_name[keyCode-this.KEY_NUM0]);
683
                    chg_state(STATEID_MAINMENU);
705
                    chg_state(STATEID_MAINMENU);
684
                    }
706
                    }
685
                else
707
                else
-
 
708
                */
-
 
709
 
686
                if ( getGameAction (keyCode)==FIRE )
710
                if ( getGameAction (keyCode)==FIRE )
687
                    {              
711
                    {              
-
 
712
 
-
 
713
                        if (bt_scanner.remote_device_count > act_menu_select)
-
 
714
                            {
688
                        connect_mk("btspp://"+bt_scanner.remote_device_mac[act_menu_select] + ":1",bt_scanner.remote_device_name[act_menu_select]);
715
                                connect_mk("btspp://"+bt_scanner.remote_device_mac[act_menu_select] + ":1",bt_scanner.remote_device_name[act_menu_select]);
689
                        chg_state(STATEID_MAINMENU);
716
                                chg_state(STATEID_MAINMENU);
-
 
717
                            }
-
 
718
                        else
-
 
719
                            chg_state(STATEID_SCANNING);
690
                    }
720
                    }
691
                else menu_keypress(keyCode);
721
                else menu_keypress(keyCode);
-
 
722
               
692
                break;
723
                break;
Line 693... Line 724...
693
 
724
 
694
            case STATEID_EDIT_PARAMS:
725
            case STATEID_EDIT_PARAMS:
695
                params_editor.keypress(keyCode,getGameAction (keyCode)) ;
726
                params_editor.keypress(keyCode,getGameAction (keyCode)) ;