Hello,
I've created a PulseInput instance and opened it via
@Override
protected void setup() throws ConnectionLostException {
Log.i("Looper", "setup()");
mNumberFormat.setMaximumFractionDigits(2);
mainLED = ioio_.openDigitalOutput(IOIO.LED_PIN, true);
for (int zone=0;zone < ZONE_COUNT; zone++) {
zoneControl[zone]=ioio_.openDigitalOutput(ZONE_PIN_MAP[zone]);
}
for (int relay=0;relay < RELAY_COUNT; relay++) {
relays[relay]=ioio_.openDigitalOutput(RELAY_PIN_MAP[relay]);
}
for (int sensor=0;sensor < SENSOR_COUNT; sensor++) {
sensors[sensor] =
ioio_.openAnalogInput(SENSOR_PIN_MAP[sensor]);
}
pulse = ioio_.openPulseInput(45, PulseInput.PulseMode.FREQ);
}
I appear to be getting a valid open instance of pulse... however when I try
to get a pulse measurement in the looper, I keep getting
ConnectionLostException. Here is where I'm trying to read that value...
@Override
public void loop() throws ConnectionLostException {
try {
mainLED.write(!bToggleSelected);
for (int zone = 0; zone < ZONE_COUNT; zone++) {
zoneControl[zone].write(!boolZone[zone]);
}
for (int relay = 0; relay < RELAY_COUNT; relay++) {
relays[relay].write(!boolRelay[relay]);
}
for (int sensor = 0; sensor < SENSOR_COUNT; sensor++) {
try {
sensorAverages[sensor][sensorAverageCountIndex] =
sensors[sensor].getVoltage();
} catch (InterruptedException e) {
sensorAverages[sensor][sensorAverageCountIndex] = 0;
}
if (sensorAverageCountIndex == (AVERAGE_SAMPLES - 1)) {
float total = 0;
for (int sample = 0; sample < AVERAGE_SAMPLES; sample++) {
total += sensorAverages[sensor][sample];
}
sensorAverageCountIndex = 0;
} else {
sensorAverageCountIndex++;
}
}
try {
float freqHz2 = pulse.getDuration();
} catch (InterruptedException e) {
}
}catch(ConnectionLostException p){
Log.e("CONNECTIONLOSTEXCEPTION", p.toString());
}
}
If I comment out the part where I attempt to get pulse.getDuration(), I
have no problems. In the big picture, what I'm trying to do is read water
meter pulses with frequency between 1 per 5 minutes up to 20 per minute.
Thanks for your time
--
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.