mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Added support for digital and analog IO pins on the MXP
Change-Id: I3a4e14ceab885d19a615d6cd45f22a2250ad2856
This commit is contained in:
@@ -76,7 +76,7 @@ public class AnalogChannel extends SensorBase implements PIDSource,
|
||||
+ " on module " + m_moduleNumber
|
||||
+ " cannot be allocated. Module is not present.");
|
||||
}
|
||||
if (AnalogJNI.checkAnalogChannel(channel) == 0) {
|
||||
if (AnalogJNI.checkAnalogInputChannel(channel) == 0) {
|
||||
throw new AllocationException("Analog channel " + m_channel
|
||||
+ " on module " + m_moduleNumber
|
||||
+ " cannot be allocated. Channel is not present.");
|
||||
@@ -94,7 +94,7 @@ public class AnalogChannel extends SensorBase implements PIDSource,
|
||||
// set the byte order
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
// XXX: Uncomment when Analog has been fixed
|
||||
m_port = AnalogJNI.initializeAnalogPort(port_pointer, status.asIntBuffer());
|
||||
m_port = AnalogJNI.initializeAnalogInputPort(port_pointer, status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
|
||||
LiveWindow.addSensor("Analog", moduleNumber, channel, this);
|
||||
|
||||
@@ -28,7 +28,7 @@ public abstract class SensorBase { // TODO: Refactor
|
||||
/**
|
||||
* Number of digital channels per digital sidecar
|
||||
*/
|
||||
public static final int kDigitalChannels = 10;
|
||||
public static final int kDigitalChannels = 20;
|
||||
/**
|
||||
* Number of digital modules
|
||||
* XXX: This number is incorrect. We need to find the correct number.
|
||||
@@ -53,7 +53,7 @@ public abstract class SensorBase { // TODO: Refactor
|
||||
/**
|
||||
* Number of PWM channels per sidecar
|
||||
*/
|
||||
public static final int kPwmChannels = 10;
|
||||
public static final int kPwmChannels = 20;
|
||||
/**
|
||||
* Number of relay channels per sidecar
|
||||
*/
|
||||
|
||||
@@ -20,9 +20,13 @@ public class AnalogJNI extends JNIWrapper {
|
||||
public static final int kFallingPulse = 3;
|
||||
};
|
||||
|
||||
public static native ByteBuffer initializeAnalogPort(ByteBuffer port_pointer, IntBuffer status);
|
||||
public static native ByteBuffer initializeAnalogInputPort(ByteBuffer port_pointer, IntBuffer status);
|
||||
public static native ByteBuffer initializeAnalogOutputPort(ByteBuffer port_pointer, IntBuffer status);
|
||||
public static native byte checkAnalogModule(byte module);
|
||||
public static native byte checkAnalogChannel(int pin);
|
||||
public static native byte checkAnalogInputChannel(int pin);
|
||||
public static native byte checkAnalogOutputChannel(int pin);
|
||||
public static native void setAnalogOutput(ByteBuffer port_pointer, double voltage, IntBuffer status);
|
||||
public static native double getAnalogOutput(ByteBuffer port_pointer, IntBuffer status);
|
||||
public static native void setAnalogSampleRate(double samplesPerSecond, IntBuffer status);
|
||||
public static native double getAnalogSampleRate(IntBuffer status);
|
||||
public static native void setAnalogSampleRateWithModule(byte module, double samplesPerSecond, IntBuffer status);
|
||||
|
||||
Reference in New Issue
Block a user