I'm using a timer task as suggested by an earlier post to set my frequency from PulseInput back to zero when the frequency is zero or a pin is disconnected. (Actually using 1/waitPulseGetDuration() to calculate the frequency. I am having two issues.
1) I have a 14 Hz signal from a 555 to test the accuracy. It works fine with the getFrequency() method and the Pulse Mode is set to freq. But when I switch to pulse mode positive and use 1/waitPulseGetDuration() it always reads 21 instead of 14. I'm not using any scaling. 2) Also as you can see in this screen cast the top line cycles really fast even though I have the timer task at 1 second. It does however go back to zero as I want when I disconnect. The next line however displays the data every second as I intended with the 1 second timer task, BUT it never goes back to zero when unplugged. Please see this video: http://youtu.be/QOSpOELQgx8 Here is my code: @Override public void loop() throws ConnectionLostException { float freqHz1 =0; float freqHz2=0; float freqHz3 =0 ; float freqHz4 =0; float freqHz5 =0; float freqHz6=0; TimerTask t = new TimerTask() { public void run() { interrupt(); } }; Timer timer = new Timer(); timer.schedule(t, 1000); try { freqHz1 = 1.0f / pulse1.waitPulseGetDuration(); t.cancel(); } catch (InterruptedException ex) { freqHz1 = 0; } try { freqHz2 = 1.0f / pulse2.waitPulseGetDuration(); } catch (InterruptedException ex) { freqHz2 = 0; } setText(freqHz1, freqHz2, freqHz3, freqHz4, freqHz5, freqHz6); } } So in summary how do I make the first line only display in 1 second increments? How do I keep the second line to keep displaying in 1 second increments? And why does the second line not go to zero when interrupted? Thanks! -- 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.
