Class PigpioSocket
java.lang.Object
org.photonvision.common.hardware.GPIO.pi.PigpioSocket
-
Constructor Summary
ConstructorDescriptionCreates and starts a socket connection to a pigpio daemon on localhostPigpioSocket
(String addr, int port) Creates and starts a socket connection to a pigpio daemon on a remote host with the specified address and port -
Method Summary
Modifier and TypeMethodDescriptionvoid
generateAndSendWaveform
(int pulseTimeMillis, int blinks, int... pins) Generates and sends a waveform to the given pins with the specified parameters.boolean
gpioRead
(int pin) Read the GPIO levelvoid
Terminates the connection to the pigpio daemonvoid
gpioWrite
(int pin, boolean value) Write the GPIO levelvoid
hardwarePWM
(int pin, int pwmFrequency, int pwmDuty) Starts hardware PWM on a GPIO at the specified frequency and dutycyclevoid
Reconnects to the pigpio daemonvoid
Clears all waveforms and any data added by calls towaveAddGeneric(ArrayList)
int
Creates a waveform from the data provided by the prior calls towaveAddGeneric(ArrayList)
Upon success a wave ID greater than or equal to 0 is returnedvoid
waveDelete
(int waveId) Deletes the waveform with specified wave IDint
waveSendOnce
(int waveId) Transmits the waveform with specified wave ID.int
waveSendRepeat
(int waveId) Transmits the waveform with specified wave ID.boolean
Stops the transmission of the current waveform
-
Constructor Details
-
PigpioSocket
public PigpioSocket()Creates and starts a socket connection to a pigpio daemon on localhost -
PigpioSocket
Creates and starts a socket connection to a pigpio daemon on a remote host with the specified address and port- Parameters:
addr
- Address of remote pigpio daemonport
- Port of remote pigpio daemon
-
-
Method Details
-
reconnect
Reconnects to the pigpio daemon- Throws:
PigpioException
- on failure
-
gpioTerminate
Terminates the connection to the pigpio daemon- Throws:
PigpioException
- on failure
-
gpioRead
Read the GPIO level- Parameters:
pin
- Pin to read from- Returns:
- Value of the pin
- Throws:
PigpioException
- on failure
-
gpioWrite
Write the GPIO level- Parameters:
pin
- Pin to write tovalue
- Value to write- Throws:
PigpioException
- on failure
-
waveClear
Clears all waveforms and any data added by calls towaveAddGeneric(ArrayList)
- Throws:
PigpioException
- on failure
-
generateAndSendWaveform
public void generateAndSendWaveform(int pulseTimeMillis, int blinks, int... pins) throws PigpioException Generates and sends a waveform to the given pins with the specified parameters.- Parameters:
pulseTimeMillis
- Pulse length in millisecondsblinks
- Number of times to pulse. -1 for repeatpins
- Pins to pulse- Throws:
PigpioException
- on failure
-
waveTxStop
Stops the transmission of the current waveform- Returns:
- success
- Throws:
PigpioException
- on failure
-
waveCreate
Creates a waveform from the data provided by the prior calls towaveAddGeneric(ArrayList)
Upon success a wave ID greater than or equal to 0 is returned- Returns:
- ID of the created waveform
- Throws:
PigpioException
- on failure
-
waveDelete
Deletes the waveform with specified wave ID- Parameters:
waveId
- ID of the waveform to delete- Throws:
PigpioException
- on failure
-
waveSendOnce
Transmits the waveform with specified wave ID. The waveform is sent once- Parameters:
waveId
- ID of the waveform to transmit- Returns:
- The number of DMA control blocks in the waveform
- Throws:
PigpioException
- on failure
-
waveSendRepeat
Transmits the waveform with specified wave ID. The waveform cycles until cancelled (either by the sending of a new waveform orwaveTxStop()
- Parameters:
waveId
- ID of the waveform to transmit- Returns:
- The number of DMA control blocks in the waveform
- Throws:
PigpioException
- on failure
-
hardwarePWM
Starts hardware PWM on a GPIO at the specified frequency and dutycycle- Parameters:
pin
- GPIO pin to start PWM onpwmFrequency
- Frequency to run at (1Hz-125MHz). Frequencies above 30MHz are unlikely to workpwmDuty
- Duty cycle to run at (0-1,000,000)- Throws:
PigpioException
- on failure
-