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: |