AnalogInput: Remove byte buffer usage.

This commit is contained in:
Peter Johnson
2017-11-15 22:09:59 -08:00
parent 9021b37fd2
commit b93aa176d6
3 changed files with 12 additions and 26 deletions

View File

@@ -7,9 +7,6 @@
package edu.wpi.first.wpilibj;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.wpilibj.hal.AnalogJNI;
@@ -289,15 +286,8 @@ public class AnalogInput extends SensorBase implements PIDSource, LiveWindowSend
throw new IllegalArgumentException(
"Channel " + m_channel + " is not an accumulator channel.");
}
ByteBuffer value = ByteBuffer.allocateDirect(8);
// set the byte order
value.order(ByteOrder.LITTLE_ENDIAN);
ByteBuffer count = ByteBuffer.allocateDirect(8);
// set the byte order
count.order(ByteOrder.LITTLE_ENDIAN);
AnalogJNI.getAccumulatorOutput(m_port, value.asLongBuffer(), count.asLongBuffer());
result.value = value.asLongBuffer().get(0) + m_accumulatorOffset;
result.count = count.asLongBuffer().get(0);
AnalogJNI.getAccumulatorOutput(m_port, result);
result.value += m_accumulatorOffset;
}
/**

View File

@@ -7,8 +7,8 @@
package edu.wpi.first.wpilibj.hal;
import edu.wpi.first.wpilibj.AccumulatorResult;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
public class AnalogJNI extends JNIWrapper {
/**
@@ -91,8 +91,7 @@ public class AnalogJNI extends JNIWrapper {
public static native int getAccumulatorCount(int analogPortHandle);
public static native void getAccumulatorOutput(int analogPortHandle, LongBuffer value,
LongBuffer count);
public static native void getAccumulatorOutput(int analogPortHandle, AccumulatorResult result);
public static native int initializeAnalogTrigger(int analogInputHandle, IntBuffer index);