Subversion Repositories Projects

Rev

Rev 493 | Show entire file | Regard 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
        }
-
 
143
        catch (Exception e)  {
-
 
-
 
145
        }
144
           
146
        catch (Exception e)  {
Line 145... Line 147...
145
        }      
147
            act_player_state=PLAYERSTATE_FIN;
146
    }
-
 
147
   
148
        }      
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
            {
Line -... Line 153...
-
 
153
                try { Thread.sleep(5); }
-
 
154
                catch (Exception e)  {   }
-
 
155
            }
-
 
156
 
-
 
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)
152
                try { Thread.sleep(5); }
180
            {
Line -... Line 181...
-
 
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
   
153
                catch (Exception e)  {   }
238
 
154
            }
239
 }
Line 155... Line 240...
155
               
240
 
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
 
-
 
264
        while(true)
-
 
265
            {
-
 
266
                loop_cnt++;
-
 
267
                if ((canvas.mk!=null)&&(canvas.settings.do_sound))
-
 
268
                    {
-
 
269
 
-
 
270
                        if ((canvas.mk.connected)&&(!canvas.mk.force_disconnect))
-
 
271
                            {
-
 
272
                        if (!conn_told)
-
 
273
                            {
-
 
274
                                if (canvas.mk.version.known)
-
 
275
                                    {
-
 
276
                                        play("connected");
-
 
277
                                        play("to");
-
 
278
                                        play("mikrokopter");
-
 
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
                            {
-
 
291
 
-
 
292
               
-
 
293
                                if ((canvas.mk.SenderOkay()<1))
-
 
294
                                    {
-
 
295
                                        if (!sender_warning_told)
-
 
296
                                            {
-
 
297
                                                play("warning");
-
 
298
                                                play("rc-signal");
-
 
299
                                                play("lost");
-
 
300
                                                sender_warning_told=true;
-
 
301
                                            }
-
 
302
                                    }
-
 
303
                                else
172
        while(true)
304
                                    sender_warning_told=false;
173
            {
305
 
-
 
306
 
-
 
307
                                if ((canvas.mk.AngleNick()>400)||(canvas.mk.AngleRoll()>400)||(canvas.mk.AngleNick()<-400)||(canvas.mk.AngleRoll()<-400))
-
 
308
                                    {
-
 
309
                                        play("tilt");
174
                loop_cnt++;
310
                                        play("warning");
Line 175... Line 311...
175
                if ((canvas.mk!=null)&&(canvas.mk.connected)&&(canvas.settings.do_sound)&&(canvas.mk.UBatt()!=-1)&&(!canvas.mk.force_disconnect))
311
                                    }
176
                    {
312
 
Line -... Line 313...
-
 
313
                                volt_timeout--;
177
                        volt_timeout--;
314
                               
178
       
315
                                if (info_from_debug_set!=canvas.mk.stats.debug_data_count)
-
 
316
                                    { // only when newdata
-
 
317
                                       
179
                        if (info_from_debug_set!=canvas.mk.stats.debug_data_count)
318
                                       
Line 180... Line 319...
180
                            { // only when newdata
319
                                        if (canvas.settings.do_volts_sound&&(volt_timeout<0))
181
                               
320
                                            {
182
                                if (canvas.settings.do_volts_sound&&(volt_timeout<0))
321
                                                play("battery");
183
                                    {
322
                                                play("at");
184
                                        volts_play_cnt++;
-
 
Line 185... Line 323...
185
 
323
                                                volts_play_cnt++;
186
                                        volt_timeout=(delay*1000)/BASE_SLEEP;
324
                                               
187
                                        int ubatt=canvas.mk.UBatt();
325
                                                volt_timeout=(delay*1000)/BASE_SLEEP;
-
 
326
                                                int ubatt=canvas.mk.UBatt();
-
 
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");
-
 
333
                                                        play((ubatt%10));
-
 
334
                                                       
188
                                        info_from_debug_set=canvas.mk.stats.debug_data_count;
335
                                                    }
189
                                        start_playing(""+(ubatt/10));
336
                                                play("volts");
190
                                        wait_for_end();
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");
-
 
368
                                                                break;
191
                                       
369
                                                            default:
192
                                        if((ubatt%10)!=0)
-
 
193
                                            {
-
 
194
                                                start_playing("komma");
370
                                                                play(canvas.mk.stats.flying_time()%60);
Line 195... Line 371...
195
                                                wait_for_end();
371
                                                                play("minutes");
Line 207... Line 383...
207
                                        if (last_alt==-1) last_alt=canvas.mk.Alt();
383
                                                if (last_alt==-1) last_alt=canvas.mk.Alt();
Line 208... Line 384...
208
 
384
                                               
209
                               
385
                                               
210
                                        if (last_alt>canvas.mk.Alt()+canvas.settings.altsteps)
-
 
211
                                            {
386
                                                if (last_alt>canvas.mk.Alt()+canvas.settings.altsteps)
212
                                                //                                              start_playing("down");
-
 
-
 
387
                                                    {
213
                                                play_down();
388
                                                        play("down");
214
                                                wait_for_end();
389
                                                       
215
                                                last_alt-=canvas.settings.altsteps;
390
                                                        last_alt-=canvas.settings.altsteps;
Line 216... Line 391...
216
                                            }
391
                                                    }
217
                                        if (last_alt<canvas.mk.Alt()-canvas.settings.altsteps)
-
 
218
                                           
392
                                                if (last_alt<canvas.mk.Alt()-canvas.settings.altsteps)
219
                                            {
-
 
-
 
393
                                                   
220
                                                //start_playing("up");
394
                                                    {
221
                                                play_up();
395
                                                        play("up");
222
                                                wait_for_end();
396
                                                       
223
                                                last_alt+=canvas.settings.altsteps;
397
                                                        last_alt+=canvas.settings.altsteps;
224
                                            }
398
                                                    }
225
                                    }
399
                                            }
-
 
400
                                        else
-
 
401
                                            last_alt=-1;
-
 
402
                                    }
-
 
403
                            }
-
 
404
                            }
-
 
405
                        else
-
 
406
                            {
-
 
407
                                if (!disconn_told)
Line 226... Line 408...
226
                                else
408
                                    play("disconnected");
-
 
409
                                conn_told=false;
Line 227... Line 410...
227
                                    last_alt=-1;
410
                                disconn_told=true;
228
                            }
411
                               
Line 229... Line 412...
229
       
412
                            }