Hello,
>>
>
> Thank you for your response. I really appreciate the good support that 
> this IOIO community has.
>
> 1.) So it is okay to assume if the wave is consistent that the value 
> produced by Positive mode would be 50% more than the value of 
> getFrequency()?
>

    2.) I added threads as shown below, however, when I unhook my cable 
from pin1 numbers continue to display on my screen well after disconnect 
and it eventually sets to 0. Also the numbers appear to be displaying 
rapidly almost like my timer task isn't working properly. I have placed a 
sleep at the bottom of the loop().

3.) My second pulse input doesn't seem to be doing anything as nothing is 
being displayed. Only the first pulse input channel seems to be working. Am 
I doing the threading incorrectly?

 class IOIOThread extends AbstractIOIOActivity.IOIOThread {
 private PulseInput pulse1;
private PulseInput pulse2;
@Override
public void setup() throws ConnectionLostException {
try {
 pulse1 = ioio_.openPulseInput(new DigitalInput.Spec(1), 
ClockRate.RATE_62KHz,  PulseMode.POSITIVE, false);
pulse2 = ioio_.openPulseInput(new DigitalInput.Spec(2), 
ClockRate.RATE_62KHz,  PulseMode.POSITIVE, false); 
 } catch (ConnectionLostException e) {
throw e;
}
}

@Override
public void loop() throws ConnectionLostException, InterruptedException {
 final TimerTask t = new TimerTask() {
  public void run() {
     interrupt();
  }
};
Timer timer = new Timer();
timer.schedule(t, 1000); 


Thread thread1 = new Thread() {
    @Override
    public void run() {
        while(true) {

try {
try {
freqHz1 = 1.0f / pulse1.waitPulseGetDuration();
} catch (ConnectionLostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
 t.cancel();
} 
catch (InterruptedException ex) {
freqHz1 = 0;
 } 
  setText1(freqHz1);

}
    }
};

thread1.start();




Thread thread2 = new Thread() {
    @Override
    public void run() {
        while(true) {

try {
try {
freqHz2 = 1.0f / pulse2.waitPulseGetDuration();
} catch (ConnectionLostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
 t.cancel();
} 
catch (InterruptedException ex) {
freqHz2 = 0;
 } 
  setText1(freqHz2);

}
    }
};

thread2.start();

sleep(1000);
 }
 }
 @Override
protected AbstractIOIOActivity.IOIOThread createIOIOThread() {
return new IOIOThread();
}

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