Rev 493 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 493 | Rev 517 | ||
---|---|---|---|
Line 130... | Line 130... | ||
130 | } |
130 | } |
131 | catch (Exception e) { |
131 | catch (Exception e) { |
Line 132... | Line 132... | ||
132 | 132 | ||
133 | } |
133 | } |
- | 134 | } |
|
- | 135 | ||
134 | } |
136 | |
135 | public void start_playing(String name) |
137 | public boolean play(String what) |
Line -... | Line 138... | ||
- | 138 | { |
|
136 | { |
139 | |
137 | 140 | // start play |
|
138 | try { |
141 | try { |
139 | act_player_state=PLAYERSTATE_PLAYING; |
142 | act_player_state=PLAYERSTATE_PLAYING; |
140 | player=init_player(name); |
143 | player=init_player(what); |
141 | player.start(); |
144 | player.start(); |
142 | } |
- | |
- | 145 | } |
|
143 | catch (Exception e) { |
146 | catch (Exception e) { |
144 | - | ||
145 | } |
147 | act_player_state=PLAYERSTATE_FIN; |
146 | } |
148 | } |
147 | - | ||
148 | public void wait_for_end() |
149 | |
149 | { |
150 | // wait for end |
150 | while (act_player_state!=PLAYERSTATE_FIN) |
151 | while (act_player_state!=PLAYERSTATE_FIN) |
151 | { |
152 | { |
152 | try { Thread.sleep(5); } |
153 | try { Thread.sleep(5); } |
153 | catch (Exception e) { } |
- | |
Line -... | Line 154... | ||
- | 154 | catch (Exception e) { } |
|
- | 155 | } |
|
154 | } |
156 | |
Line -... | Line 157... | ||
- | 157 | ||
- | 158 | return true; |
|
- | 159 | } |
|
- | 160 | ||
- | 161 | // play number |
|
- | 162 | public void play(int what) |
|
- | 163 | { |
|
- | 164 | ||
- | 165 | if (what==0) |
|
- | 166 | { |
|
- | 167 | play("0"); |
|
- | 168 | return; |
|
- | 169 | } |
|
- | 170 | ||
- | 171 | if (((what/1000)%10)!=0) |
|
- | 172 | { |
|
- | 173 | play((what/1000)%10); |
|
- | 174 | play("thousand"); |
|
- | 175 | what%=1000; |
|
- | 176 | } |
|
- | 177 | ||
- | 178 | ||
- | 179 | if (((what/100)%10)!=0) |
|
- | 180 | { |
|
- | 181 | play((what/100)%10); |
|
- | 182 | play("hundred"); |
|
- | 183 | what%=100; |
|
- | 184 | ||
- | 185 | } |
|
- | 186 | ||
- | 187 | ||
- | 188 | ||
- | 189 | ||
- | 190 | ||
- | 191 | if (what<20) |
|
- | 192 | { |
|
- | 193 | ||
- | 194 | if (what<13) |
|
- | 195 | { |
|
- | 196 | if(what!=0) |
|
- | 197 | play(""+what); |
|
- | 198 | } |
|
- | 199 | else |
|
- | 200 | { |
|
- | 201 | switch (what%10) |
|
- | 202 | { |
|
- | 203 | case 3: |
|
- | 204 | play("thir"); |
|
- | 205 | break; |
|
- | 206 | case 5: |
|
- | 207 | play("fiv"); |
|
- | 208 | break; |
|
- | 209 | default: |
|
- | 210 | play (""+what%10); |
|
- | 211 | } |
|
- | 212 | play("teen"); |
|
- | 213 | } |
|
- | 214 | } |
|
- | 215 | else |
|
- | 216 | { |
|
- | 217 | ||
- | 218 | switch (what/10) |
|
- | 219 | { |
|
- | 220 | ||
- | 221 | case 2: |
|
- | 222 | play("twen"); |
|
- | 223 | break; |
|
- | 224 | case 3: |
|
- | 225 | play("thir"); |
|
- | 226 | break; |
|
- | 227 | case 5: |
|
- | 228 | play("fiv"); |
|
- | 229 | break; |
|
- | 230 | default: |
|
- | 231 | play (""+what/10); |
|
- | 232 | } |
|
- | 233 | play("ty"); |
|
- | 234 | if ((what%10)!=0) |
|
- | 235 | play (what%10); |
|
- | 236 | } |
|
- | 237 | ||
- | 238 | ||
- | 239 | } |
|
155 | 240 | ||
156 | 241 | ||
Line 157... | Line 242... | ||
157 | } |
242 | |
Line 165... | Line 250... | ||
165 | 250 | ||
166 | 251 | ||
Line -... | Line 252... | ||
- | 252 | public int loop_cnt; |
|
- | 253 | public int volts_play_cnt; |
|
- | 254 | ||
- | 255 | boolean conn_told=false; |
|
- | 256 | boolean disconn_told=true; |
|
167 | public int loop_cnt; |
257 | boolean sender_warning_told=false; |
168 | public int volts_play_cnt; |
258 | |
- | 259 | ||
- | 260 | public void run() |
|
169 | 261 | { |
|
170 | public void run() |
262 | |
171 | { |
263 | |
172 | while(true) |
264 | while(true) |
173 | { |
265 | { |
174 | loop_cnt++; |
- | |
175 | if ((canvas.mk!=null)&&(canvas.mk.connected)&&(canvas.settings.do_sound)&&(canvas.mk.UBatt()!=-1)&&(!canvas.mk.force_disconnect)) |
- | |
176 | { |
- | |
177 | volt_timeout--; |
- | |
178 | - | ||
179 | if (info_from_debug_set!=canvas.mk.stats.debug_data_count) |
- | |
180 | { // only when newdata |
- | |
181 | - | ||
Line 182... | Line 266... | ||
182 | if (canvas.settings.do_volts_sound&&(volt_timeout<0)) |
266 | loop_cnt++; |
- | 267 | if ((canvas.mk!=null)&&(canvas.settings.do_sound)) |
|
183 | { |
268 | { |
- | 269 | ||
184 | volts_play_cnt++; |
270 | if ((canvas.mk.connected)&&(!canvas.mk.force_disconnect)) |
- | 271 | { |
|
185 | 272 | if (!conn_told) |
|
- | 273 | { |
|
- | 274 | if (canvas.mk.version.known) |
|
186 | volt_timeout=(delay*1000)/BASE_SLEEP; |
275 | { |
Line -... | Line 276... | ||
- | 276 | play("connected"); |
|
- | 277 | play("to"); |
|
- | 278 | play("mikrokopter"); |
|
187 | int ubatt=canvas.mk.UBatt(); |
279 | play("version"); |
- | 280 | ||
- | 281 | play(canvas.mk.version.major); |
|
- | 282 | play("point"); |
|
- | 283 | play(canvas.mk.version.minor); |
|
- | 284 | play("established"); |
|
- | 285 | conn_told=true; |
|
- | 286 | disconn_told=false; |
|
- | 287 | } |
|
- | 288 | } |
|
- | 289 | else |
|
- | 290 | { |
|
188 | info_from_debug_set=canvas.mk.stats.debug_data_count; |
291 | |
189 | start_playing(""+(ubatt/10)); |
292 | |
190 | wait_for_end(); |
293 | if ((canvas.mk.SenderOkay()<1)) |
191 | 294 | { |
|
192 | if((ubatt%10)!=0) |
295 | if (!sender_warning_told) |
193 | { |
296 | { |
194 | start_playing("komma"); |
- | |
195 | wait_for_end(); |
- | |
196 | start_playing(""+(ubatt%10)); |
297 | play("warning"); |
- | 298 | play("rc-signal"); |
|
- | 299 | play("lost"); |
|
Line 197... | Line -... | ||
197 | wait_for_end(); |
- | |
Line 198... | Line 300... | ||
198 | } |
300 | sender_warning_told=true; |
199 | start_playing("volt"); |
301 | } |
- | 302 | } |
|
200 | wait_for_end(); |
303 | else |
- | 304 | sender_warning_told=false; |
|
Line -... | Line 305... | ||
- | 305 | ||
Line -... | Line 306... | ||
- | 306 | ||
- | 307 | if ((canvas.mk.AngleNick()>400)||(canvas.mk.AngleRoll()>400)||(canvas.mk.AngleNick()<-400)||(canvas.mk.AngleRoll()<-400)) |
|
- | 308 | { |
|
- | 309 | play("tilt"); |
|
201 | } |
310 | play("warning"); |
202 | 311 | } |
|
- | 312 | ||
- | 313 | volt_timeout--; |
|
- | 314 | ||
- | 315 | if (info_from_debug_set!=canvas.mk.stats.debug_data_count) |
|
- | 316 | { // only when newdata |
|
- | 317 | ||
- | 318 | ||
- | 319 | if (canvas.settings.do_volts_sound&&(volt_timeout<0)) |
|
- | 320 | { |
|
- | 321 | play("battery"); |
|
- | 322 | play("at"); |
|
203 | 323 | volts_play_cnt++; |
|
- | 324 | ||
- | 325 | volt_timeout=(delay*1000)/BASE_SLEEP; |
|
- | 326 | int ubatt=canvas.mk.UBatt(); |
|
204 | 327 | info_from_debug_set=canvas.mk.stats.debug_data_count; |
|
- | 328 | play((ubatt/10)); |
|
- | 329 | ||
- | 330 | if((ubatt%10)!=0) |
|
- | 331 | { |
|
- | 332 | play("point"); |
|
205 | if (canvas.settings.do_altimeter_sound) |
333 | play((ubatt%10)); |
206 | { |
334 | |
- | 335 | } |
|
- | 336 | play("volts"); |
|
- | 337 | ||
- | 338 | ||
- | 339 | play("altitude"); |
|
- | 340 | ||
- | 341 | play( canvas.mk.Alt()/10); |
|
- | 342 | play("point"); |
|
- | 343 | play( canvas.mk.Alt()%10); |
|
- | 344 | play("meter"); |
|
- | 345 | ||
- | 346 | ||
- | 347 | if ((canvas.mk.stats.flying_time()!=0)) |
|
- | 348 | { |
|
- | 349 | play("flight"); |
|
- | 350 | play("time"); |
|
- | 351 | switch (canvas.mk.stats.flying_time()/60) |
|
- | 352 | { |
|
- | 353 | case 0: |
|
- | 354 | case 1: |
|
- | 355 | play("1"); |
|
- | 356 | play("minute"); |
|
- | 357 | break; |
|
- | 358 | default: |
|
- | 359 | play(canvas.mk.stats.flying_time()/60); |
|
- | 360 | play("minutes"); |
|
- | 361 | } |
|
- | 362 | ||
- | 363 | switch (canvas.mk.stats.flying_time()%60) |
|
- | 364 | { |
|
- | 365 | case 0: |
|
- | 366 | // case 1: |
|
- | 367 | // play("1"); |
|
207 | if (last_alt==-1) last_alt=canvas.mk.Alt(); |
368 | break; |
208 | - | ||
209 | 369 | default: |
|
- | 370 | play(canvas.mk.stats.flying_time()%60); |
|
- | 371 | play("minutes"); |
|
- | 372 | } |
|
210 | if (last_alt>canvas.mk.Alt()+canvas.settings.altsteps) |
373 | |
- | 374 | ||
- | 375 | ||
- | 376 | } |
|
- | 377 | } |
|
- | 378 | ||
211 | { |
379 | |
- | 380 | ||
- | 381 | if (canvas.settings.do_altimeter_sound) |
|
212 | // start_playing("down"); |
382 | { |
- | 383 | if (last_alt==-1) last_alt=canvas.mk.Alt(); |
|
- | 384 | ||
- | 385 | ||
213 | play_down(); |
386 | if (last_alt>canvas.mk.Alt()+canvas.settings.altsteps) |
- | 387 | { |
|
214 | wait_for_end(); |
388 | play("down"); |
- | 389 | ||
215 | last_alt-=canvas.settings.altsteps; |
390 | last_alt-=canvas.settings.altsteps; |
- | 391 | } |
|
- | 392 | if (last_alt<canvas.mk.Alt()-canvas.settings.altsteps) |
|
216 | } |
393 | |
217 | if (last_alt<canvas.mk.Alt()-canvas.settings.altsteps) |
- | |
218 | - | ||
219 | { |
394 | { |
- | 395 | play("up"); |
|
- | 396 | ||
- | 397 | last_alt+=canvas.settings.altsteps; |
|
- | 398 | } |
|
- | 399 | } |
|
- | 400 | else |
|
- | 401 | last_alt=-1; |
|
220 | //start_playing("up"); |
402 | } |
- | 403 | } |
|
221 | play_up(); |
404 | } |
Line 222... | Line 405... | ||
222 | wait_for_end(); |
405 | else |
223 | last_alt+=canvas.settings.altsteps; |
406 | { |