Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Add Missing JNI docs from C++ (NFC) #6139

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,22 @@ public static native Transform3d estimatePose(
double cx,
double cy);

/**
* Generates a RawFrame containing the apriltag with the id with family 16h5 passed in.
*
* @param frameObj generated frame (output parameter).
* @param frame raw frame handle
* @param id id
*/
public static native void generate16h5AprilTagImage(RawFrame frameObj, long frame, int id);

/**
* Generates a RawFrame containing the apriltag with the id with family 36h11 passed in.
*
* @param frameObj generated frame (output parameter).
* @param frame raw frame handle
* @param id id
*/
public static native void generate36h11AprilTagImage(RawFrame frameObj, long frame, int id);

/** Utility class. */
Expand Down
24 changes: 24 additions & 0 deletions hal/src/main/java/edu/wpi/first/hal/AnalogJNI.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ public interface AnalogTriggerType {
*/
public static native boolean checkAnalogInputChannel(int channel);

/**
* Checks that the analog output channel number is valid.
*
* <p>Verifies that the analog channel number is one of the legal channel numbers. Channel numbers
* are 0-based.
*
* @param channel The analog output channel number.
* @return Analog channel is valid
* @see "HAL_CheckAnalogOutputChannel"
*/
public static native boolean checkAnalogOutputChannel(int channel);

/**
Expand All @@ -95,8 +105,22 @@ public interface AnalogTriggerType {
*/
public static native void setAnalogInputSimDevice(int handle, int device);

/**
* Sets an analog output value.
*
* @param portHandle the analog output handle
* @param voltage the voltage (0-5v) to output
* @see "HAL_SetAnalogOutput"
*/
public static native void setAnalogOutput(int portHandle, double voltage);

/**
* Gets the current analog output value.
*
* @param portHandle the analog output handle
* @return the current output voltage (0-5v)
* @see "HAL_GetAnalogOutput"
*/
public static native double getAnalogOutput(int portHandle);

/**
Expand Down
119 changes: 119 additions & 0 deletions hal/src/main/java/edu/wpi/first/hal/PWMJNI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,41 @@
package edu.wpi.first.hal;

public class PWMJNI extends DIOJNI {
/**
* Initializes a PWM port.
*
* @param halPortHandle the port to initialize
* @return the created pwm handle
*/
public static native int initializePWMPort(int halPortHandle);

/**
* Checks if a pwm channel is valid.
*
* @param channel the channel to check
* @return true if the channel is valid, otherwise false
*/
public static native boolean checkPWMChannel(int channel);

/**
* Frees a PWM port.
*
* @param pwmPortHandle the pwm handle
*/
public static native void freePWMPort(int pwmPortHandle);

/**
* Sets the configuration settings for the PWM channel.
*
* <p>All values are in microseconds.
*
* @param pwmPortHandle the PWM handle
* @param maxPwm the maximum PWM value
* @param deadbandMaxPwm the high range of the center deadband
* @param centerPwm the center PWM value
* @param deadbandMinPwm the low range of the center deadband
* @param minPwm the minimum PWM value
*/
public static native void setPWMConfigMicroseconds(
int pwmPortHandle,
int maxPwm,
Expand All @@ -19,30 +48,120 @@ public static native void setPWMConfigMicroseconds(
int deadbandMinPwm,
int minPwm);

/**
* Gets the pwm configuration settings for the PWM channel.
*
* <p>Values are in microseconds.
*
* @param pwmPortHandle the PWM handle
* @return the pwm configuration settings
*/
public static native PWMConfigDataResult getPWMConfigMicroseconds(int pwmPortHandle);

/**
* Sets if the FPGA should output the center value if the input value is within the deadband.
*
* @param pwmPortHandle the PWM handle
* @param eliminateDeadband true to eliminate deadband, otherwise false
*/
public static native void setPWMEliminateDeadband(int pwmPortHandle, boolean eliminateDeadband);

/**
* Gets the current eliminate deadband value.
*
* @param pwmPortHandle the PWM handle
* @return true if set, otherwise false
*/
public static native boolean getPWMEliminateDeadband(int pwmPortHandle);

/**
* Sets a PWM channel to the desired pulse width in microseconds.
*
* @param pwmPortHandle the PWM handle
* @param microsecondPulseTime the PWM value to set
*/
public static native void setPulseTimeMicroseconds(int pwmPortHandle, int microsecondPulseTime);

/**
* Sets a PWM channel to the desired scaled value.
*
* <p>The values range from -1 to 1 and the period is controlled by the PWM Period and MinHigh
* registers.
*
* @param pwmPortHandle the PWM handle
* @param speed the scaled PWM value to set
*/
public static native void setPWMSpeed(int pwmPortHandle, double speed);

/**
* Sets a PWM channel to the desired position value.
*
* <p>The values range from 0 to 1 and the period is controlled by the PWM Period and MinHigh
* registers.
*
* @param pwmPortHandle the PWM handle
* @param position the positional PWM value to set
*/
public static native void setPWMPosition(int pwmPortHandle, double position);

/**
* Gets the current microsecond pulse time from a PWM channel.
*
* @param pwmPortHandle the PWM handle
* @return the current PWM microsecond pulse time
*/
public static native int getPulseTimeMicroseconds(int pwmPortHandle);

/**
* Gets a scaled value from a PWM channel.
*
* <p>The values range from -1 to 1.
*
* @param pwmPortHandle the PWM handle
* @return the current speed PWM value
*/
public static native double getPWMSpeed(int pwmPortHandle);

/**
* Gets a position value from a PWM channel.
*
* <p>The values range from 0 to 1.
*
* @param pwmPortHandle the PWM handle
* @return the current positional PWM value
*/
public static native double getPWMPosition(int pwmPortHandle);

/**
* Sets a PWM channel to be disabled.
*
* <p>The channel is disabled until the next time it is set. Note this is different from just
* setting a 0 speed, as this will actively stop all signaling on the channel.
*
* @param pwmPortHandle the PWM handle.
*/
public static native void setPWMDisabled(int pwmPortHandle);

/**
* Forces a PWM signal to go to 0 temporarily.
*
* @param pwmPortHandle the PWM handle.
*/
public static native void latchPWMZero(int pwmPortHandle);

/**
* Sets the PWM output to be a continuous high signal while enabled.
*
* @param pwmPortHandle the PWM handle.
*/
public static native void setAlwaysHighMode(int pwmPortHandle);

/**
* Sets how how often the PWM signal is squelched, thus scaling the period.
*
* @param pwmPortHandle the PWM handle.
* @param squelchMask the 2-bit mask of outputs to squelch
*/
public static native void setPWMPeriodScale(int pwmPortHandle, int squelchMask);

/** Utility class. */
Expand Down
13 changes: 13 additions & 0 deletions wpinet/src/main/java/edu/wpi/first/net/WPINetJNI.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,21 @@ public static synchronized void forceLoad() throws IOException {
libraryLoaded = true;
}

/**
* Forward a local TCP port to a remote host and port. Note that local ports less than 1024 won't
* work as a normal user.
*
* @param port local port number
* @param remoteHost remote IP address / DNS name
* @param remotePort remote port number
*/
public static native void addPortForwarder(int port, String remoteHost, int remotePort);

/**
* Stop TCP forwarding on a port.
*
* @param port local port number
*/
public static native void removePortForwarder(int port);

public static native int createMulticastServiceAnnouncer(
Expand Down
49 changes: 49 additions & 0 deletions wpiutil/src/main/java/edu/wpi/first/util/WPIUtilJNI.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,67 @@ public static synchronized void forceLoad() throws IOException {

public static native long getSystemTime();

/**
* Creates an event. Events have binary state (signaled or not signaled) and may be either
* automatically reset or manually reset. Automatic-reset events go to non-signaled state when a
* WaitForObject is woken up by the event; manual-reset events require ResetEvent() to be called
* to set the event to non-signaled state; if ResetEvent() is not called, any waiter on that event
* will immediately wake when called.
*
* @param manualReset true for manual reset, false for automatic reset
* @param initialState true to make the event initially in signaled state
* @return Event handle
*/
public static native int createEvent(boolean manualReset, boolean initialState);

/**
* Destroys an event. Destruction wakes up any waiters.
*
* @param eventHandle event handle
*/
public static native void destroyEvent(int eventHandle);

/**
* Sets an event to signaled state.
*
* @param eventHandle event handle
*/
public static native void setEvent(int eventHandle);

/**
* Sets an event to non-signaled state.
*
* @param eventHandle event handle
*/
public static native void resetEvent(int eventHandle);

/**
* Creates a semaphore. Semaphores keep an internal counter. Releasing the semaphore increases the
* count. A semaphore with a non-zero count is considered signaled. When a waiter wakes up it
* atomically decrements the count by 1. This is generally useful in a single-supplier,
* multiple-consumer scenario.
*
* @param initialCount initial value for the semaphore's internal counter
* @param maximumCount maximum value for the samephore's internal counter
* @return Semaphore handle
*/
public static native int createSemaphore(int initialCount, int maximumCount);

/**
* Destroys a semaphore. Destruction wakes up any waiters.
*
* @param semHandle semaphore handle
*/
public static native void destroySemaphore(int semHandle);

/**
* Releases N counts of a semaphore.
*
* @param semHandle semaphore handle
* @param releaseCount amount to add to semaphore's internal counter; must be positive
* @return True on successful release, false on failure (e.g. release count would exceed maximum
* value, or handle invalid)
*/
public static native boolean releaseSemaphore(int semHandle, int releaseCount);

static native long allocateRawFrame();
Expand Down
Loading