Class PigpioSocket

java.lang.Object
org.photonvision.common.hardware.GPIO.pi.PigpioSocket

public class PigpioSocket extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates and starts a socket connection to a pigpio daemon on localhost
    PigpioSocket(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 Type
    Method
    Description
    void
    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 level
    void
    Terminates the connection to the pigpio daemon
    void
    gpioWrite(int pin, boolean value)
    Write the GPIO level
    void
    hardwarePWM(int pin, int pwmFrequency, int pwmDuty)
    Starts hardware PWM on a GPIO at the specified frequency and dutycycle
    void
    Reconnects to the pigpio daemon
    void
    Clears all waveforms and any data added by calls to waveAddGeneric(ArrayList)
    int
    Creates a waveform from the data provided by the prior calls to waveAddGeneric(ArrayList) Upon success a wave ID greater than or equal to 0 is returned
    void
    waveDelete(int waveId)
    Deletes the waveform with specified wave ID
    int
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PigpioSocket

      public PigpioSocket()
      Creates and starts a socket connection to a pigpio daemon on localhost
    • PigpioSocket

      public PigpioSocket(String addr, int port)
      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 daemon
      port - Port of remote pigpio daemon
  • Method Details

    • reconnect

      public void reconnect() throws PigpioException
      Reconnects to the pigpio daemon
      Throws:
      PigpioException - on failure
    • gpioTerminate

      public void gpioTerminate() throws PigpioException
      Terminates the connection to the pigpio daemon
      Throws:
      PigpioException - on failure
    • gpioRead

      public boolean gpioRead(int pin) throws PigpioException
      Read the GPIO level
      Parameters:
      pin - Pin to read from
      Returns:
      Value of the pin
      Throws:
      PigpioException - on failure
    • gpioWrite

      public void gpioWrite(int pin, boolean value) throws PigpioException
      Write the GPIO level
      Parameters:
      pin - Pin to write to
      value - Value to write
      Throws:
      PigpioException - on failure
    • waveClear

      public void waveClear() throws PigpioException
      Clears all waveforms and any data added by calls to waveAddGeneric(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 milliseconds
      blinks - Number of times to pulse. -1 for repeat
      pins - Pins to pulse
      Throws:
      PigpioException - on failure
    • waveTxStop

      public boolean waveTxStop() throws PigpioException
      Stops the transmission of the current waveform
      Returns:
      success
      Throws:
      PigpioException - on failure
    • waveCreate

      public int waveCreate() throws PigpioException
      Creates a waveform from the data provided by the prior calls to waveAddGeneric(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

      public void waveDelete(int waveId) throws PigpioException
      Deletes the waveform with specified wave ID
      Parameters:
      waveId - ID of the waveform to delete
      Throws:
      PigpioException - on failure
    • waveSendOnce

      public int waveSendOnce(int waveId) throws PigpioException
      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

      public int waveSendRepeat(int waveId) throws PigpioException
      Transmits the waveform with specified wave ID. The waveform cycles until cancelled (either by the sending of a new waveform or waveTxStop()
      Parameters:
      waveId - ID of the waveform to transmit
      Returns:
      The number of DMA control blocks in the waveform
      Throws:
      PigpioException - on failure
    • hardwarePWM

      public void hardwarePWM(int pin, int pwmFrequency, int pwmDuty) throws PigpioException
      Starts hardware PWM on a GPIO at the specified frequency and dutycycle
      Parameters:
      pin - GPIO pin to start PWM on
      pwmFrequency - Frequency to run at (1Hz-125MHz). Frequencies above 30MHz are unlikely to work
      pwmDuty - Duty cycle to run at (0-1,000,000)
      Throws:
      PigpioException - on failure