Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 218 → Rev 219

/DUBwise/trunk/shared/src/DUBwiseDefinitions.java
4,19 → 4,49
public interface DUBwiseDefinitions
{
 
public final static byte USER_INTENT_NONE=0;
public final static byte USER_INTENT_RAWDEBUG=1;
public final static byte USER_INTENT_PARAMS=2;
public final static byte USER_INTENT_GRAPH=3;
public final static byte USER_INTENT_RCDATA=4;
public final static byte USER_INTENT_LCD=5;
public final static byte USER_INTENT_NONE =0;
public final static byte USER_INTENT_RAWDEBUG =1;
public final static byte USER_INTENT_PARAMS =2;
public final static byte USER_INTENT_GRAPH =3;
public final static byte USER_INTENT_RCDATA =4;
public final static byte USER_INTENT_LCD =5;
public final static byte USER_INTENT_EXTERNAL_CONTROL =6;
 
 
public final static byte GPS_FORMAT_DECIMAL=0;
public final static byte GPS_FORMAT_MINSEC=1;
public final static byte GPS_FORMAT_DECIMAL =0;
public final static byte GPS_FORMAT_MINSEC =1;
 
 
public final static byte SPEED_FORMAT_KMH=0; // km/h
public final static byte SPEED_FORMAT_MPH=1; // miles/h
public final static byte SPEED_FORMAT_CMS=2; // cm/s
public final static byte SPEED_FORMAT_KMH =0; // km/h
public final static byte SPEED_FORMAT_MPH =1; // miles/h
public final static byte SPEED_FORMAT_CMS =2; // cm/s
 
 
 
/* from uart.h
unsigned char Digital[2];
unsigned char RemoteTasten;
signed char Nick;
signed char Roll;
signed char Gier;
unsigned char Gas;
signed char Hight;
unsigned char free;
unsigned char Frame;
unsigned char Config;
*/
 
public final static byte EXTERN_CONTROL_NICK =3;
public final static byte EXTERN_CONTROL_ROLL =4;
public final static byte EXTERN_CONTROL_GIER =5;
public final static byte EXTERN_CONTROL_GAS =6;
public final static byte EXTERN_CONTROL_HIGHT =7;
public final static byte EXTERN_CONTROL_FRAME =9;
public final static byte EXTERN_CONTROL_CONFIG =10;
 
public final static byte EXTERN_CONTROL_LENGTH =11;
 
public final static byte EXTERN_CONTROL_DEFAULT =42;
 
public final static byte[] default_extern_keycontrol = { (byte)0, (byte)0, (byte)0, (byte)EXTERN_CONTROL_DEFAULT, (byte)EXTERN_CONTROL_DEFAULT, (byte)EXTERN_CONTROL_DEFAULT, (byte)255 , (byte)0, (byte)0, (byte)1, (byte)1 };
}
/DUBwise/trunk/shared/src/MKCommunicator.java
27,11 → 27,13
 
 
public class MKCommunicator
implements Runnable
implements Runnable,DUBwiseDefinitions
{
public byte bl_retrys=0;
public boolean init_bootloader=false;
 
public byte lib_version_major=0;
public byte lib_version_minor=1;
public byte lib_version_minor=3;
 
public String lib_version_str()
{
54,50 → 56,51
int data_buff_pos=0;
 
public byte user_intent=0;
public final static int[] crc16_table = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
};
public final static int[] crc16_table = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
};
 
public void log(String str)
{
//#ifdef android
if (do_log) Log.d("MK-Comm",str);
if (do_log) Log.d("MK-Comm",str);
//#endif
}
 
public int CRC16(int ch, int crc)
{ return crc16_table[((crc >> 8) ^ (ch)) & 0xFF] ^ (crc << 8);
{
return crc16_table[((crc >> 8) ^ (ch)) & 0xFF] ^ (crc << 8);
}
 
 
108,15 → 111,17
else
return 0;
}
public final static int BOOTLOADER_STAGE_NONE=0;
public final static int BOOTLOADER_STAGE_GOT_MKBL=1;
public final static byte BOOTLOADER_STAGE_NONE=0;
public final static byte BOOTLOADER_STAGE_GOT_MKBL=1;
 
int bootloader_stage= BOOTLOADER_STAGE_NONE;
byte bootloader_stage= BOOTLOADER_STAGE_NONE;
 
public MKLCD LCD;
public MKVersion version;
public MKDebugData debug_data;
 
public int[] extern_control;
 
public MKGPSPosition gps_position;
 
public MKStickData stick_data;
178,6 → 183,10
debug_data=new MKDebugData();
stick_data=new MKStickData();
params=new MKParamsParser();
extern_control=new int[EXTERN_CONTROL_LENGTH];
extern_control[EXTERN_CONTROL_CONFIG]=1;
extern_control[EXTERN_CONTROL_FRAME]=1;
LCD= new MKLCD(this);
watchdog=new MKWatchDog(this);
gps_position=new MKGPSPosition();
231,7 → 240,7
 
age%=DATA_BUFF_LEN;
if (age<=data_buff_pos)
if (age<=data_buff_pos)
return ""+data_buff[data_buff_pos-age];
else
return ""+data_buff[DATA_BUFF_LEN+data_buff_pos-age];
355,11 → 364,19
send_command(FC_SLAVE_ADDR,'t',params);
}
 
public void send_keys(int[] params)
 
public void send_extern_control()
{
send_command(FC_SLAVE_ADDR,'k',params);
 
stats.external_control_request_count++;
send_command(FC_SLAVE_ADDR,'b',extern_control);
}
 
/* public void send_keys(int[] params)
{
send_command(FC_SLAVE_ADDR,'k',params);
}*/
// get params
public void get_params(int id)
{
457,6 → 474,8
flash_msgs[msg_pos]="attempt "+attempt;
attempt++;
send_command_nocheck((byte)FC_SLAVE_ADDR,'R',new int[0]);
try{
writer.write( 27);
writer.flush();
 
464,7 → 483,8
writer.write( 0xAA);
writer.flush();
 
}
catch (Exception e) { }
sleep((attempt%2==0)?80:800); //800
}
msg_pos++;
563,7 → 583,6
// send command to FC ( add crc and pack into pseudo Base64
public void send_command(int modul,char cmd,int[] params)
{
 
// if (modul==0) return;
sending=true;
send_command_nocheck((byte)modul,cmd,params);
612,6 → 631,10
debug_data.set_names_by_mk_data(Decode64(data,3,len-3));
break;
 
case 'B': // external_control confirm frames
stats.external_control_confirm_frame_count++;
break;
 
case 'L': // LCD Data
stats.lcd_data_count++;
LCD.handle_lcd_data(Decode64(data,3,len-3));
722,7 → 745,7
//# catch (Exception inner_ex) { }
//#endif
ufo_prober.set_to_none();
stats.reset();
stats.reset();
connected=false;
version=new MKVersion();
}
730,7 → 753,7
// Thread to recieve data from Connection
public void run()
{
 
boolean sigfail=false;
if (bootloader_stage==BOOTLOADER_STAGE_GOT_MKBL)
{
try {
740,6 → 763,10
writer.flush();
int avr_sig=reader.read();
 
while (avr_sig==63)
avr_sig=reader.read();
 
flash_msgs[msg_pos++]="got avr sig " + avr_sig;
 
 
747,7 → 774,10
throw new Exception("val after avrsig isnt 0");
 
if ((avr_sig!=0x74)&&(avr_sig!=224)&&(avr_sig!=120))
throw new Exception("avr sig" + avr_sig + " unknown");
{
sigfail=true;
throw new Exception("avr sig" + avr_sig + " unknown");
}
writer.write('T');
// writer.flush();
779,101 → 809,106
flash_msgs[msg_pos++]="BUFF Size:" + send_buff_size;
// if (send_buff_size>128)
// send_buff_size=128;
if (bootloader_intension_flash)
{
 
byte[] flash_buff =new byte[send_buff_size]; ///!!
 
 
flash_msgs[msg_pos++]="Opening firmware ..";
 
 
InputStream in;
try {
in=this.getClass().getResourceAsStream((avr_sig==224)?"/navi.bin":((avr_sig==120)?"mk3.bin":"/fc.bin"));
}
catch (Exception e) { throw new Exception(" cant open firmware"); }
 
 
int firmware_size= ((int)in.read()<<24) |((int)in.read()<<16) | ((int)in.read()<<8) | ((int)in.read()&0xff) ;
 
flash_msgs[msg_pos++]=".. open with " + firmware_size + "bytes";
 
 
 
// if (true) throw new Exception("before erasing" );
 
flash_msgs[msg_pos++]="Erasing Flash ..";
writer.write('e');
writer.flush();
 
if (reader.read()!=0x0d)
throw new Exception("cant erase flash");
 
flash_msgs[msg_pos]+="OK";
 
 
writer.write('A');
writer.write(0);
writer.write(0);
writer.flush();
 
if (reader.read()!=0x0d)
throw new Exception("cant set addr");
flash_msgs[msg_pos++]="addr set";
 
 
int blocks2write=((firmware_size/send_buff_size));
if ((firmware_size%send_buff_size)>0)
blocks2write++;
 
for ( int block=0; block<blocks2write; block ++)
{
int hex_bytes_read=in.read(flash_buff,0,send_buff_size);
if (bootloader_intension_flash)
{
flash_msgs[msg_pos]="bl:" + block + "/" + blocks2write + " si:"+hex_bytes_read ;
 
 
writer.write('B');
writer.write((hex_bytes_read>>8)& 0xFF);
writer.write((hex_bytes_read)& 0xFF);
writer.write('F');
byte[] flash_buff =new byte[send_buff_size]; ///!!
String firmware_filename=(avr_sig==224)?"/navi.bin":((avr_sig==120)?"/mk3.bin":"/fc.bin");
flash_msgs[msg_pos++]="Opening firmware " + firmware_filename + "..";
InputStream in;
try {
in=this.getClass().getResourceAsStream(firmware_filename);
}
catch (Exception e) { throw new Exception(" .. cant open firmware"); }
int firmware_size=-1;
try {
firmware_size= ((int)in.read()<<24) |((int)in.read()<<16) | ((int)in.read()<<8) | ((int)in.read()&0xff) ;
}
catch (Exception e) { throw new Exception(" .. cant read size"); }
int blocks2write=((firmware_size/send_buff_size));
flash_msgs[msg_pos++]=".. open("+blocks2write+" blocks," + firmware_size + "bytes)";
// if (true) throw new Exception("before erasing");
// if (true) throw new Exception("before erasing" );
flash_msgs[msg_pos++]="Erasing Flash ..";
writer.write('e');
writer.flush();
 
writer.write(flash_buff,0,hex_bytes_read);
writer.flush();
 
if (avr_sig==224)
if (reader.read()!=0x0d)
throw new Exception("cant erase flash");
flash_msgs[msg_pos]+="OK";
writer.write('A');
writer.write(0);
writer.write(0);
writer.flush();
if (reader.read()!=0x0d)
throw new Exception("cant set addr");
flash_msgs[msg_pos++]="addr set";
// int blocks2write=((firmware_size/send_buff_size));
if ((firmware_size%send_buff_size)>0)
blocks2write++;
for ( int block=0; block<blocks2write; block ++)
{
int crc=0xFFFF;
for (int crc_pos=0;crc_pos<hex_bytes_read;crc_pos++)
crc=CRC16(flash_buff[crc_pos],crc);
writer.write(crc>>8);
writer.write(crc&0xff);
writer.flush();
}
int hex_bytes_read=in.read(flash_buff,0,send_buff_size);
flash_msgs[msg_pos]="bl:" + block + "/" + blocks2write + " si:"+hex_bytes_read ;
writer.write('B');
writer.write((hex_bytes_read>>8)& 0xFF);
writer.write((hex_bytes_read)& 0xFF);
writer.write('F');
writer.flush();
writer.write(flash_buff,0,hex_bytes_read);
writer.flush();
if (avr_sig==224)
{
int crc=0xFFFF;
for (int crc_pos=0;crc_pos<hex_bytes_read;crc_pos++)
crc=CRC16(flash_buff[crc_pos],crc);
writer.write(crc>>8);
writer.write(crc&0xff);
writer.flush();
}
// flash_msgs[msg_pos]+="ok";
// writer.flush();
 
 
if (reader.read()!=0x0d)
throw new Exception("abort write at block"+block);
// sleep(1000);
}
// flash_msgs[msg_pos]="bl:" + block + "/" + blocks2write + " si:"+hex_bytes_read ;
/*
 
if (reader.read()!=0x0d)
throw new Exception("abort write at block"+block);
// sleep(1000);
}
// flash_msgs[msg_pos]="bl:" + block + "/" + blocks2write + " si:"+hex_bytes_read ;
/*
int inp=0;
int block=0;
while (inp!=-1)
993,10 → 1028,12
flash_msgs[msg_pos++]="cant exit bootloader" ;
}
flash_msgs[msg_pos++]="Exit BL done" ;
 
 
 
close_connections(false);
if (sigfail&&(bl_retrys<3))
{
bl_retrys++;
init_bootloader=true;
}
close_connections(false);
}
 
 
/DUBwise/trunk/shared/src/MKStatistics.java
9,8 → 9,6
 
package org.ligi.ufo;
 
 
 
public class MKStatistics
 
{
19,6 → 17,8
public int bytes_out=0;
 
 
public int resend_count=0;
 
public int debug_data_count=0;
public int debug_names_count=0;
public int angle_data_count=0;
28,6 → 28,7
public int params_data_count=0;
public int navi_data_count=0;
public int stick_data_count=0;
public int external_control_confirm_frame_count=0;
 
 
public int debug_data_request_count=0;
38,7 → 39,9
// public int navi_data_count=0;
public int stick_data_request_count=0;
public int motortest_request_count=0;
public int external_control_request_count=0;
 
 
public void reset()
{
 
/DUBwise/trunk/shared/src/MKWatchDog.java
34,10 → 34,25
int last_count=0;
 
 
public boolean resend_check(int ref_count)
{
if (( last_count!=ref_count)||(resend_timeout<0))
{
if (resend_timeout<0) mk.stats.resend_count++;
last_count=ref_count;
resend_timeout=20;
return true;
}
else
resend_timeout--;
return false;
}
 
//#ifdef android
// public final static int BASE_SLEEP=50;
//#else
public final static int BASE_SLEEP=40;
public final static int BASE_SLEEP=10;
//#endif
 
public void run()
45,22 → 60,22
mk.log("starting Watchdog");
// get all params
int act_debug_name=0;
int sleeper=BASE_SLEEP;
// int sleeper=BASE_SLEEP;
while(true)
{
try {
Thread.sleep(sleeper);
sleeper=BASE_SLEEP;
Thread.sleep(BASE_SLEEP);
// sleeper=BASE_SLEEP;
if (mk.connected&&(!mk.force_disconnect))
{
 
mk.log("watchdog pre main loop");
/* if (mk.root.canvas.init_bootloader)
if (mk.init_bootloader)
{
mk.jump_bootloader();
mk.root.canvas.init_bootloader=false;
mk.init_bootloader=false;
}
else */if ( mk.version.major==-1 )
else if ( mk.version.major==-1 )
mk.get_version();
else if (mk.ufo_prober.is_navi()&&(mk.error_str==null))
mk.get_error_str();
68,7 → 83,8
else if (mk.ufo_prober.is_mk()&&(mk.params.last_parsed_paramset==-1))
{
mk.get_params(0xFF-1);
sleeper+=150;
Thread.sleep(150);
 
act_paramset=0; // warning - if dropped problem
}
else switch (mk.user_intent)
126,26 → 142,21
break;
 
case USER_INTENT_RCDATA:
mk.trigger_rcdata();
sleeper+=250;
if ( resend_check(mk.stats.stick_data_count) )
mk.trigger_rcdata();
break;
 
case USER_INTENT_EXTERNAL_CONTROL:
if (resend_check(mk.stats.external_control_confirm_frame_count))
mk.send_extern_control();
 
break;
 
case USER_INTENT_LCD:
if (resend_timeout==0)
{
if (resend_check(mk.stats.lcd_data_count))
mk.LCD.trigger_LCD();
resend_timeout=50;
}
if ( last_count!=mk.stats.lcd_data_count)
{
mk.LCD.trigger_LCD();
resend_timeout=50;
}
else
resend_timeout--;
//sleeper +=250;
 
break;
 
default: