Thanks again. I've edited this in my IDE, however on the .start() and 
.join() it says for example "The method start() is undefined for the type 
SimpleDigitalInputActivity.IOIOThread.PulseInputThread"

I'm also getting a similar message for waitPulseGetFrequency(). "The method 
waitPulseGetFrequency() is undefined for the type PulseInput." I couldn't 
find it anywhere in the PulseInput.java library file.


class IOIOThread extends AbstractIOIOActivity.IOIOThread {
> private PulseInput input_ =null;
>   private Timer timer_ = null;
>   private float last_;
>
 

> class  PulseInputThread{
>
 

>  PulseInputThread  thread1_;
>  PulseInputThread  thread2_;
>
> public PulseInputThread(PulseInput input,Timer timer) {
>  input_ = input;
>     timer_ = timer;
> }
>
> Thread thread = new Thread() {
>  
>   private synchronized void read() throws ConnectionLostException {
>     TimerTask task = new TimerTask() {public void run() {
>      interrupt();
>   }};
>   
>     timer_.schedule(task, 1000);
>     try {
>       last_ = input_.waitPulseGetFrequency();
>       task.cancel();
>     } catch (InterruptedException e) {
>       last_ = 0;
>     }
>   }
>  
>   public void run() {
>     try {
>       while (true) {
>         read();
>         try {
> Thread.sleep(1000);
> } catch (InterruptedException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>       }
>     } catch (ConnectionLostException e) {
>      e.printStackTrace();
>     }
>   }
>  
>
> public void setup() throws ConnectionLostException {
> PulseInput  input1_ = ioio_.openPulseInput(new DigitalInput.Spec(1), 
> ClockRate.RATE_62KHz,  PulseMode.FREQ, false);
> PulseInput  input2_ = ioio_.openPulseInput(new DigitalInput.Spec(2), 
> ClockRate.RATE_62KHz,  PulseMode.FREQ, false);;
>
>   Timer t = new Timer();
>    thread1_ = new PulseInputThread(input1_, t);
>    thread2_ = new PulseInputThread(input2_, t);
>   thread1_.start();
>   thread2_.start();
> }
>  
> public void loop() throws ConnectionLostException, InterruptedException {
>   setText1(thread1_.getLastReading());
>   setText2(thread2_.getLastReading());
>
> }
>
> public void disconnected() {
>    try {
>      thread1_.join();
>      thread2_.join();
>    } catch (InterruptedException e) {
>    }
>
> }
>
> };
>
>
>  public synchronized float getLastReading() {
>  return last_;
> }
>  
> }
>  }
>  

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to