mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Add AddressableLED simulation support
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
package edu.wpi.first.hal.sim;
|
||||
|
||||
import edu.wpi.first.hal.sim.mockdata.AddressableLEDDataJNI;
|
||||
|
||||
public class AddressableLEDSim {
|
||||
private final int m_index;
|
||||
|
||||
public AddressableLEDSim(int index) {
|
||||
m_index = index;
|
||||
}
|
||||
|
||||
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
|
||||
int uid = AddressableLEDDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
|
||||
return new CallbackStore(m_index, uid, AddressableLEDDataJNI::cancelInitializedCallback);
|
||||
}
|
||||
public boolean getInitialized() {
|
||||
return AddressableLEDDataJNI.getInitialized(m_index);
|
||||
}
|
||||
public void setInitialized(boolean initialized) {
|
||||
AddressableLEDDataJNI.setInitialized(m_index, initialized);
|
||||
}
|
||||
|
||||
public CallbackStore registerOutputPortCallback(NotifyCallback callback, boolean initialNotify) {
|
||||
int uid = AddressableLEDDataJNI.registerOutputPortCallback(m_index, callback, initialNotify);
|
||||
return new CallbackStore(m_index, uid, AddressableLEDDataJNI::cancelOutputPortCallback);
|
||||
}
|
||||
public int getOutputPort() {
|
||||
return AddressableLEDDataJNI.getOutputPort(m_index);
|
||||
}
|
||||
public void setOutputPort(int outputPort) {
|
||||
AddressableLEDDataJNI.setOutputPort(m_index, outputPort);
|
||||
}
|
||||
|
||||
public CallbackStore registerLengthCallback(NotifyCallback callback, boolean initialNotify) {
|
||||
int uid = AddressableLEDDataJNI.registerLengthCallback(m_index, callback, initialNotify);
|
||||
return new CallbackStore(m_index, uid, AddressableLEDDataJNI::cancelLengthCallback);
|
||||
}
|
||||
public int getLength() {
|
||||
return AddressableLEDDataJNI.getLength(m_index);
|
||||
}
|
||||
public void setLength(int length) {
|
||||
AddressableLEDDataJNI.setLength(m_index, length);
|
||||
}
|
||||
|
||||
public CallbackStore registerRunningCallback(NotifyCallback callback, boolean initialNotify) {
|
||||
int uid = AddressableLEDDataJNI.registerRunningCallback(m_index, callback, initialNotify);
|
||||
return new CallbackStore(m_index, uid, AddressableLEDDataJNI::cancelRunningCallback);
|
||||
}
|
||||
public boolean getRunning() {
|
||||
return AddressableLEDDataJNI.getRunning(m_index);
|
||||
}
|
||||
public void setRunning(boolean running) {
|
||||
AddressableLEDDataJNI.setRunning(m_index, running);
|
||||
}
|
||||
|
||||
public CallbackStore registerDataCallback(ConstBufferCallback callback) {
|
||||
int uid = AddressableLEDDataJNI.registerDataCallback(m_index, callback);
|
||||
return new CallbackStore(m_index, uid, AddressableLEDDataJNI::cancelDataCallback);
|
||||
}
|
||||
public byte[] getData() {
|
||||
return AddressableLEDDataJNI.getData(m_index);
|
||||
}
|
||||
public void setData(byte[] data) {
|
||||
AddressableLEDDataJNI.setData(m_index, data);
|
||||
}
|
||||
|
||||
public void resetData() {
|
||||
AddressableLEDDataJNI.resetData(m_index);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
package edu.wpi.first.hal.sim.mockdata;
|
||||
|
||||
import edu.wpi.first.hal.sim.ConstBufferCallback;
|
||||
import edu.wpi.first.hal.sim.NotifyCallback;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class AddressableLEDDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native void cancelInitializedCallback(int index, int uid);
|
||||
public static native boolean getInitialized(int index);
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native int registerOutputPortCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native void cancelOutputPortCallback(int index, int uid);
|
||||
public static native int getOutputPort(int index);
|
||||
public static native void setOutputPort(int index, int outputPort);
|
||||
|
||||
public static native int registerLengthCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native void cancelLengthCallback(int index, int uid);
|
||||
public static native int getLength(int index);
|
||||
public static native void setLength(int index, int length);
|
||||
|
||||
public static native int registerRunningCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native void cancelRunningCallback(int index, int uid);
|
||||
public static native boolean getRunning(int index);
|
||||
public static native void setRunning(int index, boolean running);
|
||||
|
||||
public static native int registerDataCallback(int index, ConstBufferCallback callback);
|
||||
public static native void cancelDataCallback(int index, int uid);
|
||||
public static native byte[] getData(int index);
|
||||
public static native void setData(int index, byte[] data);
|
||||
|
||||
public static native void resetData(int index);
|
||||
}
|
||||
Reference in New Issue
Block a user