Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 209 → Rev 210

/branches/ligi_j2me/README
30,6 → 30,8
* 0.16 - LCD implementation & polishing code on serveral places
* 0.17 - Quit via * | Rescan via #
* 0.18 - Remember URL ( bt-mac ) on quit
* 0.19 - better handling of MK Version
* 0.23 - care for Version while parsing DebugData - MK0.64 compatible now (0.20-0.23 - n1 bugfixing With CaSCade)
*
* Online Link to this Document:
* http://mikrocontroller.cco-ev.de/mikroviewvc/FlightCtrl/branches/ligi_j2me/README?view=markup
79,6 → 81,6
- get/set MK-Parameters
- Visualisation of DebugData
- making lib to be useable with desktop JAVA / will be sceduled after bluecove for linux is ready ( anounced for next Version)
- save BT-Mac ( so that no scanning is needed on startup )
- triangulate MK by BT rssi
- tbc
/branches/ligi_j2me/bin/midp2_minimal/MKMiniMidlet.jad
1,7 → 1,7
MIDlet-Jar-URL: MKMiniMidlet.jar
MIDlet-Jar-Size: 8234
MIDlet-Jar-Size: 8814
MIDlet-Name: MKMiniMidlet
MIDlet-Vendor: LiGi
MIDlet-Version: 0.18
MIDlet-Version: 0.23
MIDlet-1: MKMiniMidlet, , MKMiniMidlet
MIDletX-No-Command: true
/branches/ligi_j2me/bin/midp2_minimal/MKMiniMidlet.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/branches/ligi_j2me/src/MKCommunicator.java
32,13 → 32,9
 
public String mk_url=""; // buffer the url which is given in the constuctor for reconnectin purposes
// version Info from Flight Control
public int version_major=-1;
public int version_minor=-1;
public int version_compatible=-1;
 
public MKLCD LCD;
public MKVersion version;
public MKDebugData debug_data;
 
public long connection_start_time=-1;
62,7 → 58,7
/****************** Section: public Methods ************************************************/
public MKCommunicator(String url) // Constructor with URL string e.g. "btspp://XXXXXXXXXXXX:1" - the X-Part is the MAC-Adress of the Bluetooth-Device connected to the Fligth-Control
{
 
version=new MKVersion();
debug_data=new MKDebugData();
mk_url=url; // remember URL for connecting / reconnecting later
 
182,7 → 178,7
}
 
MKDebugData debug_data;
 
public void process_data(int[] data,int len)
{
int[] decoded_data;
192,20 → 188,13
{
case 'D': // debug Data
decoded_data=Decode64(data,3,50);
debug_data=new MKDebugData(decoded_data);
 
debug_data_count++;
debug_data.set_by_mk_data(Decode64(data,3,50),version);
break;
case 'V': // Version Info
decoded_data=Decode64(data,3,6);
version_major=decoded_data[0];
version_minor=decoded_data[1];
version_compatible=decoded_data[2];
version_data_count++;
version.set_by_mk_data(Decode64(data,3,6));
break;
case '0':
/branches/ligi_j2me/src/MKDebugData.java
25,22 → 25,34
 
public MKDebugData()
{
analog=new int[16];
for (i=0;i<16;i++)
analog=new int[32];
for (i=0;i<32;i++)
analog[i]=-1;
 
}
 
public MKDebugData(int[] in_arr) // MKVersion
public void set_by_mk_data(int[] in_arr,MKVersion version)
{
 
analog=new int[32];
if (version.compare(-1,-1)==version.VERSION_EQUAL)
return;
 
for (i=0;i<16;i++)
analog[i]=(in_arr[17+i*2]<<8) | in_arr[18+i*2];
if (version.compare(0,60)==version.VERSION_PREVIOUS)
{
for (i=0;i<16;i++)
analog[i]=(in_arr[1+i*2]<<8) | in_arr[2+i*2];
}
else
{
for (i=0;i<16;i++)
analog[i]=(in_arr[17+i*2]<<8) | in_arr[18+i*2];
}
 
motor_complete=motor_val(0)+motor_val(1)+motor_val(2)+motor_val(3);
 
 
}
 
 
 
}
/branches/ligi_j2me/src/MKLCD.java
0,0 → 1,78
/*********************************************************************************************************************************
* *
* Handling of MK LCD *
* *
* Author: Marcus -LiGi- Bueschleb *
* Project-Start: 9/2007 *
* Mailto: ligi@smart4mobile.de *
* Licence: Creative Commons / Non Commercial *
* Big Up: Holger&Ingo *
*********************************************************************************************************************************/
 
public class MKLCD
implements Runnable
{
 
MKCommunicator mk=null;
 
public String[] LCD_str;
 
public MKLCD(MKCommunicator _mk)
{
LCD_str=new String[4];
mk=_mk;
new Thread( this ).start(); // fire up main Thread
}
 
public void run()
{
while(true)
{
if (mk.connected)
{
trigger_LCD();
}
else
{
 
}
try { Thread.sleep(100); }
catch (Exception e) { }
}
}
 
 
public void handle_lcd_data(int[] data,int row)
{
LCD_str[row]="";
for(int foo=0;foo<20;foo++)
LCD_str[row]+=(char)data[foo];
}
 
public void trigger_LCD()
{
int[] params=new int[3];
params[0]=act_key;
params[1]=0;
params[2]=0;
 
mk.send_command(0,'h',params);
act_key=0;
}
int act_key=0;
 
 
public void LCD_NEXTPAGE()
{
act_key=2;
}
 
public void LCD_PREVPAGE()
{
act_key=1;
}
}
/branches/ligi_j2me/src/MKMiniCanvas.java
151,7 → 151,7
{
int y_off=0;
 
g.drawString("v"+mk.version_major+"."+mk.version_minor+"(d:"+mk.debug_data_count+ " l:" + mk.lcd_data_count+ " v:" + mk.version_data_count+" o:"+mk.other_data_count+")",0,y_off,Graphics.TOP | Graphics.LEFT);
g.drawString(mk.version.str+"(d:"+mk.debug_data_count+ " l:" + mk.lcd_data_count+ " v:" + mk.version_data_count+" o:"+mk.other_data_count+")",0,y_off,Graphics.TOP | Graphics.LEFT);
 
y_off+=spacer;
for ( int foo=0;foo<4;foo++)
/branches/ligi_j2me/src/MKVersion.java
0,0 → 1,48
/*********************************************************************************************************************************
* *
* class representing the MK-Version *
* *
* Author: Marcus -LiGi- Bueschleb *
* Project-Start: 9/2007 *
 
* Mailto: ligi@smart4mobile.de *
* Licence: Creative Commons / Non Commercial *
* Big Up: Holger&Ingo *
*********************************************************************************************************************************/
 
public class MKVersion
 
{
public int major=-1;
public int minor=-1;
public int compatible=-1;
public String str="--";
public final byte VERSION_AFTER=0;
public final byte VERSION_EQUAL=1;
public final byte VERSION_PREVIOUS=2;
 
 
public void set_by_mk_data(int[] data)
{
major=data[0];
minor=data[1];
compatible=data[2];
str="v"+major+"."+minor+"/"+compatible;
}
public byte compare(int major_c,int minor_c)
{
if ((major_c==major)&&(minor_c==minor))
return VERSION_EQUAL;
// TODO - compare major - PC-COMPATIBLE
else if (minor_c>minor) return VERSION_AFTER;
return VERSION_PREVIOUS;
 
 
}
 
}