Rev 483 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 483 | Rev 485 | ||
---|---|---|---|
Line 159... | Line 159... | ||
159 | try |
159 | try |
160 | { |
160 | { |
161 | // load all needed images |
161 | // load all needed images |
162 | lcd_img=Image.createImage("/lcd.png"); |
162 | lcd_img=Image.createImage("/lcd.png"); |
163 | bt_img=Image.createImage("/bt.png"); |
163 | bt_img=Image.createImage("/bt.png"); |
164 | bg_img=Image.createImage("/bg.jpg"); |
164 | bg_img=Image.createImage("/starfield.jpg"); |
165 | load_img=Image.createImage("/load.png"); |
165 | load_img=Image.createImage("/load.png"); |
166 | } |
166 | } |
167 | catch (Exception e) |
167 | catch (Exception e) |
168 | { |
168 | { |
169 | err+=e.toString(); |
169 | err+=e.toString(); |
Line 417... | Line 417... | ||
417 | if (bg_offset+bg_img.getWidth()<this.getWidth()) |
417 | if (bg_offset+bg_img.getWidth()<this.getWidth()) |
418 | g.drawImage(bg_img,bg_offset+bg_img.getWidth(),0, g.TOP | g.LEFT); |
418 | g.drawImage(bg_img,bg_offset+bg_img.getWidth(),0, g.TOP | g.LEFT); |
419 | } |
419 | } |
Line 420... | Line 420... | ||
420 | 420 | ||
421 | g.setColor(0x000000); |
- | |
- | 421 | g.setColor(0x000000); |
|
422 | 422 | g.setColor(0x2dcf20); |
|
423 | switch(state) |
423 | switch(state) |
424 | { |
424 | { |
- | 425 | case STATEID_KEYCONTROL: |
|
- | 426 | ||
- | 427 | ||
- | 428 | y_off+=spacer; |
|
- | 429 | g.drawString("UP&DOWN => nick",0,y_off,Graphics.TOP | Graphics.LEFT); |
|
- | 430 | y_off+=spacer; |
|
- | 431 | g.drawString("LEFT&RIGHT => roll",0,y_off,Graphics.TOP | Graphics.LEFT); |
|
- | 432 | y_off+=spacer; |
|
- | 433 | g.drawString("1&4 => altitude",0,y_off,Graphics.TOP | Graphics.LEFT); |
|
- | 434 | ||
- | 435 | y_off+=spacer; |
|
- | 436 | g.drawString("2&3 => gier",0,y_off,Graphics.TOP | Graphics.LEFT); |
|
- | 437 | ||
- | 438 | y_off+=spacer; |
|
- | 439 | g.drawString("Press # and * at once",0,y_off,Graphics.TOP | Graphics.LEFT); |
|
- | 440 | y_off+=spacer; |
|
- | 441 | g.drawString("to quit KeyControl",0,y_off,Graphics.TOP | Graphics.LEFT); |
|
425 | case STATEID_KEYCONTROL: |
442 | y_off+=spacer; |
426 | g.drawString("bf1:"+ keycontrol_bitfield[0] ,0,10,Graphics.TOP | Graphics.LEFT); |
443 | g.drawString("bf1:"+ keycontrol_bitfield[0] ,0,y_off,Graphics.TOP | Graphics.LEFT); |
- | 444 | g.drawString("bf2:"+ keycontrol_bitfield[1] ,this.getWidth()/2,y_off,Graphics.TOP | Graphics.LEFT); |
|
427 | g.drawString("bf2:"+ keycontrol_bitfield[1] ,0,30,Graphics.TOP | Graphics.LEFT); |
445 | |
Line 428... | Line 446... | ||
428 | break; |
446 | break; |
429 | 447 | ||
Line 444... | Line 462... | ||
444 | break; |
462 | break; |
Line 445... | Line 463... | ||
445 | 463 | ||
446 | case STATEID_SCANNING: |
464 | case STATEID_SCANNING: |
Line 447... | Line 465... | ||
447 | paint_lcd(g,true); |
465 | paint_lcd(g,true); |
448 | 466 | ||
449 | g.setClip(this.getWidth()/2-load_img.getWidth()/6,this.getHeight()/2-load_img.getHeight()/8, load_img.getWidth()/4,load_img.getHeight()/3);; |
467 | g.setClip(this.getWidth()/2-load_img.getWidth()/6+1,this.getHeight()/2-load_img.getHeight()/8+1, load_img.getWidth()/4,load_img.getHeight()/3);; |
450 | g.drawImage(load_img,this.getWidth()/2-load_img.getWidth()/8 - ((((frame_pos/3)%12)%4)*(load_img.getWidth()/4)) ,this.getHeight()/2-load_img.getHeight()/6- ((((frame_pos/3)%12)/4)*(load_img.getHeight()/3)), g.TOP | g.LEFT); |
468 | g.drawImage(load_img,this.getWidth()/2-load_img.getWidth()/8 - ((((frame_pos/3)%12)%4)*(load_img.getWidth()/4)) ,this.getHeight()/2-load_img.getHeight()/6- ((((frame_pos/3)%12)/4)*(load_img.getHeight()/3)), g.TOP | g.LEFT); |
Line 451... | Line 469... | ||
451 | g.drawImage(bt_img,this.getWidth()/2 ,this.getHeight()/2 , g.HCENTER | g.VCENTER); |
469 | g.drawImage(bt_img,this.getWidth()/2 ,this.getHeight()/2 , g.HCENTER | g.VCENTER); |
Line 604... | Line 622... | ||
604 | { |
622 | { |
605 | act_menu_select=0; |
623 | act_menu_select=0; |
606 | // prepare next state |
624 | // prepare next state |
607 | switch(next_state) |
625 | switch(next_state) |
608 | { |
626 | { |
- | 627 | case STATEID_KEYCONTROL: |
|
- | 628 | keycontrol_exit=0; |
|
- | 629 | break; |
|
- | 630 | ||
609 | case STATEID_SCANNING: |
631 | case STATEID_SCANNING: |
610 | lcd_lines=new String[4]; |
632 | lcd_lines=new String[4]; |
611 | lcd_lines[0]="Scanning for Devices"; |
633 | lcd_lines[0]="Scanning for Devices"; |
612 | lcd_lines[1]=" "; |
634 | lcd_lines[1]=" "; |
Line 662... | Line 684... | ||
662 | case STATEID_MOTORTEST: |
684 | case STATEID_MOTORTEST: |
663 | act_motor_increase=0; |
685 | act_motor_increase=0; |
664 | break; |
686 | break; |
Line 665... | Line 687... | ||
665 | 687 | ||
- | 688 | case STATEID_KEYCONTROL: |
|
- | 689 | if (keyCode==KEY_POUND) |
|
- | 690 | keycontrol_exit &= 255^1; |
|
- | 691 | else |
|
- | 692 | if (keyCode==KEY_STAR) |
|
- | 693 | keycontrol_exit &= 255^2; |
|
666 | case STATEID_KEYCONTROL: |
694 | else |
667 | if ((keyCode >= this.KEY_NUM0) && (keyCode < this.KEY_NUM8)) |
695 | if ((keyCode >= this.KEY_NUM0) && (keyCode < this.KEY_NUM8)) |
668 | keycontrol_bitfield[0]&=255^( 1<<(keyCode-this.KEY_NUM0)); |
696 | keycontrol_bitfield[0]&=255^( 1<<(keyCode-this.KEY_NUM0)); |
669 | else |
697 | else |
670 | if ((keyCode >= this.KEY_NUM8) && (keyCode <= this.KEY_NUM9)) |
698 | if ((keyCode >= this.KEY_NUM8) && (keyCode <= this.KEY_NUM9)) |
Line 700... | Line 728... | ||
700 | } |
728 | } |
Line 701... | Line 729... | ||
701 | 729 | ||
Line -... | Line 730... | ||
- | 730 | } |
|
- | 731 | ||
702 | } |
732 | |
Line 703... | Line 733... | ||
703 | 733 | byte keycontrol_exit=0; |
|
704 | 734 | ||
705 | public final static int[] keycontrol_bitfield={0,0}; |
735 | public final static int[] keycontrol_bitfield={0,0}; |
706 | 736 | ||
707 | public void keyPressed(int keyCode) |
737 | public void keyPressed(int keyCode) |
708 | { |
738 | { |
- | 739 | ||
709 | 740 | if (keyCode==KEY_STAR) |
|
- | 741 | { |
|
- | 742 | if (state==STATEID_EDIT_PARAMS) |
|
710 | if (keyCode==KEY_STAR) |
743 | { |
711 | { |
744 | chg_state(STATEID_HANDLE_PARAMS); |
712 | if (state==STATEID_EDIT_PARAMS) |
745 | return; |
- | 746 | } |
|
713 | chg_state(STATEID_HANDLE_PARAMS); |
747 | else |
- | 748 | if (state!=STATEID_KEYCONTROL) |
|
- | 749 | { |
|
714 | else |
750 | chg_state(STATEID_MAINMENU); |
715 | chg_state(STATEID_MAINMENU); |
751 | return; |
716 | 752 | } |
|
717 | return; |
753 | |
718 | } |
754 | } |
719 | if (keyCode==KEY_POUND) |
755 | if ((keyCode==KEY_POUND)&&(state!=STATEID_KEYCONTROL)) |
720 | { |
756 | { |
721 | fullscreen=!fullscreen; |
757 | fullscreen=!fullscreen; |
722 | setFullScreenMode(fullscreen); |
758 | setFullScreenMode(fullscreen); |
723 | return; |
759 | return; |
- | 760 | } |
|
- | 761 | switch(state) |
|
- | 762 | { |
|
- | 763 | case STATEID_KEYCONTROL: |
|
- | 764 | if (keyCode==KEY_POUND) |
|
- | 765 | keycontrol_exit |= 1; |
|
724 | } |
766 | else |
725 | switch(state) |
767 | if (keyCode==KEY_STAR) |
726 | { |
768 | keycontrol_exit |= 2; |
727 | case STATEID_KEYCONTROL: |
769 | else |
728 | if ((keyCode >= this.KEY_NUM0) && (keyCode < this.KEY_NUM8)) |
770 | if ((keyCode >= this.KEY_NUM0) && (keyCode < this.KEY_NUM8)) |
Line 752... | Line 794... | ||
752 | break; |
794 | break; |
Line 753... | Line 795... | ||
753 | 795 | ||
754 | case FIRE: |
796 | case FIRE: |
755 | keycontrol_bitfield[1]|=64; |
797 | keycontrol_bitfield[1]|=64; |
- | 798 | break; |
|
756 | break; |
799 | |
- | 800 | } |
|
- | 801 | if (keycontrol_exit==3) |
|
- | 802 | chg_state(STATEID_MAINMENU); |
|
757 | } |
803 | else |
758 | mk.send_keys(keycontrol_bitfield); |
804 | mk.send_keys(keycontrol_bitfield); |
Line 759... | Line 805... | ||
759 | break; |
805 | break; |
760 | 806 |