Subversion Repositories FlightCtrl

Compare Revisions

Regard whitespace Rev 230 → Rev 231

/branches/ligi_j2me/src/MKMiniCanvas.java
1,13 → 1,13
/*********************************************************************************************************************************
* *
* minimal canvas to test Abstraction layer on various Phones *
* *
* Author: Marcus -LiGi- Bueschleb *
* Project-Start: 9/2007 *
* Mailto: ligi@smart4mobile.de *
* Licence: Creative Commons / Non Commercial *
* Big Up: Holger&Ingo *
*********************************************************************************************************************************/
/***************************************************************
*
* minimal canvas to test Abstraction layer on various Phones
*
* Author: Marcus -LiGi- Bueschleb
* Project-Start: 9/2007
* Mailto: ligi@smart4mobile.de
* Licence: Creative Commons / Non Commercial
* Big Up: Holger&Ingo
***************************************************************/
 
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
117,6 → 117,9
 
while(true)
{
repaint();
serviceRepaints();
 
long loopStartTime = System.currentTimeMillis();
long sleeptime=0;
// ticked thing
123,6 → 126,28
frame_pos++;
 
 
switch(state)
{
case STATEID_MOTORTEST:
 
if (motor_test_sel_all)
for (int m=0;m<4;m++)
{
motor_test[m]+=act_motor_increase;
if (motor_test[m]<0)motor_test[m]=0;
}
else
{
motor_test[act_motor]+=act_motor_increase;
if (motor_test[act_motor]<0)motor_test[act_motor]=0;
}
 
mk.motor_test(motor_test);
break;
}
 
try {
nick_line_pos_data[-bg_offset] = mk.debug_data.nick_int();
roll_line_pos_data[-bg_offset] = mk.debug_data.roll_int();
166,6 → 191,7
bt_scanner.search_again();
}
 
try {
rescan=false;
bg_offset--;
if (bg_offset==-bg_img.getWidth())
173,13 → 199,18
com.nokia.mid.ui.DeviceControl.setLights(0,100);
//bt.tick();
// every state has sth to do in tick section
}
catch (Exception e)
{
}
 
 
// System.gc();
repaint();
serviceRepaints();
sleeptime=1000/ 15 - (int) (System.currentTimeMillis()- loopStartTime);
197,12 → 228,20
 
 
public int state=-1;
public final static int STATEID_MOTORTEST=2;
 
int local_max=-1;
 
int[] motor_test = {0,0,0,0};
 
// drawing section
public void paint(Graphics g) {
try {
if (mk!=null)
{
line_middle_y=this.getHeight()/2;
220,11 → 259,29
g.setColor(0xFFFFFF);
g.fillRect(0,0,this.getWidth(),this.getHeight());
g.drawImage(bg_img,bg_offset,0, g.TOP | g.LEFT);
 
if (bg_offset+bg_img.getWidth()<this.getWidth())
g.drawImage(bg_img,bg_offset+bg_img.getWidth(),0, g.TOP | g.LEFT);
 
 
 
 
switch(state)
{
case STATEID_MOTORTEST:
for (int bar=0;bar<4;bar++)
{
g.setColor(((bar==act_motor)|motor_test_sel_all)?0x44CC44:0x4444DD);
g.fillRect(this.getWidth()/(8*2)+bar*2*this.getWidth()/8,10,this.getWidth()/8,20+motor_test[bar]);
g.setColor(0x000000);
g.drawString(""+motor_test[bar] ,this.getWidth()/8+bar*2*this.getWidth()/8,10,Graphics.TOP | Graphics.HCENTER);
if(bar!=4) g.drawString(""+mk.debug_data.motor_val(bar) ,this.getWidth()/8+bar*2*this.getWidth()/8,30,Graphics.TOP | Graphics.HCENTER);
}
break;
default:
g.setColor(0x000000);
if (mk==null)
{
 
276,21 → 333,17
}
 
 
y_off=this.getHeight()-4*19;
y_off=this.getHeight()-4*lcd_img.getHeight();
 
for ( int foo=0;foo<4;foo++)
{
for (int x=0;x<20;x++)
{
g.setClip(12*x,y_off,12,19);
g.drawImage(lcd_img,12*x-(mk.LCD.LCD_str[foo].charAt(x)-' ')*(lcd_img.getWidth()/95),y_off, g.TOP | g.LEFT);
g.setClip((lcd_img.getWidth()/222)*x,y_off,(lcd_img.getWidth()/222),lcd_img.getHeight());
g.drawImage(lcd_img,(lcd_img.getWidth()/222)*x-(mk.LCD.LCD_str[foo].charAt(x)-' ')*(lcd_img.getWidth()/222),y_off, g.TOP | g.LEFT);
 
}
y_off+=19;
 
 
y_off+=lcd_img.getHeight();
}
 
g.setClip(0,0,this.getWidth(),this.getHeight());
322,8 → 375,12
 
}
 
}
 
} catch (Exception e) {}
}
 
private void connect_mk(String url)
{
mk = new MKCommunicator(url);
343,10 → 400,62
/*********************************************** input Section **********************************************/
// keys
public boolean fullscreen=false;
public int act_motor=0;
public int act_motor_increase=0;
public boolean motor_test_sel_all=false;
 
public void chg_state(int _state)
{
state=_state;
}
 
 
public void keyReleased(int keyCode)
{
switch(state)
{
case STATEID_MOTORTEST:
act_motor_increase=0;
break;
}
 
}
 
public void keyPressed(int keyCode)
{
switch(state)
{
case STATEID_MOTORTEST:
switch (getGameAction (keyCode))
{
case UP:
act_motor_increase=-1;
break;
case DOWN:
act_motor_increase=1;
break;
 
case FIRE:
motor_test_sel_all=!motor_test_sel_all;
break;
 
case LEFT:
act_motor--;
if (act_motor<0) {act_motor=0; chg_state(-1); }
break;
 
case RIGHT:
act_motor++;
act_motor%=4;
break;
}
 
break;
 
default:
if ((mk==null)&&(keyCode >= this.KEY_NUM0) && (keyCode < this.KEY_NUM0+bt_scanner.remote_device_count))
connect_mk("btspp://"+bt_scanner.remote_device_mac[keyCode-this.KEY_NUM0] + ":1");
else
363,6 → 472,7
//rescan=true;
fullscreen=!fullscreen;
setFullScreenMode(fullscreen);
break;
}
switch (getGameAction (keyCode))
374,9 → 484,14
case DOWN:
mk.LCD.LCD_NEXTPAGE();
break;
 
case RIGHT:
state=STATEID_MOTORTEST;
break;
}
}
}
return;
}