Rev 216 | Rev 222 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 216 | Rev 219 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | 32 | ||
33 | public byte resend_timeout=0; |
33 | public byte resend_timeout=0; |
Line -... | Line 34... | ||
- | 34 | int last_count=0; |
|
- | 35 | ||
- | 36 | ||
- | 37 | public boolean resend_check(int ref_count) |
|
- | 38 | { |
|
- | 39 | if (( last_count!=ref_count)||(resend_timeout<0)) |
|
- | 40 | { |
|
- | 41 | if (resend_timeout<0) mk.stats.resend_count++; |
|
- | 42 | last_count=ref_count; |
|
- | 43 | resend_timeout=20; |
|
- | 44 | return true; |
|
- | 45 | } |
|
- | 46 | else |
|
- | 47 | resend_timeout--; |
|
- | 48 | ||
34 | int last_count=0; |
49 | return false; |
35 | 50 | } |
|
36 | 51 | ||
37 | //#ifdef android |
52 | //#ifdef android |
38 | // public final static int BASE_SLEEP=50; |
53 | // public final static int BASE_SLEEP=50; |
Line 39... | Line 54... | ||
39 | //#else |
54 | //#else |
40 | public final static int BASE_SLEEP=40; |
55 | public final static int BASE_SLEEP=10; |
41 | //#endif |
56 | //#endif |
42 | 57 | ||
43 | public void run() |
58 | public void run() |
44 | { |
59 | { |
45 | mk.log("starting Watchdog"); |
60 | mk.log("starting Watchdog"); |
46 | // get all params |
61 | // get all params |
47 | int act_debug_name=0; |
62 | int act_debug_name=0; |
48 | int sleeper=BASE_SLEEP; |
63 | // int sleeper=BASE_SLEEP; |
49 | while(true) |
64 | while(true) |
50 | { |
65 | { |
51 | try { |
66 | try { |
Line 52... | Line 67... | ||
52 | Thread.sleep(sleeper); |
67 | Thread.sleep(BASE_SLEEP); |
53 | sleeper=BASE_SLEEP; |
68 | // sleeper=BASE_SLEEP; |
54 | if (mk.connected&&(!mk.force_disconnect)) |
69 | if (mk.connected&&(!mk.force_disconnect)) |
55 | { |
70 | { |
56 | 71 | ||
57 | mk.log("watchdog pre main loop"); |
72 | mk.log("watchdog pre main loop"); |
58 | /* if (mk.root.canvas.init_bootloader) |
73 | if (mk.init_bootloader) |
59 | { |
74 | { |
60 | mk.jump_bootloader(); |
75 | mk.jump_bootloader(); |
61 | mk.root.canvas.init_bootloader=false; |
76 | mk.init_bootloader=false; |
Line 62... | Line 77... | ||
62 | } |
77 | } |
63 | else */if ( mk.version.major==-1 ) |
78 | else if ( mk.version.major==-1 ) |
64 | mk.get_version(); |
79 | mk.get_version(); |
65 | else if (mk.ufo_prober.is_navi()&&(mk.error_str==null)) |
80 | else if (mk.ufo_prober.is_navi()&&(mk.error_str==null)) |
- | 81 | mk.get_error_str(); |
|
66 | mk.get_error_str(); |
82 | |
67 | 83 | else if (mk.ufo_prober.is_mk()&&(mk.params.last_parsed_paramset==-1)) |
|
68 | else if (mk.ufo_prober.is_mk()&&(mk.params.last_parsed_paramset==-1)) |
84 | { |
69 | { |
85 | mk.get_params(0xFF-1); |
70 | mk.get_params(0xFF-1); |
86 | Thread.sleep(150); |
Line 124... | Line 140... | ||
124 | act_debug_name=0; |
140 | act_debug_name=0; |
Line 125... | Line 141... | ||
125 | 141 | ||
Line 126... | Line 142... | ||
126 | break; |
142 | break; |
127 | 143 | ||
128 | case USER_INTENT_RCDATA: |
144 | case USER_INTENT_RCDATA: |
129 | mk.trigger_rcdata(); |
145 | if ( resend_check(mk.stats.stick_data_count) ) |
- | 146 | mk.trigger_rcdata(); |
|
- | 147 | break; |
|
- | 148 | ||
- | 149 | case USER_INTENT_EXTERNAL_CONTROL: |
|
- | 150 | if (resend_check(mk.stats.external_control_confirm_frame_count)) |
|
- | 151 | mk.send_extern_control(); |
|
- | 152 | ||
Line 130... | Line 153... | ||
130 | sleeper+=250; |
153 | break; |
131 | break; |
154 | |
132 | - | ||
133 | case USER_INTENT_LCD: |
155 | |
134 | if (resend_timeout==0) |
- | |
135 | { |
- | |
136 | mk.LCD.trigger_LCD(); |
156 | case USER_INTENT_LCD: |
137 | resend_timeout=50; |
- | |
138 | } |
- | |
139 | - | ||
140 | if ( last_count!=mk.stats.lcd_data_count) |
- | |
141 | { |
- | |
142 | mk.LCD.trigger_LCD(); |
- | |
143 | resend_timeout=50; |
- | |
144 | } |
- | |
145 | else |
- | |
146 | resend_timeout--; |
157 | if (resend_check(mk.stats.lcd_data_count)) |
Line 147... | Line 158... | ||
147 | 158 | mk.LCD.trigger_LCD(); |
|
148 | //sleeper +=250; |
159 | |
149 | break; |
160 | break; |