Package jpigpio
Interface JPigpio
- All Known Implementing Classes:
 CommonPigpio,Pigpio,PigpioSocket
public interface JPigpio
The exposed pigpio functions as Java methods.
- 
Field Summary
Fields Modifier and Type Field Description static intPI_ALT0static intPI_ALT1static intPI_ALT2static intPI_ALT3static intPI_ALT4static intPI_ALT5static intPI_CLEARstatic intPI_DEFAULT_DUTYCYCLE_RANGEstatic intPI_EITHER_EDGEstatic intPI_FALLING_EDGEstatic intPI_GPIO10static intPI_GPIO11static intPI_GPIO12static intPI_GPIO13static intPI_GPIO14static intPI_GPIO15static intPI_GPIO16static intPI_GPIO17static intPI_GPIO18static intPI_GPIO19static intPI_GPIO2static intPI_GPIO20static intPI_GPIO21static intPI_GPIO22static intPI_GPIO23static intPI_GPIO24static intPI_GPIO25static intPI_GPIO26static intPI_GPIO27static intPI_GPIO3static intPI_GPIO4static intPI_GPIO5static intPI_GPIO6static intPI_GPIO7static intPI_GPIO8static intPI_GPIO9static booleanPI_HIGHstatic intPI_HW_CLK_MAX_FREQstatic intPI_HW_CLK_MIN_FREQstatic intPI_HW_PWM_MAX_FREQstatic intPI_HW_PWM_MIN_FREQstatic intPI_HW_PWM_RANGEstatic intPI_I2C1_SCLstatic intPI_I2C1_SDAstatic intPI_INPUTstatic booleanPI_LOWstatic booleanPI_LSBFIRSTstatic intPI_MAX_DUTYCYCLE_RANGEstatic intPI_MAX_SERVO_PULSEWIDTHstatic intPI_MICROSECONDSstatic intPI_MILLISECONDSstatic intPI_MIN_DUTYCYCLE_RANGEstatic intPI_MIN_SERVO_PULSEWIDTHstatic booleanPI_MSBFIRSTstatic intPI_NO_TX_WAVEstatic intPI_NTFY_FLAGS_ALIVEstatic intPI_NTFY_FLAGS_GPIOstatic intPI_NTFY_FLAGS_WDOGstatic intPI_OFFstatic intPI_ONstatic intPI_OUTPUTstatic intPI_PUD_DOWNstatic intPI_PUD_OFFstatic intPI_PUD_UPstatic intPI_RISING_EDGEstatic intPI_SCRIPT_FAILEDstatic intPI_SCRIPT_HALTEDstatic intPI_SCRIPT_INITINGstatic intPI_SCRIPT_RUNNINGstatic intPI_SCRIPT_WAITINGstatic intPI_SECONDSstatic intPI_SERVO_OFFstatic intPI_SETstatic intPI_SPI_BAUD_125KHZstatic intPI_SPI_BAUD_1MHZstatic intPI_SPI_BAUD_250KHZstatic intPI_SPI_BAUD_2MHZstatic intPI_SPI_BAUD_4MHZstatic intPI_SPI_BAUD_500KHZstatic intPI_SPI_BAUD_8MHZstatic intPI_SPI_CE0static intPI_SPI_CE1static intPI_SPI_CHANNEL0static intPI_SPI_CHANNEL1static intPI_SPI_MISOstatic intPI_SPI_MODE0static intPI_SPI_MODE1static intPI_SPI_MODE2static intPI_SPI_MODE3static intPI_SPI_MOSIstatic intPI_SPI_SCLKstatic intPI_TIMEOUTstatic intPI_WAVE_MODE_ONE_SHOTstatic intPI_WAVE_MODE_ONE_SHOT_SYNCstatic intPI_WAVE_MODE_REPEATstatic intPI_WAVE_MODE_REPEAT_SYNCstatic intPI_WAVE_NOT_FOUND - 
Method Summary
Modifier and Type Method Description voidaddCallback(GPIOListener listener)Calls a user supplied function (a callback) whenever the specified GPIO edge is detected.
The user supplied callback receives three parameters, the GPIO, the level, and the tick.
If a user callback is not specified a default tally callback is provided which simply counts edges.longgetCurrentTick()intgetPWMDutycycle(int gpio)Returns the PWM dutycycle being used on the GPIO.
For normal PWM the dutycycle will be out of the defined range for the GPIO (see [*getPWMRange*]).
If a hardware clock is active on the GPIO the reported dutycycle will be 500000 (500k) out of 1000000 (1M).
If hardware PWM is active on the GPIO the reported dutycycle will be out of a 1000000 (1M).intgetPWMFrequency(int gpio)Returns the frequency of PWM being used on the GPIO.
Returns the frequency (in Hz) used for the GPIO.
For normal PWM the frequency will be that defined for the GPIO by [*setPWMFrequency*].
If a hardware clock is active on the GPIO the reported frequency will be that set by [*hardwareClock*].
If hardware PWM is active on the GPIO the reported frequency will be that set by [*hardwarePWM*].intgetPWMRange(int gpio)Returns the range of PWM values being used on the GPIO.
If a hardware clock or hardware PWM is active on the GPIO the reported range will be 1000000 (1M).intgetPWMRealRange(int gpio)Returns the real (underlying) range of PWM values being used on the GPIO.intgetServoPulseWidth(int gpio)Returns the servo pulsewidth being used on the GPIO.
voidgpioDelay(long delay)Delay for the specified number of microsecondsvoidgpioDelay(long delay, int type)intgpioGetMode(int gpio)Retrieve the mode of the given gpiovoidgpioInitialize()booleangpioRead(int gpio)Retrieve the state of the gpiovoidgpioServo(int gpio, int pulseWidth)Starts (500-2500) or stops (0) servo pulses on the GPIO.
The selected pulsewidth will continue to be transmitted until changed by a subsequent call to set_servo_pulsewidth.
The pulsewidths supported by servos varies and should probably be determined by experiment.voidgpioSetAlertFunc(int gpio, Alert alert)voidgpioSetMode(int gpio, int mode)Set the mode of the gpiovoidgpioSetPullUpDown(int gpio, int pud)voidgpioShiftOut(int gpioData, int gpioClock, boolean clockLevel, boolean bitOrder, byte value)Shift out a byte of data to a given pin.voidgpioShiftOut(int gpioData, int gpioClock, boolean bitOrder, byte value)Shift out a byte of data to a given pin.voidgpioShiftOut(GPIO gpioData, GPIO gpioClock, boolean clockLevel, boolean bitOrder, byte value)voidgpioShiftOut(GPIO gpioData, GPIO gpioClock, boolean bitOrder, byte value)voidgpioTerminate()Terminate the usage of the pigpio interfaces.longgpioTick()voidgpioTrigger(int gpio, long pulseLen, boolean level)Set the specified gpio to the level specified by level for the duration (in micro-sec) specified by pulseLen and then set the gpio back to not-level.voidgpioWrite(int gpio, boolean value)Set the state of the gpiolonggpioxPulseAndWait(int outGpio, int inGpio, long waitDuration, long pulseHoldDuration, boolean pulseLow)Pulse a named pin and then wait for a response on a different pin.voidi2cClose(int handle)Closes the I2C device associated with handle.inti2cOpen(int i2cBus, int i2cAddr)Returns a handle (>=0) for the device at the I2C bus address.
i2c_flags:= 0, no flags are currently defined.
Normally you would only use the [*i2c_**] functions if you are or will be connecting to the Pi over a network.inti2cReadDevice(int handle, byte[] data)Returns count bytes read from the raw device associated with handle.voidi2cWriteDevice(int handle, byte[] data)Writes the data bytes to the raw device associated with handle.voidnotifyBegin(int handle, int bits)Starts notifications on a handle.
The notification sends state changes for each GPIO whose corresponding bit in bits is set.voidnotifyClose(int handle)Stops notifications on a handle and releases the handle for reuse.intnotifyOpen()Returns a notification handle (>=0).
A notification is a method for being notified of GPIO state changes via a pipe.
Pipes are only accessible from the local machine so this function serves no purpose if you are using Python from a remote machine.voidnotifyPause(int handle)Pauses notifications on a handle.
Notifications for the handle are suspended until [*notify_begin*] is called again.
voidreconnect()Try reconnecting to pigpio.voidremoveCallback(GPIOListener listener)Remove callback listener object from notification thread.voidserialClose(int handle)Closes the serial device associated with handle.intserialDataAvailable(int handle)Returns the number of bytes available to be read from the device associated with handle.intserialOpen(java.lang.String tty, int baudRate, int flags)Returns a handle for the serial tty device opened at baud bits per second.
Normally you would only use the [*serial_**] functions if you are or will be connecting to the Pi over a network.byte[]serialRead(int handle, int count)Reads up to count bytes from the device associated with handle.
The returned value is a tuple of the number of bytes read and a bytearray containing the bytes.byteserialReadByte(int handle)Returns a single byte from the device associated with handle.voidserialWrite(int handle, byte[] data)Writes the data bytes to the device associated with handle.voidserialWriteByte(int handle, byte data)Writes a single byte to the device associated with handle.voidsetDebug(boolean flag)voidsetPWMDutycycle(int gpio, int dutycycle)Starts (non-zero dutycycle) or stops (0) PWM pulses on the GPIO.intsetPWMFrequency(int gpio, int frequency)Sets the frequency (in Hz) of the PWM to be used on the GPIO.
Returns the frequency actually set.voidsetPWMRange(int gpio, int range)Sets the range of PWM values to be used on the GPIO.voidsetServoPulseWidth(int gpio, int pulseWidth)voidsetWatchdog(int userGpio, int timeout)Sets a watchdog timeout for a GPIO.
The watchdog is nominally in milliseconds.
Only one watchdog may be registered per GPIO.
The watchdog may be cancelled by setting timeout to 0.
If no level change has been detected for the GPIO for timeout milliseconds any notification for the GPIO has a report written to the fifo with the flags set to indicate a watchdog timeout.
The callback class interprets the flags and will call registered notificationListeners for the GPIO with level TIMEOUT.
voidspiClose(int handle)Closes the SPI device associated with handle.intspiOpen(int channel, int baudRate, int flags)Returns a handle for the SPI device on channel.intspiRead(int handle, byte[] data)Reads count bytes from the SPI device associated with handle.
The returned value is a tuple of the number of bytes read and a bytearray containing the bytes.intspiWrite(int handle, byte[] data)Writes the data bytes to the SPI device associated with handle.intspiXfer(int handle, byte[] txData, byte[] rxData)Writes the data bytes to the SPI device associated with handle, returning the data bytes read from the device.
The returned value is a tuple of the number of bytes read and a bytearray containing the bytes.intwaveAddGeneric(java.util.ArrayList<Pulse> pulses)Adds a list of pulses to the current waveform.
Returns the new total number of pulses in the current waveform.
The pulses are interleaved in time order within the existing waveform (if any).
Merging allows the waveform to be built in parts, that is the settings for GPIO#1 can be added, and then GPIO#2 etc.
If the added waveform is intended to start after or within the existing waveform then the first pulse should consist solely of a delay.voidwaveAddNew()Starts a new empty waveform.
You would not normally need to call this function as it is automatically called after a waveform is created with the [*wave_create*] function.intwaveAddSerial(int gpio, int baud, byte[] data, int offset, int bbBits, int bbStop)Adds a waveform representing serial data to the existing waveform (if any).voidwaveClear()This function clears all waveforms and any data added by calls to the wave_add_* functions.intwaveCreate()Creates a waveform from the data provided by the prior calls to the [*wave_add_**] functions.
Returns a wave id (>=0) if OK, otherwise PI_EMPTY_WAVEFORM, PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID.
The data provided by the [*wave_add_**] functions is consumed by this function.
As many waveforms may be created as there is space available.voidwaveDelete(int waveId)This function deletes the waveform with id wave_id.
Wave ids are allocated in order, 0, 1, 2, etc.intwaveSendOnce(int waveId)Transmits the waveform with id wave_id.intwaveSendRepeat(int waveId)Transmits the waveform with id wave_id.booleanwaveTxBusy()Returns 1 if a waveform is currently being transmitted, otherwise 0.intwaveTxStop()Stops the transmission of the current waveform.
This function is intended to stop a waveform started with wave_send_repeat. 
- 
Field Details
- 
PI_GPIO2
static final int PI_GPIO2- See Also:
 - Constant Field Values
 
 - 
PI_GPIO3
static final int PI_GPIO3- See Also:
 - Constant Field Values
 
 - 
PI_GPIO4
static final int PI_GPIO4- See Also:
 - Constant Field Values
 
 - 
PI_GPIO5
static final int PI_GPIO5- See Also:
 - Constant Field Values
 
 - 
PI_GPIO6
static final int PI_GPIO6- See Also:
 - Constant Field Values
 
 - 
PI_GPIO7
static final int PI_GPIO7- See Also:
 - Constant Field Values
 
 - 
PI_GPIO8
static final int PI_GPIO8- See Also:
 - Constant Field Values
 
 - 
PI_GPIO9
static final int PI_GPIO9- See Also:
 - Constant Field Values
 
 - 
PI_GPIO10
static final int PI_GPIO10- See Also:
 - Constant Field Values
 
 - 
PI_GPIO11
static final int PI_GPIO11- See Also:
 - Constant Field Values
 
 - 
PI_GPIO12
static final int PI_GPIO12- See Also:
 - Constant Field Values
 
 - 
PI_GPIO13
static final int PI_GPIO13- See Also:
 - Constant Field Values
 
 - 
PI_GPIO14
static final int PI_GPIO14- See Also:
 - Constant Field Values
 
 - 
PI_GPIO15
static final int PI_GPIO15- See Also:
 - Constant Field Values
 
 - 
PI_GPIO16
static final int PI_GPIO16- See Also:
 - Constant Field Values
 
 - 
PI_GPIO17
static final int PI_GPIO17- See Also:
 - Constant Field Values
 
 - 
PI_GPIO18
static final int PI_GPIO18- See Also:
 - Constant Field Values
 
 - 
PI_GPIO19
static final int PI_GPIO19- See Also:
 - Constant Field Values
 
 - 
PI_GPIO20
static final int PI_GPIO20- See Also:
 - Constant Field Values
 
 - 
PI_GPIO21
static final int PI_GPIO21- See Also:
 - Constant Field Values
 
 - 
PI_GPIO22
static final int PI_GPIO22- See Also:
 - Constant Field Values
 
 - 
PI_GPIO23
static final int PI_GPIO23- See Also:
 - Constant Field Values
 
 - 
PI_GPIO24
static final int PI_GPIO24- See Also:
 - Constant Field Values
 
 - 
PI_GPIO25
static final int PI_GPIO25- See Also:
 - Constant Field Values
 
 - 
PI_GPIO26
static final int PI_GPIO26- See Also:
 - Constant Field Values
 
 - 
PI_GPIO27
static final int PI_GPIO27- See Also:
 - Constant Field Values
 
 - 
PI_OFF
static final int PI_OFF- See Also:
 - Constant Field Values
 
 - 
PI_ON
static final int PI_ON- See Also:
 - Constant Field Values
 
 - 
PI_CLEAR
static final int PI_CLEAR- See Also:
 - Constant Field Values
 
 - 
PI_SET
static final int PI_SET- See Also:
 - Constant Field Values
 
 - 
PI_LOW
static final boolean PI_LOW- See Also:
 - Constant Field Values
 
 - 
PI_HIGH
static final boolean PI_HIGH- See Also:
 - Constant Field Values
 
 - 
PI_TIMEOUT
static final int PI_TIMEOUT- See Also:
 - Constant Field Values
 
 - 
PI_MICROSECONDS
static final int PI_MICROSECONDS- See Also:
 - Constant Field Values
 
 - 
PI_MILLISECONDS
static final int PI_MILLISECONDS- See Also:
 - Constant Field Values
 
 - 
PI_SECONDS
static final int PI_SECONDS- See Also:
 - Constant Field Values
 
 - 
PI_RISING_EDGE
static final int PI_RISING_EDGE- See Also:
 - Constant Field Values
 
 - 
PI_FALLING_EDGE
static final int PI_FALLING_EDGE- See Also:
 - Constant Field Values
 
 - 
PI_EITHER_EDGE
static final int PI_EITHER_EDGE- See Also:
 - Constant Field Values
 
 - 
PI_INPUT
static final int PI_INPUT- See Also:
 - Constant Field Values
 
 - 
PI_OUTPUT
static final int PI_OUTPUT- See Also:
 - Constant Field Values
 
 - 
PI_ALT0
static final int PI_ALT0- See Also:
 - Constant Field Values
 
 - 
PI_ALT1
static final int PI_ALT1- See Also:
 - Constant Field Values
 
 - 
PI_ALT2
static final int PI_ALT2- See Also:
 - Constant Field Values
 
 - 
PI_ALT3
static final int PI_ALT3- See Also:
 - Constant Field Values
 
 - 
PI_ALT4
static final int PI_ALT4- See Also:
 - Constant Field Values
 
 - 
PI_ALT5
static final int PI_ALT5- See Also:
 - Constant Field Values
 
 - 
PI_PUD_OFF
static final int PI_PUD_OFF- See Also:
 - Constant Field Values
 
 - 
PI_PUD_DOWN
static final int PI_PUD_DOWN- See Also:
 - Constant Field Values
 
 - 
PI_PUD_UP
static final int PI_PUD_UP- See Also:
 - Constant Field Values
 
 - 
PI_SCRIPT_INITING
static final int PI_SCRIPT_INITING- See Also:
 - Constant Field Values
 
 - 
PI_SCRIPT_HALTED
static final int PI_SCRIPT_HALTED- See Also:
 - Constant Field Values
 
 - 
PI_SCRIPT_RUNNING
static final int PI_SCRIPT_RUNNING- See Also:
 - Constant Field Values
 
 - 
PI_SCRIPT_WAITING
static final int PI_SCRIPT_WAITING- See Also:
 - Constant Field Values
 
 - 
PI_SCRIPT_FAILED
static final int PI_SCRIPT_FAILED- See Also:
 - Constant Field Values
 
 - 
PI_NTFY_FLAGS_ALIVE
static final int PI_NTFY_FLAGS_ALIVE- See Also:
 - Constant Field Values
 
 - 
PI_NTFY_FLAGS_WDOG
static final int PI_NTFY_FLAGS_WDOG- See Also:
 - Constant Field Values
 
 - 
PI_NTFY_FLAGS_GPIO
static final int PI_NTFY_FLAGS_GPIO- See Also:
 - Constant Field Values
 
 - 
PI_WAVE_MODE_ONE_SHOT
static final int PI_WAVE_MODE_ONE_SHOT- See Also:
 - Constant Field Values
 
 - 
PI_WAVE_MODE_REPEAT
static final int PI_WAVE_MODE_REPEAT- See Also:
 - Constant Field Values
 
 - 
PI_WAVE_MODE_ONE_SHOT_SYNC
static final int PI_WAVE_MODE_ONE_SHOT_SYNC- See Also:
 - Constant Field Values
 
 - 
PI_WAVE_MODE_REPEAT_SYNC
static final int PI_WAVE_MODE_REPEAT_SYNC- See Also:
 - Constant Field Values
 
 - 
PI_WAVE_NOT_FOUND
static final int PI_WAVE_NOT_FOUND- See Also:
 - Constant Field Values
 
 - 
PI_NO_TX_WAVE
static final int PI_NO_TX_WAVE- See Also:
 - Constant Field Values
 
 - 
PI_DEFAULT_DUTYCYCLE_RANGE
static final int PI_DEFAULT_DUTYCYCLE_RANGE- See Also:
 - Constant Field Values
 
 - 
PI_MIN_DUTYCYCLE_RANGE
static final int PI_MIN_DUTYCYCLE_RANGE- See Also:
 - Constant Field Values
 
 - 
PI_MAX_DUTYCYCLE_RANGE
static final int PI_MAX_DUTYCYCLE_RANGE- See Also:
 - Constant Field Values
 
 - 
PI_SERVO_OFF
static final int PI_SERVO_OFF- See Also:
 - Constant Field Values
 
 - 
PI_MIN_SERVO_PULSEWIDTH
static final int PI_MIN_SERVO_PULSEWIDTH- See Also:
 - Constant Field Values
 
 - 
PI_MAX_SERVO_PULSEWIDTH
static final int PI_MAX_SERVO_PULSEWIDTH- See Also:
 - Constant Field Values
 
 - 
PI_HW_PWM_MIN_FREQ
static final int PI_HW_PWM_MIN_FREQ- See Also:
 - Constant Field Values
 
 - 
PI_HW_PWM_MAX_FREQ
static final int PI_HW_PWM_MAX_FREQ- See Also:
 - Constant Field Values
 
 - 
PI_HW_PWM_RANGE
static final int PI_HW_PWM_RANGE- See Also:
 - Constant Field Values
 
 - 
PI_HW_CLK_MIN_FREQ
static final int PI_HW_CLK_MIN_FREQ- See Also:
 - Constant Field Values
 
 - 
PI_HW_CLK_MAX_FREQ
static final int PI_HW_CLK_MAX_FREQ- See Also:
 - Constant Field Values
 
 - 
PI_MSBFIRST
static final boolean PI_MSBFIRST- See Also:
 - Constant Field Values
 
 - 
PI_LSBFIRST
static final boolean PI_LSBFIRST- See Also:
 - Constant Field Values
 
 - 
PI_SPI_MODE0
static final int PI_SPI_MODE0- See Also:
 - Constant Field Values
 
 - 
PI_SPI_MODE1
static final int PI_SPI_MODE1- See Also:
 - Constant Field Values
 
 - 
PI_SPI_MODE2
static final int PI_SPI_MODE2- See Also:
 - Constant Field Values
 
 - 
PI_SPI_MODE3
static final int PI_SPI_MODE3- See Also:
 - Constant Field Values
 
 - 
PI_SPI_BAUD_125KHZ
static final int PI_SPI_BAUD_125KHZ- See Also:
 - Constant Field Values
 
 - 
PI_SPI_BAUD_250KHZ
static final int PI_SPI_BAUD_250KHZ- See Also:
 - Constant Field Values
 
 - 
PI_SPI_BAUD_500KHZ
static final int PI_SPI_BAUD_500KHZ- See Also:
 - Constant Field Values
 
 - 
PI_SPI_BAUD_1MHZ
static final int PI_SPI_BAUD_1MHZ- See Also:
 - Constant Field Values
 
 - 
PI_SPI_BAUD_2MHZ
static final int PI_SPI_BAUD_2MHZ- See Also:
 - Constant Field Values
 
 - 
PI_SPI_BAUD_4MHZ
static final int PI_SPI_BAUD_4MHZ- See Also:
 - Constant Field Values
 
 - 
PI_SPI_BAUD_8MHZ
static final int PI_SPI_BAUD_8MHZ- See Also:
 - Constant Field Values
 
 - 
PI_SPI_CHANNEL0
static final int PI_SPI_CHANNEL0- See Also:
 - Constant Field Values
 
 - 
PI_SPI_CHANNEL1
static final int PI_SPI_CHANNEL1- See Also:
 - Constant Field Values
 
 - 
PI_SPI_CE0
static final int PI_SPI_CE0- See Also:
 - Constant Field Values
 
 - 
PI_SPI_CE1
static final int PI_SPI_CE1- See Also:
 - Constant Field Values
 
 - 
PI_SPI_MOSI
static final int PI_SPI_MOSI- See Also:
 - Constant Field Values
 
 - 
PI_SPI_MISO
static final int PI_SPI_MISO- See Also:
 - Constant Field Values
 
 - 
PI_SPI_SCLK
static final int PI_SPI_SCLK- See Also:
 - Constant Field Values
 
 - 
PI_I2C1_SDA
static final int PI_I2C1_SDA- See Also:
 - Constant Field Values
 
 - 
PI_I2C1_SCL
static final int PI_I2C1_SCL- See Also:
 - Constant Field Values
 
 
 - 
 - 
Method Details
- 
gpioInitialize
- Throws:
 PigpioException
 - 
reconnect
Try reconnecting to pigpio. This does make sense in case of socket pigpiod interface- Throws:
 PigpioException
 - 
gpioTerminate
Terminate the usage of the pigpio interfaces.- Throws:
 PigpioException- on error
 - 
gpioSetMode
Set the mode of the gpio- Parameters:
 gpio- The gpio pin to setmode- The mode of the pin. One of PI_INPUT or PI_OUTPUT- Throws:
 PigpioException- on pigpiod error
 - 
gpioGetMode
Retrieve the mode of the given gpio- Parameters:
 gpio- The gpio to retrieve the mode- Returns:
 - The mode of the gpio
 - Throws:
 PigpioException- on pigpiod error
 - 
gpioTrigger
Set the specified gpio to the level specified by level for the duration (in micro-sec) specified by pulseLen and then set the gpio back to not-level.- Parameters:
 gpio- The GPIO pin to pulse.pulseLen- The duration in microseconds to hold the pulse.level- The level to target the pulse.- Throws:
 PigpioException- on pigpiod error
 - 
gpioSetPullUpDown
- Throws:
 PigpioException
 - 
gpioRead
Retrieve the state of the gpio- Parameters:
 gpio- The gpio pin to retrieve- Returns:
 - The state of the gpio, one of PI_HIGH or PI_LOW (or equivalents)
 - Throws:
 PigpioException- on pigpiod error
 - 
gpioWrite
Set the state of the gpio- Parameters:
 gpio- The gpio pin to setvalue- The desired value of the new pin state. One of PI_HIGH or PI_LOW (or equivalents)- Throws:
 PigpioException- on pigpiod error
 - 
gpioShiftOut
void gpioShiftOut(int gpioData, int gpioClock, boolean bitOrder, byte value) throws PigpioExceptionShift out a byte of data to a given pin. Note that this function is implemented in Javacode.- Parameters:
 gpioData- The gpio to which to write the data.gpioClock- The clock gpio to pulse.bitOrder- The order of the bits. Either PI_LSBFIRST or PI_MSBFIRST.value- The value of the byte to write.- Throws:
 PigpioException- on pigpiod error
 - 
gpioShiftOut
void gpioShiftOut(GPIO gpioData, GPIO gpioClock, boolean bitOrder, byte value) throws PigpioException- Throws:
 PigpioException
 - 
gpioShiftOut
void gpioShiftOut(int gpioData, int gpioClock, boolean clockLevel, boolean bitOrder, byte value) throws PigpioExceptionShift out a byte of data to a given pin. Note that this function is implemented in Javacode.- Parameters:
 gpioData- The gpio to which to write the data.gpioClock- The clock gpio to pulse.clockLevel- The value of the clock pulsebitOrder- The order of the bitsvalue- The value of the byte to write.- Throws:
 PigpioException- on pigpiod error
 - 
gpioShiftOut
void gpioShiftOut(GPIO gpioData, GPIO gpioClock, boolean clockLevel, boolean bitOrder, byte value) throws PigpioException- Throws:
 PigpioException
 - 
gpioServo
Starts (500-2500) or stops (0) servo pulses on the GPIO.
The selected pulsewidth will continue to be transmitted until changed by a subsequent call to set_servo_pulsewidth.
The pulsewidths supported by servos varies and should probably be determined by experiment. A value of 1500 should always be safe and represents the mid-point of rotation.
You can DAMAGE a servo if you command it to move beyond its limits.
... pi.setServoPulsewidth(17, 0); // off pi.setServoPulsewidth(17, 1000); // safe anti-clockwise pi.setServoPulsewidth(17, 1500); // centre pi.setServoPulsewidth(17, 2000); // safe clockwise ...- Parameters:
 gpio- GPIO to control the servo. 0-31pulseWidth- The pulse width of the pulse (500-2500).
0 = off
500 = most anti-clockwise
2500 = most clock-wise- Throws:
 PigpioException- on pigpiod error
 - 
setServoPulseWidth
- Throws:
 PigpioException
 - 
getServoPulseWidth
Returns the servo pulsewidth being used on the GPIO.
... pi.set_servo_pulsewidth(4, 525) print(pi.get_servo_pulsewidth(4)) 525 pi.set_servo_pulsewidth(4, 2130) print(pi.get_servo_pulsewidth(4)) 2130- Parameters:
 gpio- user gpio 0-31- Returns:
 - Returns the servo pulsewidth.
 - Throws:
 PigpioException- on pigpiod error
 - 
gpioDelay
Delay for the specified number of microseconds- Parameters:
 delay- The number of microseconds for which to block- Throws:
 PigpioException- on pigpiod error
 - 
gpioDelay
- Throws:
 PigpioException
 - 
notifyOpen
Returns a notification handle (>=0).
A notification is a method for being notified of GPIO state changes via a pipe.
Pipes are only accessible from the local machine so this function serves no purpose if you are using Python from a remote machine. The in-built (socket) notifications provided by [*callback*] should be used instead.
Notifications for handle x will be available at the pipe named /dev/pigpiox (where x is the handle number).
E.g. if the function returns 15 then the notifications must be read from /dev/pigpio15.
Notifications have the following structure.
seqno: starts at 0 each time the handle is opened and then increments by one for each report.. . I seqno I flags I tick I level . .
flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE. If bit 5 is set (PI_NTFY_FLAGS_WDOG) then bits 0-4 of the flags indicate a GPIO which has had a watchdog timeout; if bit 6 is set (PI_NTFY_FLAGS_ALIVE) this indicates a keep alive signal on the pipe/socket and is sent once a minute in the absence of other notification activity.
tick: the number of microseconds since system boot. It wraps around after 1h12m.
level: indicates the level of each GPIO. If bit 1<<x is set then GPIO x is high.
... h = pi.notify_open(); if h >= 0:; pi.notify_begin(h, 1234); ...- Returns:
 - notification handle
 - Throws:
 PigpioException- on pigpiod error
 - 
notifyBegin
Starts notifications on a handle.
The notification sends state changes for each GPIO whose corresponding bit in bits is set.
The following code starts notifications for GPIO 1, 4, 6, 7, and 10 (1234 = 0x04D2 = 0b0000010011010010).
... h = pi.notify_open() if h >= 0: pi.notify_begin(h, 1234) ...- Parameters:
 handle- >=0 (as returned by a prior call to [*notify_open*])bits- a 32 bit mask indicating the GPIO to be notified.- Throws:
 PigpioException- on pigpiod error
 - 
notifyPause
Pauses notifications on a handle.
Notifications for the handle are suspended until [*notify_begin*] is called again.
... h = pi.notify_open() if h >= 0: pi.notify_begin(h, 1234) ... pi.notify_pause(h) ... pi.notify_begin(h, 1234) ...- Parameters:
 handle- >=0 (as returned by a prior call to [*notify_open*])- Throws:
 PigpioException- on pigpiod error
 - 
notifyClose
Stops notifications on a handle and releases the handle for reuse.... h = pi.notify_open() if h >= 0: pi.notify_begin(h, 1234) ... pi.notify_close(h) ... ...- Parameters:
 handle- >=0 (as returned by a prior call to [*notify_open*])- Throws:
 PigpioException- on pigpiod error
 - 
setWatchdog
Sets a watchdog timeout for a GPIO.
The watchdog is nominally in milliseconds.
Only one watchdog may be registered per GPIO.
The watchdog may be cancelled by setting timeout to 0.
If no level change has been detected for the GPIO for timeout milliseconds any notification for the GPIO has a report written to the fifo with the flags set to indicate a watchdog timeout.
The callback class interprets the flags and will call registered notificationListeners for the GPIO with level TIMEOUT.
... pi.setWatchdog(23, 1000) # 1000 ms watchdog on GPIO 23 pi.setWatchdog(23, 0) # cancel watchdog on GPIO 23 ...- Parameters:
 userGpio- 0-31timeout- 0-60000- Throws:
 PigpioException- on pigpiod error
 - 
gpioTick
- Throws:
 PigpioException
 - 
getCurrentTick
- Throws:
 PigpioException
 - 
waveClear
This function clears all waveforms and any data added by calls to the wave_add_* functions.- Throws:
 PigpioException- on pigpiod error
 - 
waveAddGeneric
Adds a list of pulses to the current waveform.
Returns the new total number of pulses in the current waveform.
The pulses are interleaved in time order within the existing waveform (if any).
Merging allows the waveform to be built in parts, that is the settings for GPIO#1 can be added, and then GPIO#2 etc.
If the added waveform is intended to start after or within the existing waveform then the first pulse should consist solely of a delay.
... G1=4 G2=24 pi.set_mode(G1, pigpio.OUTPUT) pi.set_mode(G2, pigpio.OUTPUT) flash_500=[] # flash every 500 ms flash_100=[] # flash every 100 ms # ON OFF DELAY flash_500.addListener(pigpio.pulse(1<<G1, 1<<G2, 500000)) flash_500.addListener(pigpio.pulse(1<<G2, 1<<G1, 500000)) flash_100.addListener(pigpio.pulse(1<<G1, 1<<G2, 100000)) flash_100.addListener(pigpio.pulse(1<<2, 1<<G1, 100000)) pi.wave_clear() # clear any existing waveforms pi.wave_add_generic(flash_500) # 500 ms flashes f500 = pi.wave_create() # create and save id pi.wave_add_generic(flash_100) # 100 ms flashes f100 = pi.wave_create() # create and save id pi.wave_send_repeat(f500) time.sleep(4) pi.wave_send_repeat(f100) time.sleep(4) pi.wave_send_repeat(f500) time.sleep(4) pi.wave_tx_stop() # stop waveform pi.wave_clear() # clear all waveforms ...- Parameters:
 pulses- list of pulses to add to the waveform.- Returns:
 - Returns the new total number of pulses in the current waveform.
 - Throws:
 PigpioException- on pigpiod error
 - 
waveAddSerial
int waveAddSerial(int gpio, int baud, byte[] data, int offset, int bbBits, int bbStop) throws PigpioExceptionAdds a waveform representing serial data to the existing waveform (if any). The serial data starts [*offset*] microseconds from the start of the waveform.
Returns the new total number of pulses in the current waveform.
The serial data is formatted as one start bit, [*bb_bits*] data bits, and [*bb_stop*]/2 stop bits.
It is legal to add serial data streams with different baud rates to the same waveform.
The bytes required for each character depend upon [*bb_bits*].
For [*bb_bits*] 1-8 there will be one byte per character.
For [*bb_bits*] 9-16 there will be two bytes per character.
For [*bb_bits*] 17-32 there will be four bytes per character.
... pi.wave_add_serial(4, 300, 'Hello world') pi.wave_add_serial(4, 300, b"Hello world") pi.wave_add_serial(4, 300, b'\\x23\\x01\\x00\\x45') pi.wave_add_serial(17, 38400, [23, 128, 234], 5000) ...- Parameters:
 gpio- GPIO to transmit data. You must set the GPIO mode to output.baud- 50-1000000 bits per second.data- the bytes to write.offset- number of microseconds from the start of the waveform, default 0.bbBits- number of data bits, default 8.bbStop- number of stop half bits, default 2.- Returns:
 - Returns the new total number of pulses in the current waveform.
 - Throws:
 PigpioException- on pigpiod error
 - 
waveAddNew
Starts a new empty waveform.
You would not normally need to call this function as it is automatically called after a waveform is created with the [*wave_create*] function.
... pi.wave_add_new() ...- Throws:
 PigpioException- on pigpiod error
 - 
waveTxBusy
Returns 1 if a waveform is currently being transmitted, otherwise 0.
... pi.wave_send_once(0) # send first waveform while pi.wave_tx_busy(): # wait for waveform to be sent time.sleep(0.1) pi.wave_send_once(1) # send next waveform ...- Returns:
 - The return code from wave_tx_busy.
 - Throws:
 PigpioException- on pigpiod error
 - 
waveTxStop
Stops the transmission of the current waveform.
This function is intended to stop a waveform started with wave_send_repeat.
... pi.wave_send_repeat(3) time.sleep(5) pi.wave_tx_stop() ...- Returns:
 - The return code from wave_tx_stop.
 - Throws:
 PigpioException- on pigpiod error
 - 
waveCreate
Creates a waveform from the data provided by the prior calls to the [*wave_add_**] functions.
Returns a wave id (>=0) if OK, otherwise PI_EMPTY_WAVEFORM, PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID.
The data provided by the [*wave_add_**] functions is consumed by this function.
As many waveforms may be created as there is space available. The wave id is passed to [*wave_send_**] to specify the waveform to transmit.
Normal usage would be- Step 1. [*wave_clear*] to clear all waveforms and added data.
 - Step 2. [*wave_add_**] calls to supply the waveform data.
 - Step 3. [*wave_create*] to create the waveform and get a unique id
 
Repeat steps 2 and 3 as needed.
Step 4. [*wave_send_**] with the id of the waveform to transmit.
A waveform comprises one or more pulses.
A pulse specifies
- the GPIO to be switched on at the start of the pulse.
 - the GPIO to be switched off at the start of the pulse.
 - the delay in microseconds before the next pulse.
 
When a waveform is started each pulse is executed in order with the specified delay between the pulse and the next.
... wid = pi.wave_create() ...- Returns:
 - wave id (>=0) if OK, otherwise PI_EMPTY_WAVEFORM, PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID.
 - Throws:
 PigpioException- on pigpiod error
 - 
waveDelete
This function deletes the waveform with id wave_id.
Wave ids are allocated in order, 0, 1, 2, etc.
... pi.wave_delete(6) # delete waveform with id 6 pi.wave_delete(0) # delete waveform with id 0 ...- Parameters:
 waveId- >=0 (as returned by a prior call to [*wave_create*]).- Throws:
 PigpioException- on pigpiod error
 - 
waveSendOnce
Transmits the waveform with id wave_id. The waveform is sent once.
NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled.
Returns the number of DMA control blocks used in the waveform.
... cbs = pi.wave_send_once(wid) ...- Parameters:
 waveId- >=0 (as returned by a prior call to [*wave_create*]).- Returns:
 - Returns the number of DMA control blocks used in the waveform.
 - Throws:
 PigpioException- on pigpiod error
 - 
waveSendRepeat
Transmits the waveform with id wave_id. The waveform repeats until wave_tx_stop is called or another call to [*wave_send_**] is made.
NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled.
Returns the number of DMA control blocks used in the waveform.
... cbs = pi.wave_send_repeat(wid) ...- Parameters:
 waveId- >=0 (as returned by a prior call to [*wave_create*]).- Returns:
 - Returns the number of DMA control blocks used in the waveform.
 - Throws:
 PigpioException- on pigpiod error
 - 
i2cOpen
Returns a handle (>=0) for the device at the I2C bus address.
i2c_flags:= 0, no flags are currently defined.
Normally you would only use the [*i2c_**] functions if you are or will be connecting to the Pi over a network. If you will always run on the local Pi use the standard SMBus module instead.
For the SMBus commands the low level transactions are shown at the end of the function description. The following abbreviations are used.
. . S (1 bit) : Start bit P (1 bit) : Stop bit Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. A, NA (1 bit) : Accept and not accept bit. Addr (7 bits): I2C 7 bit address. reg (8 bits): Command byte, which often selects a register. Data (8 bits): A data byte. Count (8 bits): A byte defining the length of a block operation. [..]: Data sent by the device. . . ... h = pi.i2c_open(1, 0x53) # open device at address 0x53 on bus 1 ...- Parameters:
 i2cBus- 0-1.i2cAddr- 0x00-0x7F.- Returns:
 - Returns a handle (>=0) for the device at the I2C bus address.
 - Throws:
 PigpioException- on pigpiod error
 - 
i2cClose
Closes the I2C device associated with handle.... pi.i2c_close(h) ...- Parameters:
 handle- >=0 (as returned by a prior call to [*i2c_open*]).- Throws:
 PigpioException- on pigpiod error
 - 
i2cReadDevice
Returns count bytes read from the raw device associated with handle.. . S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P . .
The returned value is a tuple of the number of bytes read and a bytearray containing the bytes. If there was an error the number of bytes read will be less than zero (and will contain the error code).... (count, data) = pi.i2c_read_device(h, 12) ...- Parameters:
 handle- >=0 (as returned by a prior call to [*i2c_open*]).data- >0, the number of bytes to read.- Returns:
 - Returns count bytes read from the raw device associated with handle.
 - Throws:
 PigpioException- on pigpiod error
 - 
i2cWriteDevice
Writes the data bytes to the raw device associated with handle.. . S Addr Wr [A] data0 [A] data1 [A] ... [A] datan [A] P . .
... pi.i2c_write_device(h, b"\\x12\\x34\\xA8") pi.i2c_write_device(h, b"help") pi.i2c_write_device(h, 'help') pi.i2c_write_device(h, [23, 56, 231]) ...- Parameters:
 handle- >=0 (as returned by a prior call to [*i2c_open*]).data- the bytes to write.- Throws:
 PigpioException- on pigpiod error
 - 
spiOpen
Returns a handle for the SPI device on channel. Data will be transferred at baud bits per second. The flags may be used to modify the default behaviour of 4-wire operation, mode 0, active low chip select.
An auxiliary SPI device is available on all models but the A and B and may be selected by setting the A bit in the flags. The auxiliary device has 3 chip selects and a selectable word size in bits.
Normally you would only use the [*spi_**] functions if you are or will be connecting to the Pi over a network. If you will always run on the local Pi use the standard SPI module instead.
spi_flags consists of the least significant 22 bits.
. . 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m . . mm defines the SPI mode. WARNING: modes 1 and 3 do not appear to work on the auxiliary device. . . Mode POL PHA 0 0 0 1 0 1 2 1 0 3 1 1 . .
px is 0 if CEx is active low (default) and 1 for active high.
ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
A is 0 for the standard SPI device, 1 for the auxiliary SPI.
W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard SPI device only.
nnnn defines the number of bytes (0-15) to write before switching the MOSI line to MISO to read data. This field is ignored if W is not set. Standard SPI device only.
T is 1 if the least significant bit is transmitted on MOSI first, the default (0) shifts the most significant bit out first. Auxiliary SPI device only.
R is 1 if the least significant bit is received on MISO first, the default (0) receives the most significant bit first. Auxiliary SPI device only.
bbbbbb defines the word size in bits (0-32). The default (0) sets 8 bits per word. Auxiliary SPI device only.
The [*spi_read*], [*spi_write*], and [*spi_xfer*] functions transfer data packed into 1, 2, or 4 bytes according to the word size in bits.
For bits 1-8 there will be one byte per character.
For bits 9-16 there will be two bytes per character.
For bits 17-32 there will be four bytes per character.
E.g. 32 12-bit words will be transferred in 64 bytes.
The other bits in flags should be set to zero.
... # open SPI device on channel 1 in mode 3 at 50000 bits per second h = pi.spi_open(1, 50000, 3) ...- Parameters:
 channel- The channel to open.
0-1 (0-2 for the auxiliary SPI device).baudRate- The baud rate for transmission and reception. Some constants are provided:- PI_SPI_BAUD_125KHZ
 - PI_SPI_BAUD_250KHZ
 - PI_SPI_BAUD_500KHZ
 - PI_SPI_BAUD_1MHZ
 - PI_SPI_BAUD_2MHZ
 - PI_SPI_BAUD_4MHZ
 - PI_SPI_BAUD_8MHZ
 
flags- Control flags. The flags can include:- Returns:
 - A handle used in subsequent SPI API calls
 - Throws:
 PigpioException- on pigpiod error
 - 
spiClose
Closes the SPI device associated with handle.... pi.spi_close(h) ...- Parameters:
 handle- The handle to be closed.
>=0 (as returned by a prior call to [*spi_open*]).- Throws:
 PigpioException- on pigpiod error
 - 
spiRead
Reads count bytes from the SPI device associated with handle.
The returned value is a tuple of the number of bytes read and a bytearray containing the bytes. If there was an error the number of bytes read will be less than zero (and will contain the error code).
... (b, d) = pi.spi_read(h, 60) # read 60 bytes from device h if b == 60: # process read data else: # error path ...- Parameters:
 handle- The handle from which to read. >=0 (as returned by a prior call to [*spi_open*]).data- An array into which to read data.- Returns:
 - The number of bytes actually read.
 - Throws:
 PigpioException- on pigpiod error
 - 
spiWrite
Writes the data bytes to the SPI device associated with handle.... pi.spi_write(0, b'\\x02\\xc0\\x80') # write 3 bytes to device 0 pi.spi_write(0, b'defgh') # write 5 bytes to device 0 pi.spi_write(0, "def") # write 3 bytes to device 0 pi.spi_write(1, [2, 192, 128]) # write 3 bytes to device 1 ...- Parameters:
 handle- The handle into which to write. >=0 (as returned by a prior call to [*spi_open*]).data- An array of data to write to SPI.- Returns:
 - The number of bytes actually written
 - Throws:
 PigpioException- on pigpiod error
 - 
spiXfer
Writes the data bytes to the SPI device associated with handle, returning the data bytes read from the device.
The returned value is a tuple of the number of bytes read and a bytearray containing the bytes. If there was an error the number of bytes read will be less than zero (and will contain the error code).
... (count, rx_data) = pi.spi_xfer(h, b'\\x01\\x80\\x00') (count, rx_data) = pi.spi_xfer(h, [1, 128, 0]) (count, rx_data) = pi.spi_xfer(h, b"hello") (count, rx_data) = pi.spi_xfer(h, "hello") ...- Parameters:
 handle- The handle into which to write. >=0 (as returned by a prior call to [*spi_open*]).txData- An array of data to write.rxData- An array of data to read.- Returns:
 - The number of bytes actually transferred.
 - Throws:
 PigpioException- on pigpiod error
 - 
serialOpen
Returns a handle for the serial tty device opened at baud bits per second.
Normally you would only use the [*serial_**] functions if you are or will be connecting to the Pi over a network. If you will always run on the local Pi use the standard serial module instead.
The baud rate must be one of 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, or 230400.
... h1 = pi.serial_open("/dev/ttyAMA0", 300) h2 = pi.serial_open("/dev/ttyUSB1", 19200, 0) ...- Parameters:
 tty- serial device to openbaudRate- baud rate in bits per second, see below.flags- connection flags. No flags are currently defined.- Returns:
 - handle for opened device
 - Throws:
 PigpioException- on pigpiod error
 - 
serialClose
Closes the serial device associated with handle.... pi.serial_close(h1) ...- Parameters:
 handle- >=0 (as returned by a prior call to [*serial_open*]).- Throws:
 PigpioException- on pigpiod error
 - 
serialReadByte
Returns a single byte from the device associated with handle.... b = pi.serial_read_byte(h1) ...- Parameters:
 handle- >=0 (as returned by a prior call to [*serial_open*]).- Returns:
 - single byte from opened device
 - Throws:
 PigpioException- on pigpiod error
 - 
serialWriteByte
Writes a single byte to the device associated with handle.... pi.serial_write_byte(h1, 23) pi.serial_write_byte(h1, ord('Z')) ...- Parameters:
 handle- >=0 (as returned by a prior call to [*serial_open*]).data- 0-255, the value to write.- Throws:
 PigpioException- on pigpiod error
 - 
serialRead
Reads up to count bytes from the device associated with handle.
The returned value is a tuple of the number of bytes read and a bytearray containing the bytes. If there was an error the number of bytes read will be less than zero (and will contain the error code).... (b, d) = pi.serial_read(h2, 100) if b > 0: # process read data ...- Parameters:
 handle- >=0 (as returned by a prior call to [*serial_open*]).count- >0, the number of bytes to read.- Returns:
 - read bytes
 - Throws:
 PigpioException- on pigpiod error
 - 
serialWrite
Writes the data bytes to the device associated with handle.... pi.serial_write(h1, b'\\x02\\x03\\x04') pi.serial_write(h2, b'help') pi.serial_write(h2, "hello") pi.serial_write(h1, [2, 3, 4]) ...- Parameters:
 handle- >=0 (as returned by a prior call to [*serial_open*]).data- the bytes to write.- Throws:
 PigpioException- on pigpiod error
 - 
serialDataAvailable
Returns the number of bytes available to be read from the device associated with handle.... rdy = pi.serial_data_available(h1) if rdy > 0: (b, d) = pi.serial_read(h1, rdy) ...- Parameters:
 handle- >=0 (as returned by a prior call to [*serial_open*]).- Returns:
 - number of bytes available to be read
 - Throws:
 PigpioException- on pigpiod error
 - 
setPWMDutycycle
Starts (non-zero dutycycle) or stops (0) PWM pulses on the GPIO.
The [*setPWMRange*] function can change the default range of 255.... pi.setPWMDutycycle(4, 0) # PWM off pi.setPWMDutycycle(4, 64) # PWM 1/4 on pi.setPWMDutycycle(4, 128) # PWM 1/2 on pi.setPWMDutycycle(4, 192) # PWM 3/4 on pi.setPWMDutycycle(4, 255) # PWM full on ...- Parameters:
 gpio- user gpio 0-31dutycycle- 0-range (range defaults to 255).- Throws:
 PigpioException- on pigpiod error
 - 
getPWMDutycycle
Returns the PWM dutycycle being used on the GPIO.
For normal PWM the dutycycle will be out of the defined range for the GPIO (see [*getPWMRange*]).
If a hardware clock is active on the GPIO the reported dutycycle will be 500000 (500k) out of 1000000 (1M).
If hardware PWM is active on the GPIO the reported dutycycle will be out of a 1000000 (1M).... pi.setPWMDutycycle(4, 25) print(pi.getPWMDutycycle(4)) 25 pi.setPWMDutycycle(4, 203) print(pi.getPWMDutycycle(4)) 203 ...- Parameters:
 gpio- user gpio 0-31- Returns:
 - PWM dutycycle
 - Throws:
 PigpioException- on pigpiod error
 - 
setPWMRange
Sets the range of PWM values to be used on the GPIO.... pi.set_PWM_range(9, 100) # now 25 1/4, 50 1/2, 75 3/4 on pi.set_PWM_range(9, 500) # now 125 1/4, 250 1/2, 375 3/4 on pi.set_PWM_range(9, 3000) # now 750 1/4, 1500 1/2, 2250 3/4 on ...- Parameters:
 gpio- user gpio 0-31range- range 25-40000- Throws:
 PigpioException- on pigpiod error
 - 
getPWMRange
Returns the range of PWM values being used on the GPIO.
If a hardware clock or hardware PWM is active on the GPIO the reported range will be 1000000 (1M).... pi.set_PWM_range(9, 500) print(pi.get_PWM_range(9)) 500 ...- Parameters:
 gpio- user gpio 0-31- Returns:
 - range of PWM values
 - Throws:
 PigpioException- on pigpiod error
 - 
getPWMRealRange
Returns the real (underlying) range of PWM values being used on the GPIO.
If a hardware clock is active on the GPIO the reported real range will be 1000000 (1M).
If hardware PWM is active on the GPIO the reported real range will be approximately 250M divided by the set PWM frequency.... pi.setPWMFrequency(4, 800) System.out.println(pi.getPWMRealRange(4)) 250 ...- Parameters:
 gpio- user gpio 0-31- Returns:
 - the real (underlying) range of PWM values
 - Throws:
 PigpioException- on pigpiod error
 - 
setPWMFrequency
Sets the frequency (in Hz) of the PWM to be used on the GPIO.
Returns the frequency actually set.... pi.setPWMFrequency(4,0) print(pi.getPWMFrequency(4)) 10 pi.set_PWMFrequency(4,100000) print(pi.getPWMFrequency(4)) 8000 ...- Parameters:
 gpio- user gpio 0-31frequency- >= 0 Hz- Returns:
 - Returns the frequency actually set.
 - Throws:
 PigpioException- on pigpiod error
 - 
getPWMFrequency
Returns the frequency of PWM being used on the GPIO.
Returns the frequency (in Hz) used for the GPIO.
For normal PWM the frequency will be that defined for the GPIO by [*setPWMFrequency*].
If a hardware clock is active on the GPIO the reported frequency will be that set by [*hardwareClock*].
If hardware PWM is active on the GPIO the reported frequency will be that set by [*hardwarePWM*].... pi.setPWMFrequency(4,0) print(pi.getPWMFrequency(4)) 10 pi.setPWMFrequency(4, 800) print(pi.getPWMFrequency(4)) 800 ...- Parameters:
 gpio- user gpio 0-31- Returns:
 - frequency (in Hz) used for the GPIO.
 - Throws:
 PigpioException- on pigpiod error
 - 
gpioSetAlertFunc
- Throws:
 PigpioException
 - 
setDebug
- Throws:
 PigpioException
 - 
gpioxPulseAndWait
long gpioxPulseAndWait(int outGpio, int inGpio, long waitDuration, long pulseHoldDuration, boolean pulseLow) throws PigpioExceptionPulse a named pin and then wait for a response on a different pin. The output pin should already have a PI_OUTPUT mode and the input pin should already have a PI_INPUT mode. The wait duration is in microseconds. The pulse hold duration is how long (in microseconds) the pulse should be held for. The default is to pulse the output high and then return low however if the pulseLow flag is set the inverse will happen (pulse the output low and then return high).
The return is how long we waited for the pulse measured in microseconds. If no response is received, we return -1 to indicate a timeout.- Parameters:
 outGpio- The pin on which the output pulse will occur.inGpio- The pin on which the input pulse will be sought.waitDuration- The maximum time to wait in microseconds.pulseHoldDuration- The time to hold the output pulse in microseconds.pulseLow- True if the pulse should be a low pulse otherwise a high pulse will be sent.- Returns:
 - The time in microseconds waiting for a pulse or -1 to signfify a timeout.
 - Throws:
 PigpioException- on pigpiod error
 - 
addCallback
Calls a user supplied function (a callback) whenever the specified GPIO edge is detected.
The user supplied callback receives three parameters, the GPIO, the level, and the tick.
If a user callback is not specified a default tally callback is provided which simply counts edges. The count may be retrieved by calling the tally function. The count may be reset to zero by calling the reset_tally function.
The callback may be cancelled by calling the cancel function.
A GPIO may have multiple notificationListeners (although I can't think of a reason to do so).
... def cbf(gpio, level, tick): print(gpio, level, tick) cb1 = pi.callback(22, pigpio.EITHER_EDGE, cbf) cb2 = pi.callback(4, pigpio.EITHER_EDGE) cb3 = pi.callback(17) print(cb3.tally()) cb3.reset_tally() cb1.cancel() # To cancel callback cb1. ...- Parameters:
 listener- user supplied callback object.- Throws:
 PigpioException
 - 
removeCallback
Remove callback listener object from notification thread.- Parameters:
 listener- GPIOListener object- Throws:
 PigpioException- on pigpiod error
 
 -