Package jpigpio
Class Pigpio
java.lang.Object
jpigpio.impl.CommonPigpio
jpigpio.Pigpio
- All Implemented Interfaces:
JPigpio
public class Pigpio extends CommonPigpio
Pigpiod wrapper class using native C++ methods. This class can be used only when executing your application directly at Raspberry Pi device.
See
See
Methods which are not implemented yet has "Not implemented" in their description.
All other methods you can consider implemented.
NOTE: if method you are looking for is not implemented, check
class PigpioSocket
for socket based implementation allowing you to develop/debug/run your over network.
See
interface JPigpio
for full documentation of specific methods.Methods which are not implemented yet has "Not implemented" in their description.
All other methods you can consider implemented.
NOTE: if method you are looking for is not implemented, check
class PigpioSocket
- maybe it is implemented there.-
Field Summary
Fields inherited from interface jpigpio.JPigpio
PI_ALT0, PI_ALT1, PI_ALT2, PI_ALT3, PI_ALT4, PI_ALT5, PI_CLEAR, PI_DEFAULT_DUTYCYCLE_RANGE, PI_EITHER_EDGE, PI_FALLING_EDGE, PI_GPIO10, PI_GPIO11, PI_GPIO12, PI_GPIO13, PI_GPIO14, PI_GPIO15, PI_GPIO16, PI_GPIO17, PI_GPIO18, PI_GPIO19, PI_GPIO2, PI_GPIO20, PI_GPIO21, PI_GPIO22, PI_GPIO23, PI_GPIO24, PI_GPIO25, PI_GPIO26, PI_GPIO27, PI_GPIO3, PI_GPIO4, PI_GPIO5, PI_GPIO6, PI_GPIO7, PI_GPIO8, PI_GPIO9, PI_HIGH, PI_HW_CLK_MAX_FREQ, PI_HW_CLK_MIN_FREQ, PI_HW_PWM_MAX_FREQ, PI_HW_PWM_MIN_FREQ, PI_HW_PWM_RANGE, PI_I2C1_SCL, PI_I2C1_SDA, PI_INPUT, PI_LOW, PI_LSBFIRST, PI_MAX_DUTYCYCLE_RANGE, PI_MAX_SERVO_PULSEWIDTH, PI_MICROSECONDS, PI_MILLISECONDS, PI_MIN_DUTYCYCLE_RANGE, PI_MIN_SERVO_PULSEWIDTH, PI_MSBFIRST, PI_NO_TX_WAVE, PI_NTFY_FLAGS_ALIVE, PI_NTFY_FLAGS_GPIO, PI_NTFY_FLAGS_WDOG, PI_OFF, PI_ON, PI_OUTPUT, PI_PUD_DOWN, PI_PUD_OFF, PI_PUD_UP, PI_RISING_EDGE, PI_SCRIPT_FAILED, PI_SCRIPT_HALTED, PI_SCRIPT_INITING, PI_SCRIPT_RUNNING, PI_SCRIPT_WAITING, PI_SECONDS, PI_SERVO_OFF, PI_SET, PI_SPI_BAUD_125KHZ, PI_SPI_BAUD_1MHZ, PI_SPI_BAUD_250KHZ, PI_SPI_BAUD_2MHZ, PI_SPI_BAUD_4MHZ, PI_SPI_BAUD_500KHZ, PI_SPI_BAUD_8MHZ, PI_SPI_CE0, PI_SPI_CE1, PI_SPI_CHANNEL0, PI_SPI_CHANNEL1, PI_SPI_MISO, PI_SPI_MODE0, PI_SPI_MODE1, PI_SPI_MODE2, PI_SPI_MODE3, PI_SPI_MOSI, PI_SPI_SCLK, PI_TIMEOUT, PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_ONE_SHOT_SYNC, PI_WAVE_MODE_REPEAT, PI_WAVE_MODE_REPEAT_SYNC, PI_WAVE_NOT_FOUND
-
Constructor Summary
Constructors Constructor Description Pigpio()
-
Method Summary
Modifier and Type Method Description void
addCallback(GPIOListener gpioListener)
Not implementedlong
getCurrentTick()
int
getPWMDutycycle(int gpio)
Not implementedint
getPWMFrequency(int gpio)
Not implementedint
getPWMRange(int gpio)
Not implementedint
getPWMRealRange(int gpio)
Not implementedint
getServoPulseWidth(int gpio)
Not implementedvoid
gpioDelay(long delay)
Delay for the specified number of microsecondsint
gpioGetMode(int pin)
Retrieve the mode of the given gpiovoid
gpioInitialize()
boolean
gpioRead(int pin)
Retrieve the state of the gpiovoid
gpioServo(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.void
gpioSetAlertFunc(int pin, Alert alert)
void
gpioSetMode(int pin, int mode)
Set the mode of the gpiovoid
gpioSetPullUpDown(int pin, int pud)
void
gpioTerminate()
Terminate the usage of the pigpio interfaces.long
gpioTick()
void
gpioTrigger(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.void
gpioWrite(int pin, boolean value)
Set the state of the gpiolong
gpioxPulseAndWait(int outGpio, int inGpio, long waitDuration, long pulseHoldDuration, boolean pulseLow)
Pulse a named pin and then wait for a response on a different pin.void
i2cClose(int handle)
Closes the I2C device associated with handle.int
i2cOpen(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.int
i2cReadDevice(int handle, byte[] data)
Returns count bytes read from the raw device associated with handle.void
i2cWriteDevice(int handle, byte[] data)
Writes the data bytes to the raw device associated with handle.void
notifyBegin(int handle, int bits)
Not implementedvoid
notifyClose(int handle)
Not implementedint
notifyOpen()
Not implementedvoid
notifyPause(int handle)
Not implementedvoid
reconnect()
Not implementedvoid
removeCallback(GPIOListener cgpioListener)
Not implementedvoid
serialClose(int handle)
Not implementedint
serialDataAvailable(int handle)
Not implementedint
serialOpen(java.lang.String tty, int baudRate, int flags)
Not implementedbyte[]
serialRead(int handle, int count)
Not implementedbyte
serialReadByte(int handle)
Not implementedvoid
serialWrite(int handle, byte[] data)
Not implementedvoid
serialWriteByte(int handle, byte data)
Not implementedvoid
setDebug(boolean flag)
void
setPWMDutycycle(int gpio, int dutycycle)
Starts (non-zero dutycycle) or stops (0) PWM pulses on the GPIO.int
setPWMFrequency(int gpio, int frequency)
Not implementedvoid
setPWMRange(int gpio, int range)
Not implementedvoid
setServoPulseWidth(int gpio, int pulseWidth)
void
setWatchdog(int userGpio, int timeout)
Not implementedvoid
spiClose(int handle)
Closes the SPI device associated with handle.int
spiOpen(int channel, int baudRate, int flags)
Returns a handle for the SPI device on channel.int
spiRead(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.int
spiWrite(int handle, byte[] data)
Writes the data bytes to the SPI device associated with handle.int
spiXfer(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.int
waveAddGeneric(java.util.ArrayList<Pulse> pulses)
Not implementedvoid
waveAddNew()
Not implementedint
waveAddSerial(int userGpio, int baud, byte[] data, int offset, int bbBits, int bbStop)
Not implementedvoid
waveClear()
Not implementedint
waveCreate()
Not implementedvoid
waveDelete(int waveId)
Not implementedint
waveSendOnce(int waveId)
Not implementedint
waveSendRepeat(int waveId)
Not implementedboolean
waveTxBusy()
Not implementedint
waveTxStop()
Not implementedMethods inherited from class jpigpio.impl.CommonPigpio
gpioDelay, gpioShiftOut, gpioShiftOut, gpioShiftOut, gpioShiftOut
-
Constructor Details
-
Pigpio
public Pigpio()
-
-
Method Details
-
gpioInitialize
- Throws:
PigpioException
-
gpioTerminate
Description copied from interface:JPigpio
Terminate the usage of the pigpio interfaces.- Throws:
PigpioException
- on error
-
reconnect
Not implemented- Throws:
PigpioException
-
gpioSetMode
Description copied from interface:JPigpio
Set the mode of the gpio- Parameters:
pin
- The gpio pin to setmode
- The mode of the pin. One of PI_INPUT or PI_OUTPUT- Throws:
PigpioException
- on pigpiod error
-
gpioGetMode
Description copied from interface:JPigpio
Retrieve the mode of the given gpio- Parameters:
pin
- The gpio to retrieve the mode- Returns:
- The mode of the gpio
- Throws:
PigpioException
- on pigpiod error
-
gpioSetPullUpDown
- Throws:
PigpioException
-
gpioRead
Description copied from interface:JPigpio
Retrieve the state of the gpio- Parameters:
pin
- 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
Description copied from interface:JPigpio
Set the state of the gpio- Parameters:
pin
- 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
-
notifyOpen
Not implemented- Returns:
- notification handle
- Throws:
PigpioException
- on pigpiod error
-
notifyBegin
Not implemented- 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
Not implemented- Parameters:
handle
- >=0 (as returned by a prior call to [*notify_open*])- Throws:
PigpioException
- on pigpiod error
-
notifyClose
Not implemented- Parameters:
handle
- >=0 (as returned by a prior call to [*notify_open*])- Throws:
PigpioException
- on pigpiod error
-
setWatchdog
Not implemented- Parameters:
userGpio
- 0-31timeout
- 0-60000- Throws:
PigpioException
- on pigpiod error
-
waveClear
Not implemented- Throws:
PigpioException
- on pigpiod error
-
waveAddGeneric
Not implemented- 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
public int waveAddSerial(int userGpio, int baud, byte[] data, int offset, int bbBits, int bbStop) throws PigpioExceptionNot implemented- Parameters:
userGpio
- 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
Not implemented- Throws:
PigpioException
- on pigpiod error
-
waveTxBusy
Not implemented- Returns:
- The return code from wave_tx_busy.
- Throws:
PigpioException
- on pigpiod error
-
waveTxStop
Not implemented- Returns:
- The return code from wave_tx_stop.
- Throws:
PigpioException
- on pigpiod error
-
waveCreate
Not implemented- 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
Not implemented- Parameters:
waveId
- >=0 (as returned by a prior call to [*wave_create*]).- Throws:
PigpioException
- on pigpiod error
-
waveSendOnce
Not implemented- 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
Not implemented- 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
Description copied from interface:JPigpio
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
Description copied from interface:JPigpio
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
Description copied from interface:JPigpio
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
Description copied from interface:JPigpio
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
-
gpioDelay
Description copied from interface:JPigpio
Delay for the specified number of microseconds- Parameters:
delay
- The number of microseconds for which to block- Throws:
PigpioException
- on pigpiod error
-
gpioTick
- Throws:
PigpioException
-
getCurrentTick
- Throws:
PigpioException
-
gpioServo
Description copied from interface:JPigpio
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
Not implemented- Parameters:
gpio
- user gpio 0-31- Returns:
- Returns the servo pulsewidth.
- Throws:
PigpioException
- on pigpiod error
-
setPWMDutycycle
Description copied from interface:JPigpio
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
Not implemented- Parameters:
gpio
- user gpio 0-31- Returns:
- PWM dutycycle
- Throws:
PigpioException
- on pigpiod error
-
setPWMRange
Not implemented- Parameters:
gpio
- user gpio 0-31range
- range 25-40000- Throws:
PigpioException
- on pigpiod error
-
getPWMRange
Not implemented- Parameters:
gpio
- user gpio 0-31- Returns:
- range of PWM values
- Throws:
PigpioException
- on pigpiod error
-
getPWMRealRange
Not implemented- Parameters:
gpio
- user gpio 0-31- Returns:
- the real (underlying) range of PWM values
- Throws:
PigpioException
- on pigpiod error
-
setPWMFrequency
Not implemented- Parameters:
gpio
- user gpio 0-31frequency
- >= 0 Hz- Returns:
- Returns the frequency actually set.
- Throws:
PigpioException
- on pigpiod error
-
getPWMFrequency
Not implemented- Parameters:
gpio
- user gpio 0-31- Returns:
- frequency (in Hz) used for the GPIO.
- Throws:
PigpioException
- on pigpiod error
-
serialOpen
Not implemented- 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
Not implemented- Parameters:
handle
- >=0 (as returned by a prior call to [*serial_open*]).- Throws:
PigpioException
- on pigpiod error
-
serialReadByte
Not implemented- Parameters:
handle
- >=0 (as returned by a prior call to [*serial_open*]).- Returns:
- single byte from opened device
- Throws:
PigpioException
- on pigpiod error
-
serialWriteByte
Not implemented- 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
Not implemented- 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
Not implemented- Parameters:
handle
- >=0 (as returned by a prior call to [*serial_open*]).data
- the bytes to write.- Throws:
PigpioException
- on pigpiod error
-
serialDataAvailable
Not implemented- 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
-
gpioSetAlertFunc
- Throws:
PigpioException
-
gpioTrigger
Description copied from interface:JPigpio
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
-
spiOpen
Description copied from interface:JPigpio
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
Description copied from interface:JPigpio
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
Description copied from interface:JPigpio
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
Description copied from interface:JPigpio
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
Description copied from interface:JPigpio
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
-
setDebug
public void setDebug(boolean flag) -
gpioxPulseAndWait
public long gpioxPulseAndWait(int outGpio, int inGpio, long waitDuration, long pulseHoldDuration, boolean pulseLow) throws PigpioExceptionDescription copied from interface:JPigpio
Pulse 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
Not implemented- Parameters:
gpioListener
- user supplied callback object.- Throws:
PigpioException
-
removeCallback
Not implemented- Parameters:
cgpioListener
- GPIOListener object- Throws:
PigpioException
- on pigpiod error
-