-
Notifications
You must be signed in to change notification settings - Fork 12
APIs
pigpio.getInfo(cb)
Returns useful information about rpi hardware and pigpiod.
pigpio.getCurrentTick(cb)
Return current timer tick in microseconds. gpioTick
pigpio.readBank1(cb)
Returns levels of GPIO bits 31-0. gpioRead_Bits_0_31
pigpio.end(cb)
Ends socket communications. Callback is invoked on 'disconnected'
event.
pigpio.destroy()
DEPRECATED. Invokes socket.destroy() on both network sockets.
pigpio.connect()
Re-establishes communication with server after being disconnected.
gpio.modeSet(mode, cb)
Sets the gpio mode to be input or output. The mode
argument must be string
with a value of 'input'
, 'in'
, 'output'
or 'out'
.
The optional callback is invoked with either null
argument on success or error
on failure.
gpio.modeGet(cb)
Returns the mode of gpio as argument to callback. gpioGetMode
gpio.pullUpDown(pud, cb)
pud=2: set pullup resistor, pud=1: set pulldown
resistor, pud=0: clear resistor setting.gpioSetPullUpDown
gpio.read(cb)
Returns the gpio pin level as argument to callback.
gpio.write(level, cb)
Sets the gpio output level to on (1) or off (0). If
PWM or servo pulses are active on the gpio they are switched off. gpioWrite
gpio.analogWrite(dutyCycle, cb)
Set the PWM dutycycle (0-255) on the gpio. Caution:
This will stop all waveform generation. gpioPWM
.
gpio.hardwarePWM(frequency, dutyCycle, callback)
Set the hardware PWM dutycycle (0-1000000) on the gpio. Only works with pins that support hardware PWM (12,13,18,19); max two channels available. PWM frequency is also specified - not likely to work above 30MHz though. Caution:
This will stop all waveform generation. gpioHardwarePWM
.
gpio.setServoPulsewidth(pulseWidth, cb)
Starts servo pulses on gpio. Pulsewidth can be set to 0 (off) and from 500 (most anti-clockwise) to 2500 (most clockwise). Be aware that you can damage your servo when setting a too high pulseWidth. A value of 1500 (mid-point) is a good starting point to check range of your servo. gpioServo
gpio.getServoPulsewidth(cb)
Returns the pulsewidth of gpio as argument to callback. gpioGetServoPulsewidth
gpio.waveClear(cb)
Clear all waveforms (release DMA control blocks, reset wave IDs). gpioWaveClear
gpio.waveCreate(cb)
Returns the wave id of waveform created from previous calls
to waveAddPulse
or waveAddSerial
. gpioWaveCreate
gpio.waveBusy(cb)
Returns 1 if wave is still transmitting, otherwise 0. gpioWaveTxBusy
gpio.waveNotBusy(interval, callback)
Invokes callback
when waveform ends.
Polls waveform status at interval msec. Defaults to 25msec.
gpio.waveAddPulse([Pulse_t], cb)
Add array of Pulse_t to gpio of current
waveform. Pulse_t is a tuple [1, 0, delay] for positive pulse, [0, 1, delay]
for negative pulse width = delay. gpioWaveAddGeneric
.
gpio.waveChainTx([{loop:x}, {waves: [wids]}, {delay:y}, {repeat:z}], cb)
gpioWaveChain
Transmit a chain of waves represented by array of wave IDs [wids]
. The chain can have loops, be separated by delays and repeated by inclusion of option objects.
- loop : x, begins a loop. x can be anything
- delay: y, insert of delay of y=0 to 65535 microseconds
- repeat: z, repeat loop z=0 to 65535 times or forever if z=true
gpio.waveSendSync(wid, cb)
Synchronizes wid
to the currently active
waveform. gpioWaveTxSend
with mode set to PI_WAVE_MODE_ONE_SHOT_SYNC.
gpio.waveSendOnce(wid, cb)
Send the wave id, wid
, one time. gpioWaveTxSend
with mode set to PI_WAVE_MODE_ONE_SHOT.
gpio.waveTxAt(cb)
Return currently active wave id, no wave being transmitted
(9999) or wave not found (9998). gpioWaveTxAt
gpio.waveTxStop(cb)
Aborts the transmission of the current waveform.
This function is intended to stop a waveform started in repeat mode. waveTxStop
gpio.waveDelete(wid, cb)
Delete the wave id wid
. gpioWaveDelete
Note: waveClear
, waveCreate
and waveBusy
are not gpio specific. These methods
are made available to the gpio object for convenience and as a reminder that only
a single waveform can be active.
Note: waveBusy
and waveNotBusy
return status are global indication of waveform state - not specific to gpio!
gpio.notify(callback)
Registers the notification function callback
. callback
is invoked whenever the gpio state changes. Arguments to callback
are level
and tick where tick represents the system's time since boot.
gpio.endNotify(cb)
Unregisters the notification on gpio. For convenience,
a null tick value is sent - useful for stream objects that wrap the notifier callback.
gpio.glitchSet(steady, cb)
Sets a glitch filter (0-300000) on gpio in microseconds. Only effects notifications.
gpioGlitchFilter
gpio.glitchSet(steady, cb)
Sets a glitch filter (0-300000) on gpio in microseconds. Only effects notifications.
gpioGlitchFilter
gpio.serialReadOpen(baudRate, dataBits, cb)
- gpioSerialReadOpen
gpio.serialRead(count, cb)
Returns cb(null, length, buf). buf is Uint8Array
of length length. gpioSerialRead
gpio.serialReadClose(cb)
gpioSerialReadClose
gpio.serialReadInvert(mode, cb)
Mode is 'invert' || 'normal'. gpioSerialReadInvert
waveAddSerial(baud,bits,delay,data,cb)
- gpioWaveAddSerial
serialport.open(baudrate,databits,cb)
Argument baudRate must be a number
from 50 to 250000. Argument dataBits must be a number from 1 to 32. If the rx gpio
is already open for bit-bang serial read the method will close the gpio and then
re-open it.
serialport.read(size, cb)
size is an optional argument representing the
number of bytes to read. If not specified, all the data in pigpio's cyclic buffer
is returned (up to 8192 bytes). Returns cb(null, data) where data is a utf8
string. If the serialport is not open, returns cb(null).
serialport.write(data)
data is utf8 string or Uint8Buffer. The data is
buffered then sent out in chunk sizes that fit the available waveform resources.
Returns the number of bytes remaining in the buffer. If the serialport is not open,
returns -1. Any pigpio errors occurring during write will be thrown to limit the
possibility of data corruption.
serialport.close(cb)
Close serialport.
serialport.end(cb)
Closes rx gpio for bb_serial_read and changes gpios tx and
dtr mode to input.