/branches/ligi_j2me/README |
---|
35,6 → 35,9 |
* 0.24 - adding some GFX |
* 0.25 - adding Graph ( Nick int;Roll int; nick acc ;roll acc) |
* 0.26 - more Visuals |
* 0.27 - implemented motor_test |
* 0.28 - Icon |
* 0.29 - ressources for 176x220 / Ress differencing |
* |
* Online Link to this Document: |
* http://mikrocontroller.cco-ev.de/mikroviewvc/FlightCtrl/branches/ligi_j2me/README?view=markup |
63,20 → 66,32 |
- ANT |
Usage: |
General: |
KEY # toggle Fullscreen |
KEY * to Quit |
Device selection Screen: |
KEY 1..X to select device |
Main Screen: |
KEY UP to go Page up in MK-LCD |
KEY DOWN to go Page up in MK-LCD |
KEY # toggle Fullscreen |
KEY * to Quit |
KEY RIGHT - go to MotorTest |
MotorTest Screen |
UP/DOWN increas/decrease speed of actual motor |
LEFT prev motor ( if first go to main screen ) |
RIGHT next motor |
Tested on: |
SE - K800i |
Nokia - N95 |
SE - W800i |
Nokia 6234 |
Nokia N80 ( Font is too Big - but API worx) |
6230i ( without copter ) |
N95 ( without copter ) |
Nokia - 6234 |
Nokia - N80 ( Font is too Big - but API worx) |
Nokia - 6230i ( without copter ) |
ToDo: |
- Proxying to TCP/IP ( GPRS / UMTS / WLAN ( e.g. N80) .. ) |
- measure DebugSets per Second |
/branches/ligi_j2me/build.props |
---|
0,0 → 1,2 |
screensize=176x220 |
/branches/ligi_j2me/build.xml |
---|
3,7 → 3,9 |
<property name="project_name" value="MKMiniMidlet"/> <!-- jar filename --> |
<property name="res_dir" location="${basedir}/res"/> |
<property file="build.props"/> |
<property name="res_dir" location="${basedir}/res/${screensize}"/> |
<property name="build_dir" location="${basedir}/build/"/> |
<property name="lib_dir" location="${basedir}/lib/"/> |
<property name="src_dir" location="${basedir}/src/"/> |
17,23 → 19,23 |
<target name="build"> |
<wtkbuild destdir="${build_dir}/classes" srcdir="${src_dir}" target="1.1" preverify="true"/> |
<wtkjad |
jadfile="${build_dir}/bin/${project_name}.jad" |
jarfile="${build_dir}/bin/${project_name}.jar" |
jadfile="${build_dir}/bin/${project_name}_${screensize}.jad" |
jarfile="${build_dir}/bin/${project_name}_${screensize}.jar" |
update="false" |
manifest="${build_dir}/bin/MANIFEST.MF" |
name="${project_name}" |
vendor="LiGi" |
version="0.26"> |
version="0.29"> |
<attribute name="MIDletX-No-Command" value="true"/> |
<attribute name="MIDlet-Icon" value="i.png"/> |
<midlet name="${project_name}" class="${project_name}" icon="i.png" /> |
<midlet name="${project_name}" class="${project_name}" /> |
<!-- !!TODO!! Remove Icon JAD entry if no icon is there --> |
</wtkjad> |
<wtkpackage |
jarfile="${build_dir}/bin/${project_name}.jar" |
jadfile="${build_dir}/bin/${project_name}.jad" |
jarfile="${build_dir}/bin/${project_name}_${screensize}.jar" |
jadfile="${build_dir}/bin/${project_name}_${screensize}.jad" |
basedir="${build_dir}/classes" |
manifest="${build_dir}/bin/MANIFEST.MF" |
obfuscate="true" |
50,14 → 52,11 |
<target name="clean"> |
<delete dir="${build_dir}"/> |
<delete dir="${res_dir}"/> |
<tstamp/> |
<mkdir dir="${build_dir}"/> |
<mkdir dir="${build_dir}/classes"/> |
<mkdir dir="${build_dir}/bin"/> |
<mkdir dir="${res_dir}"/> |
</target> |
/branches/ligi_j2me/res/bg.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/branches/ligi_j2me/res/load.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/branches/ligi_j2me/res/lcd.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/branches/ligi_j2me/res/bt.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/branches/ligi_j2me/res/176x220/bg.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/branches/ligi_j2me/res/176x220/bt.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/branches/ligi_j2me/res/176x220/i.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/branches/ligi_j2me/res/176x220/lcd.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/branches/ligi_j2me/res/176x220/load.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/branches/ligi_j2me/res/240x320/bg.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/branches/ligi_j2me/res/240x320/bt.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/branches/ligi_j2me/res/240x320/i.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/branches/ligi_j2me/res/240x320/lcd.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/branches/ligi_j2me/res/240x320/load.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/branches/ligi_j2me/src/BTSearcher.java |
---|
28,37 → 28,20 |
public final int MAX_DEVICES=10; |
public RemoteDevice[] remote_devices; |
public int remote_device_count=0; |
public String[] remote_device_name; |
public String[] remote_device_mac; |
public void search_again() |
{ |
try |
{ |
remote_device_count=0; |
searching=true; |
m_DscrAgent.startInquiry(DiscoveryAgent.GIAC,this); |
} |
catch (BluetoothStateException ex) |
{ |
error=true; |
err_log+="Problem in searching the blue tooth devices\n" + ex; |
} |
} |
public BTSearcher() |
{ |
remote_devices=new RemoteDevice[MAX_DEVICES]; |
remote_device_name=new String[MAX_DEVICES]; |
remote_device_mac=new String[MAX_DEVICES]; |
remote_device_count=0; |
try |
{ |
//First get the local device and obtain the discovery agent. |
65,6 → 48,7 |
m_LclDevice = LocalDevice.getLocalDevice(); |
m_DscrAgent= m_LclDevice.getDiscoveryAgent(); |
m_DscrAgent.startInquiry(DiscoveryAgent.GIAC,this); |
} |
catch (BluetoothStateException ex) |
{ |
72,17 → 56,32 |
err_log+="Problem in searching the blue tooth devices\n" + ex; |
} |
search_again(); |
} |
public void inquiryCompleted(int transID) { |
try { |
for(int i=0;i<remote_device_count;i++) |
{ |
remote_device_name[i]=remote_devices[i].getFriendlyName(true); |
remote_device_mac[i]=remote_devices[i].getBluetoothAddress(); |
} |
} |
catch (Exception e) |
{ |
err_log+="Problem in searching the blue tooth devices"; |
} |
searching=false; |
} |
public void search_again() |
{ |
} |
//Called when device is found during inquiry |
public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) |
{ |
90,9 → 89,7 |
{ |
if (remote_device_count!=(MAX_DEVICES-1)) |
{ |
remote_device_name[remote_device_count]=btDevice.getFriendlyName(true); |
remote_device_mac[remote_device_count]=btDevice.getBluetoothAddress(); |
remote_devices[remote_device_count]=btDevice; |
remote_device_count++; |
} |
} |
/branches/ligi_j2me/src/MKCommunicator.java |
---|
1,23 → 1,15 |
/********************************************************************************************************************************* |
* * |
* Abstaction Layer to Communicate via J2ME and Bluetooth with the FlightCtrl of the MikroKopter Project (www.mikrokopter.de ) * |
* * |
* Author: Marcus -LiGi- Bueschleb * |
* Project-Start: 9/2007 * |
* Version: 0.07 * |
* Mailto: ligi@smart4mobile.de * |
* Licence: Creative Commons / Non Commercial * |
* Big Up: Holger&Ingo * |
* ChangeLog: * |
* 0.01 - initial Version ( initialize connection / main Thread with reading data from MK) * |
* 0.02 - reconnect after connection loss ( e.g. switching on/off ) * |
* 0.03 - added send_command ( with CRC ) * |
* 0.04 - added decode64 to decode 'pseudo' BASE64 * |
* 0.05 - added get_version * |
* 0.06 - added parsing of DebugData * |
* 0.07 - Code-(Doc&&Cleanup) && initial svn commit * |
* * |
*********************************************************************************************************************************/ |
/********************************************************************************************** |
* |
* Abstaction Layer to Communicate via J2ME and Bluetooth with the FlightCtrl of the MikroKopter Project (www.mikrokopter.de ) |
* |
* Author: Marcus -LiGi- Bueschleb |
* Project-Start: 9/2007 |
* Version: 0.07 |
* Mailto: ligi@smart4mobile.de |
* Licence: Creative Commons / Non Commercial |
* Big Up: Holger&Ingo |
* |
************************************************************************************************/ |
import javax.microedition.io.*; |
import java.io.*; |
134,6 → 126,12 |
} |
public void motor_test(int[] params) |
{ |
send_command(0,'t',params); |
} |
// send command to FC ( add crc and pack into pseudo Base64 |
public void send_command(int modul,char cmd,int[] params) |
{ |
144,9 → 142,9 |
for(int param_pos=0;param_pos<(params.length/3 + (params.length%3==0?0:1)) ;param_pos++) |
{ |
int a = (param_pos<params.length)?params[param_pos]:0; |
int b = ((param_pos+1)<params.length)?params[param_pos+1]:0; |
int c = ((param_pos+2)<params.length)?params[param_pos+2]:0; |
int a = (param_pos*3<params.length)?params[param_pos*3]:0; |
int b = ((param_pos*3+1)<params.length)?params[param_pos*3+1]:0; |
int c = ((param_pos*3+2)<params.length)?params[param_pos*3+2]:0; |
send_buff[3+param_pos*4] = (char)((a >> 2)+'=' ); |
send_buff[3+param_pos*4+1] = (char)('=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4))); |
/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; |
} |