summaryrefslogtreecommitdiff
path: root/DOC/src
diff options
context:
space:
mode:
Diffstat (limited to 'DOC/src')
-rw-r--r--DOC/src/defs/examples.def521
-rw-r--r--DOC/src/defs/pig2vcd.def110
-rw-r--r--DOC/src/defs/pigpiod.def101
-rw-r--r--DOC/src/defs/pigs.def3482
-rw-r--r--DOC/src/html/download.html68
-rw-r--r--DOC/src/html/ex_LDR.html150
-rw-r--r--DOC/src/html/ex_ir_remote.html253
-rw-r--r--DOC/src/html/ex_motor_shield.html254
-rw-r--r--DOC/src/html/ex_rotary_encoder.html185
-rw-r--r--DOC/src/html/ex_sonar_ranger.html164
-rw-r--r--DOC/src/html/faq.html462
-rw-r--r--DOC/src/html/index.html659
-rw-r--r--DOC/src/html/misc.html33
-rw-r--r--DOC/src/html/pif.html30
-rw-r--r--DOC/src/html/piscope.html216
-rw-r--r--DOC/src/html/sif.html2004
16 files changed, 8692 insertions, 0 deletions
diff --git a/DOC/src/defs/examples.def b/DOC/src/defs/examples.def
new file mode 100644
index 0000000..637a82b
--- /dev/null
+++ b/DOC/src/defs/examples.def
@@ -0,0 +1,521 @@
+The following examples show various ways pigpio may be used to communicate with sensors via the GPIO.
+
+Although many are complete programs they are intended to be a starting point in producing your own code, not an end point.
+
+?0|Index
+
+?0|Hardware
+
+?0|Shell code
+
+?0|C code
+
+?0|C++ code
+
+?0|pigpiod_if2 code
+
+?0|Python code
+
+?0|Miscellaneous related code
+
+?0|External links
+
+?1|Hardware|Hardware
+
+A few practical examples of using pigpio with hardware.
+
+?2|ex_ir_remote|2013-06-09|IR Receiver
+Reading an infrared remote receiver.
+
+?2|ex_LDR|2013-06-09|Light Dependent Resistor
+Measuring brightness with a light dependent resistor (LDR). Improved methods of timing the start of the capacitor recharge are given for <a href="#C_pot_cap_charge_c">C</a> and <a href="#Python_pot_cap_py">Python</a>.
+
+?2|ex_motor_shield|2013-12-15|Motor Shield
+Using an Arduino motor shield.
+
+?2|ex_rotary_encoder|2013-06-09|Rotary Encoder
+Reading a rotary encoder.
+
+?2|ex_sonar_ranger|2013-06-10|Sonar Ranger
+Measuring range with a sonar ranger.
+
+?1|Shell|Shell code
+
+Examples of using pigpio with shell code.
+
+?3|gpiotest|2014-08-11|GPIO test
+This bash script tests the user GPIO. <a href="http://youtu.be/sCJFLKWaxHo">Video</a>
+
+?1|C|C code
+
+Examples of C pigpio programs.
+
+If your program is called foobar.c then build with
+
+gcc -Wall -o foobar foobar.c -lpigpio
+
+?3|freq_count_1|2014-08-20|Frequency Counter 1
+A program showing how to use the <a href="cif.html#gpioSetAlertFunc">gpioSetAlertFunc</a> function to set a callback for GPIO state changes. A frequency count is generated for each monitored GPIO (frequencies up to 500kHz with a sample rate of 1&mu;s).
+
+?3|freq_count_2|2014-08-20|Frequency Counter 2
+A program showing how to use the <a href="cif.html#gpioSetGetSamplesFunc">gpioSetGetSamplesFunc</a> function to set a callback for accumulated GPIO state changes over the last millisecond. A frequency count is generated for each monitored GPIO (frequencies up to 500kHz with a sample rate of 1&mu;s). Generally the method used is more complicated but more efficient than frequency counter 1.
+
+?3|hall|2014-06-13|Hall Effect Sensor
+Program to show status changes for a Hall effect sensor.
+
+?3|I2C_sniffer|2014-06-15|I2C Sniffer
+A program to passively sniff I2C transactions (100kHz bus maximum) and display the results. This C program uses pigpio notifications.
+
+?3|ir_hasher_c|2015-02-25|IR Receiver
+Function to hash a code from an IR receiver (reading an IR remote control).
+
+?3|PCF8591|2014-08-26|PCF8591 YL-40
+A program to display readings from the (I2C) PCF8591.
+
+?3|pot_cap_charge_c|2014-03-14|Pot + Capacitor Recharge Timing
+Function to time capacitor charging (through a resistance). The time can be used to estimate the resistance.
+
+?3|pps_c|2020-07-28|Pulse Per Second generator
+A program to generate a pulse on a GPIO every x seconds (1<=x<=60). The pulse is synced with the wall time second boundary.
+
+?3|rotary_encoder_c|2015-10-03|Rotary Encoder
+Function to decode a mechanical rotary encoder.
+
+?3|rawMCP3008_c|2016-03-20|SPI bit bang MCP3008
+This program shows how to read multiple MCP3008 ADC simultaneously with accurately timed intervals. One 10-bit channel of each ADC may be sampled at up to 25k samples per second.
+
+?3|rawMCP3202_c|2016-03-20|SPI bit bang MCP3202
+This program shows how to read multiple MCP3202 ADC simultaneously with accurately timed intervals. One 12-bit channel of each ADC may be sampled at up to 25k samples per second.
+
+?3|rawMCP3XXX_c|2016-03-20|SPI bit bang MCP3008 and MCP3202
+This program shows how to read multiple MCP3008 and MCP3202 ADC simultaneously with accurately timed intervals. One channel of each ADC may be sampled at up to 25k samples per second. The 10-bit MCP3008 readings are multiplied by 4 so they have the same range (0-4095) as the 12-bit MCP3202.
+
+?3|servo_demo|2016-10-08|Servo Pulse Generator
+This program generates servo pulses on one or more GPIO. Each connected servo is swept between 1000µs and 2000µs at a different speed.
+
+sudo ./servo_demo # Generate pulses on GPIO 4.
+
+sudo ./servo_demo 5 9 20 # Generate pulses on GPIO 5, 9, and 20.
+
+?4|code/spi-pigpio-speed.c|2016-11-06|SPI pigpio driver speed test
+This C code is used to benchmark the pigpio SPI driver on the Pi. The code executes a given number of loops at a given baud rate and bytes per transfer.
+
+?3|wiegand_c|2013-12-30|Wiegand Reader
+Function to read a Wiegand Reader.
+
+?1|C++|C++ code
+
+Examples of C++ pigpio programs.
+
+If your program is called foobar.cpp then build with
+
+g++ -Wall -pthread -o foobar foobar.cpp -lpigpio -lrt
+
+?3|ir_hasher_cpp|2015-02-22|IR Receiver
+Class to hash a code from an IR receiver (reading an IR remote control).
+
+?3|rotary_encoder_cpp|2013-12-30|Rotary Encoder
+Class to decode a mechanical rotary encoder.
+
+?3|wiegand_cpp|2013-12-30|Wiegand Reader
+Class to read a Wiegand Reader.
+
+?1|pdif2|pigpiod_if2 code
+The pigpiod_if2 code examples are linked with libpigpiod_if2 and are written in C.
+
+The pigpiod_if2 library may be compiled and run on any Linux machine and allows control of the GPIO on one or more networked Pis.
+
+It should be possible to adapt the library to run on Macs and PCs.
+
+Each Pi needs the pigpio daemon to be running. The pigpio daemon may be started with the command sudo pigpiod.
+
+?3|_433D|2015-11-17|433MHz Keyfob RX/TX
+Code to read and transmit 313 and 434 MHz key fob codes. The codes to be read must use Manchester encoding. The transmitted codes use Manchester encoding.
+
+./_433D -r10 # Print fob keycodes received on GPIO 10.
+
+./_433D -t5 8246184 # Transmit code on GPIO 5.
+
+./_433D -r10 -t5 8246184 # Transmit code on GPIO 5 then listen for codes
+
+./_433D -? for options.
+
+?3|DHTXXD|2016-02-16|DHT11/21/22/33/44 Sensor
+Code to read the DHT temperature and humidity sensors. The sensor may be auto detected. A DHT11 sensor may be read once per second. The other sensors should not be read more often than once every three seconds.
+
+The code auto detects the DHT model and generally only the GPIO needs to be specified.
+
+./DHTXXD -g17 # Read a DHT connected to GPIO 17.
+
+./DHTXXD -g5 -i3 # Read a DHT connected to GPIO 5 every three seconds.
+
+./DHTXXD -? # for options.
+
+?3|RED|2015-11-18|Rotary Encoder
+Code to monitor a rotary encoder and show the position changes. By default the detent changes are shown. There is an option to show the four steps per detent instead.
+
+./RED -a7 -b8 -s30 # Show encoder on 7/8 detent changes for 30 seconds.
+
+./RED -a5 -b6 -m1 # Show encoder on 5/6 step changes forever.
+
+./RED -? # for options.
+
+?3|servo_demo_D|2016-10-08|Servo Pulse Generator
+This program generates servo pulses on one or more GPIO. Each connected servo is swept between 1000µs and 2000µs at a different speed.
+
+./servo_demo_D # Generate pulses on GPIO 4.
+
+./servo_demo_D 5 9 20 # Generate pulses on GPIO 5, 9, and 20.
+
+?3|SRTED|2015-11-16|Sonar Ranger
+Code to read the SRF-04 and SRF-05 type of sonar rangers which use the trigger echo method of operation. A 10 &mu;s trigger pulse initiates a series of high frequency sonar chirps. The echo line then goes high and stays high until an echo from an object is received. The echo high time is used to calculate the distance of the object.
+
+For a one-off reading only the trigger and echo GPIO need to be specified.
+
+./SRTED -t5 -e6 # Read a sonar ranger connected to GPIO 5/6.
+
+./SRTED -t11 -e5 -i0.1 # Read a sonar ranger connected to GPIO 11/5 every 0.1 seconds.
+
+./SRTED -? # for options.
+
+?3|tx_RED|2015-11-25|Transmit Rotary Encoder Test Signals
+Code to transmit quadrature signals to test rotary encoder software.
+
+tx_RED -aGPIO -bGPIO [options]
+
+tx_RED -? for options
+
+E.g.
+
+tx_RED -a5 -b6 -s20 -r-100
+
+?3|tx_WD|2015-11-25|Transmit Wiegand Test Signals
+Code to transmit Wiegand codes to test Wiegand decoder software.
+
+tx_WD -gGPIO -wGPIO [options] {code}+
+
+tx_WD -? for options
+
+E.g.
+
+tx_WD -g5 -w6 -s37 12345 67890 123 899999
+
+?3|WD|2015-11-25|Wiegand Reader
+Code to read a Wiegand Reader.
+
+./WD -g7 -w8 -s30 # Read Wiegand codes from GPIO 7/8 for 30 seconds.
+
+./WD -g5 -w6 # Read Wiegand codes from GPIO 5/6 forever.
+
+./WD -? # for options.
+
+?1|Python|Python code
+The Python code may be run on any Python machine and allows control of the GPIO on one or more networked Pis.
+
+The Python machine need not be a Pi, it may run Windows, Mac, Linux, anything as long as it supports Python.
+
+Each Pi needs the pigpio daemon to be running. The pigpio daemon may be started with the command sudo pigpiod.
+
+?3|_433_py|2015-10-30|433MHz Keyfob RX/TX
+Classes to send and receive 433MHz wireless keyfob codes. These keyfobs are widely used for remote control of devices.
+
+?3|_7_segment|2016-12-12|7-Segment LED Display Multiplexing
+Script to multiplex several 7-segment LED displays. Each display has the segments a-g and the decimal point connected in parallel but has an individual enable GPIO (connected to the common anode or cathode).
+
+?3|test-APA102_py|2017-03-28|APA102 LED strip driver
+Script to drive an APA102 LED strip. Three different methods are demonstrated - using spidev SPI (only works on the local Pi), pigpio SPI, and pigpio waves. The SPI solutions only work with the dedicated SPI GPIO. Waves may use any spare GPIO. Four different examples are given including a LED strip clock.
+
+?3|BME280_py|2016-08-05|BME280 Sensor
+Class to read the relative humidity, temperature, and pressure from a BME280 sensor. The sensor has both an I2C and a SPI interface which are both
+supported by the class.
+
+?4|code/DHT.py|2019-11-07|DHT11/21/22/33/44 Sensor
+Class to read the relative humidity and temperature from a DHT sensor. It can automatically recognize the sensor type.
+
+The default script prints the reading from the specified DHT every 2 seconds. E.g. ./DHT.py 22 27 displays the data for DHT connected to GPIO 22 and 27.
+
+The following data is printed for each DHT: timestamp, GPIO, status, temperature, and humidity.
+
+The timestamp is the number of seconds since the epoch (start of 1970).
+
+The status will be one of: 0 - a good reading, 1 - checksum failure, 2 - data had one or more invalid values, 3 - no response from sensor.
+
+?3|DHT22_py|2014-07-11|DHT22 AM2302 Sensor
+Class to read the relative humidity and temperature from a DHT22/AM2302 sensor.
+
+?3|DS18B20-1_py|2016-06-29|DS18B20 Temperature Sensor
+Script to read the temperature from any DS18B20 sensors connected to the 1-wire bus.
+
+To enable the 1-wire bus add the following line to /boot/config.txt and reboot.
+
+dtoverlay=w1-gpio
+
+By default you should connect the DS18B20 data line to GPIO 4 (pin 7).
+
+Connect 3V3 or 5V for power, ground to ground, 4k7 pull-up on data line to 3V3, and data line to GPIO 4.
+
+This script uses the file features of pigpio to access the remote file system.
+
+The following entry must be in /opt/pigpio/access.
+
+/sys/bus/w1/devices/28*/w1_slave r
+
+?3|PPD42NS_py|2015-11-22|Dust Sensor
+Class to read a Shinyei PPD42NS Dust Sensor, e.g. as used in the Grove dust sensor.
+
+?3|gpio_status_py|2014-06-12|GPIO Status
+Script to display the status of GPIO 0-31.
+
+?3|hall|2014-06-13|Hall Effect Sensor
+Program to show status changes for a Hall effect sensor.
+
+?3|HX711_py|2018-03-05|HX711 24-bit ADC
+Class to read the channels of a HX711 24-bit ADC.
+
+?3|i2c_ADXL345_py|2015-04-01|I2C ADXL345 Accelerometer
+Script to display the X, Y, and Z values read from an ADXL345 accelerometer.
+
+?3|i2c_HMC5883L_py|2015-04-01|I2C HMC5883L Magnetometer
+Script to display the X, Y, and Z values read from a HMC5883L Magnetometer (compass).
+
+?3|i2c_ITG3205_py|2015-04-01|I2C ITG3205 Gyroscope
+Script to display the X, Y, Z, and temperature values read from an ITG3205 gyroscope.
+
+?3|i2c_lcd_py|2016-04-20|I2C LCD Display
+Class to display text on a LCD character display. The class supports the PCF8574T 8-bit I2C port expander connected to a HD44780 based LCD display. These displays are commonly available in 16x2 and 20x4 character formats.
+
+?3|bsc_arduino_py|2016-10-31|I2C slave device
+This script demonstrates how to transfer messages from an Arduino acting as the I2C bus master to the Pi acting as an I2C slave device.
+
+?3|I2C_sniffer|2015-06-15|I2C Sniffer
+A program to passively sniff I2C transactions (100kHz bus maximum) and display the results.
+
+?3|i2c_sonar_py|2016-03-24|I2C Sonar
+A class to read up to 8 HC-SR04 sonar rangers connected to an MCP23017 port expander.
+
+?3|ir_hasher_py|2014-06-12|IR Receiver
+Class to hash a code from an IR receiver (reading an IR remote control).
+
+?3|irrp_py|2015-12-21|IR Record and Playback
+This script may be used to record and play back arbitrary IR codes.
+
+To record the GPIO connected to the IR receiver, a file for the recorded codes, and the codes to be recorded are given.
+
+E.g. ./irrp.py -r -g4 -fir-codes vol+ vol- 1 2 3 4 5 6 7 8 9 0
+
+To playback the GPIO connected to the IR transmitter, the file containing the recorded codes, and the codes to be played back are given.
+
+E.g. ./irrp.py -p -g18 -fir-codes 2 3 4
+
+./irrp.py -h # for options
+
+?3|kivy_GPIO_py|2016-12-11|Kivy GPIO control
+This example shows how to use Kivy to control a Pi's GPIO. The GPIO may be configured as inputs, outputs, or to generate Servo or PWM pulses. Kivy is an Open source Python library for rapid development of applications.
+
+?3|MAX6675_py|2016-05-02|MAX6675 SPI Temperature Sensor
+A script to read the temperature from a MAX6675 connected to a K-type thermocouple. The MAX6675 supports readings in the range 0 - 1023.75 C. Up to 4 readings may be made per second.
+
+?3|monitor_py|2016-09-17|Monitor GPIO
+Script to monitor GPIO for level changes. By default all GPIO are monitored. At a level change the GPIO, new level, and microseconds since the last change is printed.
+
+?3|morse_code_py|2015-06-17|Morse Code
+Script to transmit the morse code corresponding to a text string.
+
+?4|code/NRF24.py|2018-01-06|NRF24 radio transceiver
+Script to transmit and receive messages using the nRF24L01 radio transceiver.
+
+?3|PCA9685_py|2016-01-31|PCA9685 16 Channel PWM
+Class to control the 16 PWM channels of the I2C PCA9685. All channels use the same frequency. The duty cycle or pulse width may be set independently for each channel.
+
+?3|PCF8591|2014-08-26|PCF8591 YL-40
+Script to display readings from the (I2C) PCF8591.
+
+?4|code/PPM.py|2016-02-19|PPM (Pulse Position Modulation) generation
+Script to generate PPM signals on a chosen GPIO.
+
+?4|code/PPM_to_servo.py|2019-10-09|PPM (Pulse Position Modulation) to servo pulses
+Script to read a PPM signal on a GPIO and generate the corresponding servo signals on chosen GPIO.
+
+?3|bench_1_py|2014-06-12|pigpio Benchmark
+Script to benchmark the pigpio Python module's performance.
+
+?3|pigpio_cgi_py|2015-05-04|pigpio CGI
+Script demonstrating how to access the pigpio daemon using CGI from a browser. Instructions on how to use with Apache2 on the Pi are given in the comments.
+
+?3|playback_py|2016-12-23|Playback piscope recordings
+Script to playback GPIO data recorded in piscope format.
+
+To playback GPIO 4 to GPIO 4 from file data.piscope
+./playback.py data.piscope 4
+
+To playback GPIO 4 to GPIO 7 from file rec.txt
+./playback.py rec.txt 7=4
+
+?3|pot_cap_py|2016-09-26|Pot + Capacitor Recharge Timing
+Class to time capacitor charging (through a resistance). The time can be used to estimate the resistance.
+
+?3|read_PWM_py|2015-12-08|PWM Monitor
+Class to monitor a PWM signal and calculate the frequency, pulse width, and duty cycle.
+
+?3|rotary_encoder_py|2014-06-12|Rotary Encoder
+Class to decode a mechanical rotary encoder.
+
+?3|read_RPM_py|2016-01-20|RPM Monitor
+Class to monitor speedometer pulses and calculate the RPM (Revolutions Per Minute).
+
+?3|Si7021_py|2016-05-07|Si7021 I2C Temperature and Humidity Sensor
+Class to read the temperature and relative humidity from a Si7021.
+
+?3|SPI_mon_py|2016-09-21|SPI Monitor
+A program to passively sniff SPI transactions and display the results. The SPI rate should be limited to about 70kbps if using the default pigpio 5µs sampling rate.
+
+?3|servo_demo_py|2016-10-07|Servo Pulse Generator
+This script generates servo pulses on one or more GPIO. Each connected servo is swept between 1000µs and 2000µs at a different speed.
+
+./servo_demo.py # Generate pulses on GPIO 4.
+
+./servo_demo.py 5 9 20 # Generate pulses on GPIO 5, 9, and 20.
+
+?3|sonar_trigger_echo_py|2014-06-12|Sonar Ranger
+Class to read sonar rangers with separate trigger and echo pins.
+
+?3|TCS3200_py|2015-07-03|TCS3200 Colour Sensor
+Class to read the TCS3200 colour sensor
+
+?3|vw|2015-10-31|Virtual Wire
+Class to send and receive radio messages compatible with the Virtual Wire library for Arduinos. This library is commonly used with 313MHz and 434MHz radio tranceivers.
+
+?4|code/create_wave.py|2019-11-18|Wave create
+Script to generate waves from a template defined in a text file.
+
+You can also specify one of py, c, or pdif - the script output will then be a complete program to generate the wave (py for Python script, c for a C program, pdif for a C program using the pigpio daemon I/F).
+
+If none of py, c, or pdif are chosen the waveform will be generated for 30 seconds.
+
+Example text file
+
+# GPIO levels
+23 11000001
+11 01110000
+12 00011100
+4 00000111
+
+To generate a pdif program with a bit time of 100 microseconds
+./create_wave.py wave_file 100 pdif >wave_pdif.c
+
+To just transmit the wave with a bit time of 50 microseconds
+./create_wave.py wave_file 50
+
+?3|wave_PWM_py|2016-03-19|Wave PWM 1
+Script to show how waves may be used to generate PWM at (one) arbitrary frequency on multiple GPIO. For instance PWM at 10kHz may be generated with 100 steps between off and fully on.
+
+?3|wavePWM_py|2016-10-06|Wave PWM 2
+Class to generate PWM on multiple GPIO. It is more flexible than the Wave PWM 1 example in that the start of the pulse within each cycle may be specified as well as the duty cycle. The start and length of each pulse may be specified on a GPIO by GPIO basis in microseconds or as a fraction of the cycle time. The class includes a __main__ to demostrate its ability to send servo pulses.
+
+?3|wiegand_py|2014-06-12|Wiegand Reader
+Class to read a Wiegand reader.
+
+?1|Misc|Miscellaneous related code
+
+The following code examples do not use pigpio.
+
+?3|adxl345_c|2014-03-12|ADXL345
+This C program reads x, y, and z accelerations from the ADXL345 via I2C address 0x53.
+
+?3|DS18B20_py|2016-04-25|DS18B20 Temperature Sensor
+This Python script reads the temperature from any DS18B20 sensors connected to the 1-wire bus.
+
+To enable the 1-wire bus add the following line to /boot/config.txt and reboot.
+
+dtoverlay=w1-gpio
+
+By default you should connect the DS18B20 data line to GPIO 4 (pin 7).
+
+Connect 3V3 or 5V for power, ground to ground, 4k7 pull-up on data line to 3V3, and data line to GPIO 4.
+
+?3|EasyAsPiServer|2014-09-15|Easy as Pi Server
+This Python class implements a simple server which allows broswer commands to be executed on the Pi.
+
+?3|minimal_clk|2015-05-20|Minimal Clock Access
+This C code sets GPIO 4 to a specified clock frequency. The frequency can be set between 4.6875 kHz and 500 MHz (untested). The clock can be preferentially set from one of the sources OSC (19.2MHz), HDMI (216MHz), PLLD (500MHz), or PLLC (1000MHz). MASH can be set between 0 and 3. MASH may not work properly for clock dividers less than 5.
+
+?3|minimal_gpio|2019-07-03|Minimal GPIO Access
+This C code has a minimal set of functions needed to control the GPIO and other Broadcom peripherals. The program requires root privileges to run. See Tiny GPIO access for an alternative which controls the GPIO (but not the other peripherals) and does not require root access.
+
+The code has been updated for the BCM2711 (Pi4B).
+
+The following functions are provided.
+
+gpioInitialise
+gpioSetMode
+gpioGetMode
+gpioSetPullUpDown
+gpioRead
+gpioWrite
+gpioTrigger
+gpioReadBank1
+gpioReadBank2
+gpioClearBank1
+gpioClearBank2
+gpioSetBank1
+gpioSetBank2
+gpioHardwareRevision
+gpioTick
+
+?3|nanopulse_c|2014-01-29|Nanosecond Pulse Generation
+This C program uses the PWM peripheral to generate precisely timed pulses of very short duration. Pulses as short as 4 nano seconds can be generated.
+
+?3|PCF8591-x|2014-08-26|PCF8591 YL-40
+C and Python code to read the (I2C) PCF8591.
+
+?4|code/spi-driver-speed.c|2016-11-06|SPI Linux driver speed test
+This C code is used to benchmark the Linux SPI driver on the Pi. The code executes a given number of loops at a given baud rate and bytes per transfer.
+
+?3|tiny_gpio|2016-04-30|Tiny GPIO Access
+This C code has a minimal set of functions needed to control the GPIO without needing root privileges (it uses /dev/gpiomem to access the GPIO).
+
+You may need to change the permissions and ownership of /dev/gpiomem if they have not been correctly set up.
+
+sudo chown root:gpio /dev/gpiomem
+sudo chmod g+rw /dev/gpiomem
+
+The user (default pi) needs to be in the gpio group.
+
+sudo adduser pi gpio
+
+The following functions are provided.
+
+gpioInitialise
+gpioSetMode
+gpioGetMode
+gpioSetPullUpDown
+gpioRead
+gpioWrite
+gpioTrigger
+gpioReadBank1
+gpioReadBank2
+gpioClearBank1
+gpioClearBank2
+gpioSetBank1
+gpioSetBank2
+gpioHardwareRevision
+
+?1|External|External links
+
+Related code.
+
+?4|https://pypi.org/project/nrf24/|2020-04-20|NRF24
+Python Package Index (Pypi) NRF24 module.
+pip install nrf24
+
+?4|https://github.com/bjarne-hansen/py-nrf24|2020-04-20|NRF24
+Code and example usage of the Pypi NRF24 module. Cleaned up and added support for reading from multiple pipes using open_reading_pipe(pipe, address) and open_writing_pipe(address) in order to be more "compatible" with the way NRF24 is used on Arduinos.
+
+?4|https://github.com/stripcode/pigpio-stepper-motor|2016-08-12|Stepper Motor
+Stepper motor code.
+
+?4|https://github.com/choeffer/360pibot|2018-11-03|Parallax ActivityBot 360
+Python 3 implementation for programming a Parallax ActivityBot 360 Robot Kit with a Raspberry Pi.
+
+?1|Index|Index
+
diff --git a/DOC/src/defs/pig2vcd.def b/DOC/src/defs/pig2vcd.def
new file mode 100644
index 0000000..48e1013
--- /dev/null
+++ b/DOC/src/defs/pig2vcd.def
@@ -0,0 +1,110 @@
+
+/*TEXT
+pig2vcd is a utility which reads notifications on stdin and writes the
+output as a Value Change Dump (VCD) file on stdout.
+
+The VCD file can be viewed using GTKWave.
+
+*Notifications*
+
+Notifications consist of 12 bytes with the following binary format.
+
+. .
+typedef struct
+{
+ uint16_t seqno;
+ uint16_t flags;
+ uint32_t tick;
+ uint32_t level;
+} gpioReport_t;
+. .
+
+seqno: starts at 0 each time the handle is opened and then increments by one for each report.
+
+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. pig2vcd takes these notifications and outputs a text format VCD.
+
+*VCD format*
+
+The VCD starts with a header.
+
+. .
+$date 2013-05-31 18:49:36 $end
+$version pig2vcd V1 $end
+$timescale 1 us $end
+$scope module top $end
+$var wire 1 A 0 $end
+$var wire 1 B 1 $end
+$var wire 1 C 2 $end
+$var wire 1 D 3 $end
+$var wire 1 E 4 $end
+$var wire 1 F 5 $end
+$var wire 1 G 6 $end
+$var wire 1 H 7 $end
+$var wire 1 I 8 $end
+$var wire 1 J 9 $end
+$var wire 1 K 10 $end
+$var wire 1 L 11 $end
+$var wire 1 M 12 $end
+$var wire 1 N 13 $end
+$var wire 1 O 14 $end
+$var wire 1 P 15 $end
+$var wire 1 Q 16 $end
+$var wire 1 R 17 $end
+$var wire 1 S 18 $end
+$var wire 1 T 19 $end
+$var wire 1 U 20 $end
+$var wire 1 V 21 $end
+$var wire 1 W 22 $end
+$var wire 1 X 23 $end
+$var wire 1 Y 24 $end
+$var wire 1 Z 25 $end
+$var wire 1 a 26 $end
+$var wire 1 b 27 $end
+$var wire 1 c 28 $end
+$var wire 1 d 29 $end
+$var wire 1 e 30 $end
+$var wire 1 f 31 $end
+$upscope $end
+$enddefinitions $end
+. .
+
+The header defines gpio identifiers and their name. Each gpio identifier
+must be unique. pig2vcd arbitrarily uses 'A' through 'Z' for gpios 0
+through 25, and 'a' through 'f' for gpios 26 through 31.
+The corresponding names are 0 through 31.
+
+The VCD file may be edited to give a frendlier name, e.g. 8 could be
+changed to ENCODER_A if an encoder switch A is connected to gpio 8.
+
+Following the header pig2vcd takes notifications and outputs a timestamp
+followed by a list of one or more gpios which have changed state.
+The timestamp consists of a '#' followed by the microsecond tick.
+The state lines contain the new state followed by the gpio identifier.
+
+. .
+#1058747
+0H
+0I
+#1059012
+1H
+#1079777
+1I
+#1079782
+0I
+#1079852
+1I
+#1079857
+0I
+0H
+#1165113
+1H
+#1165118
+0H
+#1165153
+1H
+. .
+TEXT*/
diff --git a/DOC/src/defs/pigpiod.def b/DOC/src/defs/pigpiod.def
new file mode 100644
index 0000000..f4f0781
--- /dev/null
+++ b/DOC/src/defs/pigpiod.def
@@ -0,0 +1,101 @@
+
+/*TEXT
+pigpiod is a utility which launches the pigpio library as a daemon.
+
+Once launched the pigpio library runs in the background accepting commands from the pipe and socket interfaces.
+
+The pigpiod utility requires sudo privileges to launch the library but thereafter the pipe and socket commands may be issued by normal users.
+
+pigpiod accepts the following configuration options
+
+TEXT*/
+/*O
+-a value|DMA memory allocation mode|0=AUTO, 1=PMAP, 2=MBOX|Default AUTO
+-b value|GPIO sample buffer size in milliseconds|100-10000|Default 120
+-c value|Library internal settings||Default 0
+-d value|Primary DMA channel|0-14|Default 14
+-e value|Secondary DMA channel|0-14|Default 6. Preferably use one of DMA channels 0 to 6 for the secondary channel
+-f|Disable fifo interface||Default enabled
+-g|Run in foreground (do not fork)||Default disabled
+-k|Disable local and remote socket interface||Default enabled
+-l|Disable remote socket interface||Default enabled
+-m|Disable alerts (sampling)||Default enabled
+-n IP address|Allow IP address to use the socket interface|Name (e.g. paul) or dotted quad (e.g. 192.168.1.66)|If the -n option is not used all addresses are allowed (unless overridden by the -k or -l options). Multiple -n options are allowed. If -k has been used -n has no effect. If -l has been used only -n localhost has any effect
+-p value|Socket port|1024-32000|Default 8888
+-s value|Sample rate|1, 2, 4, 5, 8, or 10 microseconds|Default 5
+-t value|Clock peripheral|0=PWM 1=PCM|Default PCM. pigpio uses one or both of PCM and PWM. If PCM is used then PWM is available for audio. If PWM is used then PCM is available for audio. If waves or hardware PWM are used neither PWM nor PCM will be available for audio.
+-v -V|Display pigpio version and exit||
+-x mask|GPIO which may be updated|A 54 bit mask with (1<<n) set if the user may update GPIO #n|Default is the set of user GPIO for the board revision. Use -x -1 to allow all GPIO
+O*/
+
+/*TEXT
+
+*Example*
+
+. .
+sudo pigpiod -s 2 -b 200 -f
+. .
+
+Launch the pigpio library with a sample rate of 2 microseconds and a 200 millisecond buffer. Disable the fifo interface.
+
+*Permissions*
+
+pigpio provides a rudimentary permissions system for commands issued via the socket and pipe interfaces.
+
+All GPIO may be read.
+
+Only the user GPIO for the board type or those specified by the -x option may be updated.
+
+. .
+Type 1 boards 0x03E6CF93 (26 pin header)
+Type 2 boards 0xFBC6CF9C (26 pin + 8 pin header)
+Type 3 boards 0x0FFFFFFC (40 pin header)
+. .
+
+In this context an update includes the following:
+
+GPIO mode set
+GPIO pull/up down
+GPIO write
+GPIO set PWM (including range and frequency)
+GPIO set servo
+
+In addition the bank clear and set commands, and the wave commands will only
+affect updateable GPIO.
+
+*Exceptions*
+
+The following exceptions are made for particular models.
+
+^Models A and B^
+
+The green activity LED (GPIO 16) may be written.
+^Models A+ and B+^
+
+The green activity LED (GPIO 47) may be written.
+The red power LED (GPIO 35) may be written.
+The high USB power mode (GPIO 38) may be written.
+^Pi Zero^
+
+The green activity LED (GPIO 47) may be written.
+^Pi2B^
+
+The green activity LED (GPIO 47) may be written.
+The red power LED (GPIO 35) may be written.
+The high USB power mode (GPIO 38) may be written.
+^Pi3B^
+
+The green activity LED and the red power LED are not writable.
+The USB power mode is fixed at 1.2 amps (high power).
+
+*DMA Channels*
+
+The secondary channel is only used for the transmission of waves.
+
+If possible use one of channels 0 to 6 for the secondary channel (a full channel).
+
+A full channel only requires one DMA control block regardless of the length of a pulse delay. Channels 7 to 14 (lite channels) require one DMA control block for each 16383 microseconds of delay. I.e. a 10 second pulse delay requires one control block on a full channel and 611 control blocks on a lite channel.
+
+TEXT*/
+
+
diff --git a/DOC/src/defs/pigs.def b/DOC/src/defs/pigs.def
new file mode 100644
index 0000000..f678126
--- /dev/null
+++ b/DOC/src/defs/pigs.def
@@ -0,0 +1,3482 @@
+INTRO
+
+The socket and pipe interfaces allow control of the Pi's GPIO by
+passing messages to the running pigpio library.
+
+The normal way to start the pigpio library would be as a daemon during boot.
+
+...
+sudo pigpiod
+...
+
+*Features*
+
+o hardware timed PWM on any of GPIO 0-31
+
+o hardware timed servo pulses on any of GPIO 0-31
+
+o reading/writing all of the GPIO in a bank as one operation
+
+o individually setting GPIO modes, reading and writing
+
+o notifications when any of GPIO 0-31 change state
+
+o the construction of output waveforms with microsecond timing
+
+o I2C, SPI, and serial link wrappers
+
+o creating and running scripts on the pigpio daemon
+
+*GPIO*
+
+ALL GPIO are identified by their Broadcom number.
+
+*Usage*
+
+pigs is a program and internally uses the socket interface to pigpio
+whereas /dev/pigpio uses the pipe interface.
+
+pigs and the pipe interface share the same commands and are invoked in
+a similar fashion from the command line.
+
+The pigpio library must be running, either by running a program linked
+with the library or starting the pigpio daemon (sudo pigpiod).
+
+pigs {command}+
+
+echo "{command}+" >/dev/pigpio
+
+pigs will show the result of the command on screen.
+
+The pigs process returns an exit status (which can be displayed with
+the command echo $?).
+
+...
+PIGS_OK 0
+PIGS_CONNECT_ERR 255
+PIGS_OPTION_ERR 254
+PIGS_SCRIPT_ERR 253
+...
+
+The results of /dev/pigpio commands need to be read from /dev/pigout,
+e.g. cat /dev/pigout (try cat /dev/pigout& so that all subsequent
+results are shown on screen).
+
+In both cases if an error was detected a message will have been written
+to /dev/pigerr (try cat /dev/pigerr&). This is likely to be more
+informative than the message returned by pigs or the error code
+returned by the pipe interface.
+
+Several commands may be entered on a line. If present PROC and PARSE must
+be the last command on a line.
+
+E.g.
+
+...
+pigs w 22 1 mils 1000 w 22 0
+...
+
+is equivalent to
+
+...
+pigs w 22 1
+pigs mils 1000
+pigs w 22 0
+...
+
+and
+
+...
+echo "m 4 w w 4 0 mils 250 m 4 r r 4" >/dev/pigpio
+...
+
+is equivalent to
+
+...
+echo "m 4 w" >/dev/pigpio
+echo "w 4 0" >/dev/pigpio
+echo "mils 250" >/dev/pigpio
+echo "m 4 r" >/dev/pigpio
+echo "r 4" >/dev/pigpio
+...
+
+*Notes*
+
+The examples from now on will show the pigs interface but the same
+commands will also work on the pipe interface.
+
+pigs does not show the status of successful commands unless the
+command itself returns data. The status (0) will be returned to
+pigs but will be discarded.
+
+The status/data of each command sent to the pipe interface should
+be read from /dev/pigout.
+
+When a command takes a number as a parameter it may be entered as hex
+(precede by 0x), octal (precede by 0), or decimal.
+
+E.g. 23 is 23 decimal, 0x100 is 256 decimal, 070 is 56 decimal.
+
+Some commands can return a variable number of data bytes. By
+default this data is displayed as decimal. The pigs -a option
+can be used to force the display as ASCII and the pigs -x
+option can be used to force the display as hex.
+
+E.g. assuming the transmitted serial data is the letters ABCDEONM
+
+...
+$ pigs slr 4 100
+8 65 66 67 68 69 79 78 77
+
+$ pigs -a slr 4 100
+8 ABCDEONM
+
+$ pigs -x slr 4 100
+8 41 42 43 44 45 4f 4e 4d
+...
+
+OVERVIEW
+
+BASIC
+
+M/MODES g m :: Set GPIO mode :: gpioSetMode
+MG/MODEG g :: Get GPIO mode :: gpioGetMode
+
+PUD g p :: Set GPIO pull up/down :: gpioSetPullUpDown
+
+R/READ g :: Read GPIO level :: gpioRead
+W/WRITE g L :: Write GPIO level :: gpioWrite
+
+PWM (overrides servo commands on same GPIO)
+
+P/PWM u v :: Set GPIO PWM value :: gpioPWM
+PFS u v :: Set GPIO PWM frequency :: gpioSetPWMfrequency
+PRS u v :: Set GPIO PWM range :: gpioSetPWMrange
+
+GDC u :: Get GPIO PWM dutycycle :: gpioGetPWMdutycycle
+PFG u :: Get GPIO PWM frequency :: gpioGetPWMfrequency
+PRG u :: Get GPIO PWM range :: gpioGetPWMrange
+
+PRRG u :: Get GPIO PWM real range :: gpioGetPWMrealRange
+
+Servo (overrides PWM commands on same GPIO)
+
+S/SERVO u v :: Set GPIO servo pulsewidth :: gpioServo
+
+GPW u :: Get GPIO servo pulsewidth :: gpioGetServoPulsewidth
+
+INTERMEDIATE
+
+TRIG u pl L :: Send a trigger pulse :: gpioTrigger
+
+WDOG u v :: Set GPIO watchdog :: gpioSetWatchdog
+
+BR1 :: Read bank 1 GPIO :: gpioRead_Bits_0_31
+BR2 :: Read bank 2 GPIO :: gpioRead_Bits_32_53
+
+BC1 bits :: Clear specified GPIO in bank 1 :: gpioWrite_Bits_0_31_Clear
+BC2 bits :: Clear specified GPIO in bank 2 :: gpioWrite_Bits_32_53_Clear
+
+BS1 bits :: Set specified GPIO in bank 1 :: gpioWrite_Bits_0_31_Set
+BS2 bits :: Set specified GPIO in bank 2 :: gpioWrite_Bits_32_53_Set
+
+ADVANCED
+
+NO :: Request a notification :: gpioNotifyOpen
+NC h :: Close notification :: gpioNotifyClose
+NB h bits :: Start notification :: gpioNotifyBegin
+NP h :: Pause notification :: gpioNotifyPause
+
+HC g cf :: Set hardware clock frequency :: gpioHardwareClock
+
+HP g pf pdc :: Set hardware PWM frequency and dutycycle :: gpioHardwarePWM
+
+FG u stdy :: Set a glitch filter on a GPIO :: gpioGlitchFilter
+FN u stdy actv :: Set a noise filter on a GPIO :: gpioNoiseFilter
+
+PADS pad padma :: Set pad drive strength :: gpioSetPad
+PADG pad :: Get pad drive strength :: gpioGetPad
+
+SHELL name str :: Execute a shell command :: shell
+
+Custom
+
+CF1 uvs :: Custom function 1 :: gpioCustom1
+CF2 uvs :: Custom function 2 :: gpioCustom1
+
+Events
+
+EVM h bits :: Set events to monitor :: eventMonitor
+EVT event :: Trigger event :: eventTrigger
+
+Scripts
+
+PROC t :: Store script :: gpioStoreScript
+PROCR sid pars :: Run script :: gpioRunScript
+PROCU sid pars :: Set script parameters :: gpioUpdateScript
+PROCP sid :: Get script status and parameters :: gpioScriptStatus
+PROCS sid :: Stop script :: gpioStopScript
+PROCD sid :: Delete script :: gpioDeleteScript
+
+PARSE t :: Validate script :: gpioParseScript
+
+I2C
+
+I2CO ib id if :: Open I2C bus and device with flags :: i2cOpen
+I2CC h :: Close I2C handle :: i2cClose
+
+I2CWQ h bit :: smb Write Quick: write bit :: i2cWriteQuick
+
+I2CRS h :: smb Read Byte: read byte :: i2cReadByte
+I2CWS h bv :: smb Write Byte: write byte :: i2cWriteByte
+
+I2CRB h r :: smb Read Byte Data: read byte from register :: i2cReadByteData
+I2CWB h r bv :: smb Write Byte Data: write byte to register :: i2cWriteByteData
+
+I2CRW h r :: smb Read Word Data: read word from register :: i2cReadWordData
+I2CWW h r wv :: smb Write Word Data: write word to register :: i2cWriteWordData
+
+I2CRK h r :: smb Read Block Data: read data from register :: i2cReadBlockData
+I2CWK h r bvs :: smb Write Block Data: write data to register :: i2cWriteBlockData
+
+I2CWI h r bvs :: smb Write I2C Block Data :: i2cWriteI2CBlockData
+I2CRI h r num :: smb Read I2C Block Data: read bytes from register :: i2cReadI2CBlockData
+
+I2CRD h num :: i2c Read device :: i2cReadDevice
+I2CWD h bvs :: i2c Write device :: i2cWriteDevice
+
+I2CPC h r wv :: smb Process Call: exchange register with word :: i2cProcessCall
+I2CPK h r bvs :: smb Block Process Call: exchange data bytes with register :: i2cBlockProcessCall
+
+I2CZ h bvs :: Performs multiple I2C transactions :: i2cZip
+
+I2C BIT BANG
+
+BI2CO sda scl b :: Open bit bang I2C :: bbI2COpen
+BI2CC sda :: Close bit bang I2C :: bbI2CClose
+
+BI2CZ sda bvs :: I2C bit bang multiple transactions :: bbI2CZip
+
+I2C/SPI SLAVE
+
+BSCX bctl bvs :: BSC I2C/SPI transfer :: bscXfer
+
+SERIAL
+
+SERO dev b sef :: Open serial device dev at baud b with flags :: serOpen
+SERC h :: Close serial handle :: serClose
+
+SERRB :: Read byte from serial handle :: serReadByte
+SERWB h bv :: Write byte to serial handle :: serWriteByte
+
+SERR h num :: Read bytes from serial handle :: serRead
+SERW h bvs :: Write bytes to serial handle :: serWrite
+
+SERDA h :: Check for serial data ready to read :: serDataAvailable
+
+SERIAL BIT BANG (read only)
+
+SLRO u b db :: Open GPIO for bit bang serial data :: gpioSerialReadOpen
+SLRC u :: Close GPIO for bit bang serial data :: gpioSerialReadClose
+
+SLRI u v :: Sets bit bang serial data logic levels :: gpioSerialReadInvert
+
+SLR u num :: Read bit bang serial data from GPIO :: gpioSerialRead
+
+SPI
+
+SPIO c b spf :: SPI open channel at baud b with flags :: spiOpen
+SPIC h :: SPI close handle :: spiClose
+
+SPIR h num :: SPI read bytes from handle :: spiRead
+SPIW h bvs :: SPI write bytes to handle :: spiWrite
+SPIX h bvs :: SPI transfer bytes to handle :: spiXfer
+
+SPI BIT BANG
+
+BSPIO cs miso mosi sclk b spf :: Open bit bang SPI :: bbSPIOpen
+BSPIC cs :: Close bit bang SPI :: bbSPIClose
+
+BSPIX cs bvs :: SPI bit bang transfer :: bbSPIXfer
+
+FILES
+
+FO file mode :: Open a file in mode :: fileOpen
+FC h :: Close file handle :: fileClose
+
+FR h num :: Read bytes from file handle :: fileRead
+FW h bvs :: Write bytes to file handle :: fileWrite
+
+FS h num from :: Seek to file handle position :: fileSeek
+
+FL pat num :: List files which match pattern :: fileList
+
+WAVES
+
+WVCLR :: Clear all waveforms :: gpioWaveClear
+
+WVNEW :: Initialise a new waveform :: gpioWaveAddNew
+WVAG trips :: Add generic pulses to waveform :: gpioWaveAddGeneric
+WVAS u b db sb o bvs :: Add serial data to waveform :: gpioWaveAddSerial
+
+WVCRE :: Create a waveform :: gpioWaveCreate
+WVCAP percent :: Create a waveform of fixed size :: gpioWaveCreatePad
+WVDEL wid :: Delete selected waveform :: gpioWaveDelete
+
+WVTX wid :: Transmits waveform once :: gpioWaveTxSend
+WVTXM wid wmde :: Transmits waveform using mode :: gpioWaveTxSend
+WVTXR wid :: Transmits waveform repeatedly :: gpioWaveTxSend
+
+WVCHA bvs :: Transmits a chain of waveforms :: gpioWaveChain
+
+WVTAT :: Returns the current transmitting waveform :: gpioWaveTxAt
+
+WVBSY :: Check if waveform is being transmitted :: gpioWaveTxBusy
+
+WVHLT :: Stop waveform :: gpioWaveTxStop
+
+WVSC ws :: Get waveform DMA CB stats :: gpioWaveGetCbs
+WVSM ws :: Get waveform time stats :: gpioWaveGetMicros
+WVSP ws :: Get waveform pulse stats :: gpioWaveGetPulses
+
+UTILITIES
+
+H/HELP :: Display command help ::
+HWVER :: Get hardware version :: gpioHardwareRevision
+MICS v :: Microseconds delay :: gpioDelay
+MILS v :: Milliseconds delay :: gpioDelay
+PIGPV :: Get pigpio library version :: gpioVersion
+T/TICK :: Get current tick :: gpioTick
+
+CONFIGURATION
+
+CGI :: Configuration get internals :: gpioCfgGetInternals
+CSI v :: Configuration set internals :: gpioCfgSetInternals
+
+COMMANDS
+
+BC1 ::
+This command clears (sets low) the GPIO specified by [*bits*] in bank 1.
+Bank 1 consists of GPIO 0-31.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs bc1 0x400010 # clear GPIO 4 (1<<4) and 22 (1<<22)
+
+$ pigs bc1 32 # clear GPIO 5 (1<<5)
+-42
+ERROR: no permission to update one or more GPIO
+...
+
+BC2 ::
+This command clears (sets low) the GPIO specified by [*bits*] in bank 2.
+Bank 2 consists of GPIO 32-53.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs bc2 0x8000 # clear GPIO 47 (activity LED on A+/B+/Pi2/Pi3)
+
+$ pigs bc2 1 # clear GPIO 32 (first in bank 2)
+-42
+ERROR: no permission to update one or more GPIO
+...
+
+BI2CC ::
+This command signals that bit banging I2C on [*sda*] (and [*scl*]) is no
+longer required.
+
+...
+$ pigs bi2cc 5
+...
+
+BI2CO ::
+This command signals that GPIO [*sda*] and [*scl*] are to be used
+for bit banging I2C at [*b*] baud.
+
+Bit banging I2C allows for certain operations which are not possible
+with the standard I2C driver.
+
+o baud rates as low as 50
+o repeated starts
+o clock stretching
+o I2C on any pair of spare GPIO
+
+The baud rate may be between 50 and 500000 bits per second.
+
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
+a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
+
+BI2CZ ::
+This function executes a sequence of bit banged I2C operations. The
+operations to be performed are specified by the contents of [*bvs*]
+which contains the concatenated command codes and associated data.
+
+The following command codes are supported:
+
+Name @ Cmd & Data @ Meaning
+End @ 0 @ No more commands
+Escape @ 1 @ Next P is two bytes
+Start @ 2 @ Start condition
+Stop @ 3 @ Stop condition
+Address @ 4 P @ Set I2C address to P
+Flags @ 5 lsb msb @ Set I2C flags to lsb + (msb << 8)
+Read @ 6 P @ Read P bytes of data
+Write @ 7 P ... @ Write P bytes of data
+
+The address, read, and write commands take a parameter P.
+Normally P is one byte (0-255). If the command is preceded by
+the Escape command then P is two bytes (0-65535, least significant
+byte first).
+
+The address and flags default to 0. The address and flags maintain
+their previous value until updated.
+
+No flags are currently defined.
+
+...
+Set address 0x53
+start, write 0x32, (re)start, read 6 bytes, stop
+Set address 0x1E
+start, write 0x03, (re)start, read 6 bytes, stop
+Set address 0x68
+start, write 0x1B, (re)start, read 8 bytes, stop
+End
+
+0x04 0x53
+0x02 0x07 0x01 0x32 0x02 0x06 0x06 0x03
+
+0x04 0x1E
+0x02 0x07 0x01 0x03 0x02 0x06 0x06 0x03
+
+0x04 0x68
+0x02 0x07 0x01 0x1B 0x02 0x06 0x08 0x03
+
+0x00
+...
+
+BR1 ::
+This command read GPIO 0-31 (bank 1) and returns the levels as a
+32-bit hexadecimal value.
+
+...
+$ pigs br1
+1001C1CF
+...
+
+BR2 ::
+This command read GPIO 32-53 (bank 2) and returns the levels as a
+32-bit hexadecimal value.
+
+...
+$ pigs br2
+003F0000
+...
+
+BS1 ::
+This command sets (sets high) the GPIO specified by [*bits*] in bank 1.
+Bank 1 consists of GPIO 0-31.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs bs1 16 # set GPIO 4 (1<<4)
+
+$ pigs bs1 1 # set GPIO 1 (1<<0)
+-42
+ERROR: no permission to update one or more GPIO
+...
+
+BS2 ::
+This command sets (sets high) the GPIO specified by [*bits*] in bank 2.
+Bank 2 consists of GPIO 32-53.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs bs2 0x40 # set GPIO 38 (enable high current mode A+/B+/Pi2/Pi3)
+
+$ pigs bs2 1 # set GPIO 32 (first in bank 2)
+-42
+ERROR: no permission to update one or more GPIO
+...
+
+BSCX ::
+
+This command performs a BSC I2C/SPI slave transfer as defined by
+[*bctl*] with data [*bvs*].
+
+This function provides a low-level interface to the SPI/I2C Slave
+peripheral on the BCM chip.
+
+This peripheral allows the Pi to act as a hardware slave device
+on an I2C or SPI bus.
+
+This is not a bit bang version and as such is OS timing
+independent. The bus timing is handled directly by the chip.
+
+The output process is simple. You simply append data to the FIFO
+buffer on the chip. This works like a queue, you add data to the
+queue and the master removes it.
+
+I can't get SPI to work properly. I tried with a
+control word of 0x303 and swapped MISO and MOSI.
+
+The command sets the BSC mode and writes any data [*bvs*]
+to the BSC transmit FIFO. It returns the data count (at least 1
+for the status word), the status word, followed by any data bytes
+read from the BSC receive FIFO.
+
+Note that the control word sets the BSC mode. The BSC will stay in
+that mode until a different control word is sent.
+
+For I2C use a control word of (I2C address << 16) + 0x305.
+
+E.g. to talk as I2C slave with address 0x13 use 0x130305.
+
+GPIO used for models other than those based on the BCM2711.
+
+ @ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
+I2C @ 18 @ 19 @ - @ - @ - @ -
+SPI @ - @ - @ 18 @ 19 @ 20 @ 21
+
+GPIO used for models based on the BCM2711 (e.g. the Pi4B).
+
+ @ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
+I2C @ 10 @ 11 @ - @ - @ - @ -
+SPI @ - @ - @ 10 @ 11 @ 9 @ 8
+
+When a zero control word is received the used GPIO will be reset
+to INPUT mode.
+
+The control word consists of the following bits.
+
+. .
+22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+ a a a a a a a - - IT HC TF IR RE TE BK EC ES PL PH I2 SP EN
+. .
+
+Bits 0-13 are copied unchanged to the BSC CR register. See
+pages 163-165 of the Broadcom peripherals document for full
+details.
+
+aaaaaaa @ defines the I2C slave address (only relevant in I2C mode)
+IT @ invert transmit status flags
+HC @ enable host control
+TF @ enable test FIFO
+IR @ invert receive status flags
+RE @ enable receive
+TE @ enable transmit
+BK @ abort operation and clear FIFOs
+EC @ send control register as first I2C byte
+ES @ send status register as first I2C byte
+PL @ set SPI polarity high
+PH @ set SPI phase high
+I2 @ enable I2C mode
+SP @ enable SPI mode
+EN @ enable BSC peripheral
+
+The returned status has the following format
+
+. .
+20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+ S S S S S R R R R R T T T T T RB TE RF TF RE TB
+. .
+
+Bits 0-15 are copied unchanged from the BSC FR register. See
+pages 165-166 of the Broadcom peripherals document for full
+details.
+
+SSSSS @ number of bytes successfully copied to transmit FIFO
+RRRRR @ number of bytes in receieve FIFO
+TTTTT @ number of bytes in transmit FIFO
+RB @ receive busy
+TE @ transmit FIFO empty
+RF @ receive FIFO full
+TF @ transmit FIFO full
+RE @ receive FIFO empty
+TB @ transmit busy
+
+This example assumes that GPIO 2/3 are connected to GPIO 18/19
+(GPIO 10/11 on the BCM2711).
+
+...
+$ pigs bscx 0x130305 # start BSC as I2C slave 0x13
+1 18
+
+$ i2cdetect -y 1
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f
+00: -- -- -- -- -- -- -- -- -- -- -- -- --
+10: -- -- -- 13 -- -- -- -- -- -- -- -- -- -- -- --
+20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+70: -- -- -- -- -- -- -- --
+
+$ pigs i2co 1 0x13 0 # get handle for device 0x13 on bus 1
+0
+
+$ pigs i2cwd 0 90 87 51 9 23 # write 5 bytes
+
+$ pigs bscx 0x130305 # check for data
+6 18 90 87 51 9 23
+
+$ pigs bscx 0x130305 11 13 15 17 # check for data and send 4 bytes
+1 262338
+
+$ pigs i2crd 0 4 # read 4 bytes
+4 11 13 15 17
+
+$ pigs i2cwd 0 90 87 51 9 23 # write 5 bytes
+$ pigs bscx 0x130305 11 13 15 17 # check for data and send 4 bytes
+6 262338 90 87 51 9 23
+
+$ pigs i2crd 0 4
+4 11 13 15 17
+
+$ pigs bscx 0x130305 22 33 44 55 66
+1 327938
+$ pigs i2crd 0 5
+5 22 33 44 55 66
+...
+
+BSPIC ::
+
+This command stops bit banging SPI on a set of GPIO
+opened with [*BSPIO*].
+
+The set of GPIO is specifed by [*cs*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs bspic 10
+
+$ pigs bspic 10
+-142
+ERROR: no bit bang SPI in progress on GPIO
+...
+
+BSPIO ::
+
+This command starts bit banging SPI on a group of GPIO with slave
+select [*cs*], MISO [*miso*], MOSI [*mosi*], and clock [*sclk*].
+
+Data will be transferred at baud [*b*] bits per second (which may
+be set in the range 50-250000).
+
+The flags [*spf*] may be used to modify the default behaviour of
+mode 0, active low chip select.
+
+The 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
+ 0 0 0 0 0 0 R T 0 0 0 0 0 0 0 0 0 0 0 p m m
+. .
+
+mm defines the SPI mode.
+
+. .
+Mode POL PHA
+ 0 0 0
+ 1 0 1
+ 2 1 0
+ 3 1 1
+. .
+
+p is 0 if CS is active low (default) and 1 for active high.
+
+T is 1 if the least significant bit is transmitted on MOSI first, the
+default (0) shifts the most significant bit out first.
+
+R is 1 if the least significant bit is received on MISO first, the
+default (0) receives the most significant bit first.
+
+The other bits in flags should be set to zero.
+
+Upon success 0 is returned. On error a negative status code
+will be returned.
+
+If more than one device is connected to the SPI bus (defined by
+SCLK, MOSI, and MISO) each must have its own CS.
+
+...
+$ pigs bspio 9 11 12 13 50000 0
+
+$ pigs bspio 10 11 12 13 50000 0
+
+$ pigs bspio 29 19 20 21 50000 0 # GPIO 29 not avaialble on this Pi
+-41
+ERROR: no permission to update GPIO
+...
+
+BSPIX::
+
+This command writes bytes [*bvs*] to the bit bang SPI device
+associated with slave select [*cs*]. It returns the same
+number of bytes read from the device.
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+...
+$ pigs bspio 5 13 19 12 10000 0 # MCP4251 DAC
+$ pigs bspio 6 13 19 12 20000 3 # MCP3008 ADC
+
+$ pigs bspix 5 0 16 # set DAC to 16
+2 255 255
+
+$ pigs bspix 5 12 0 # read back DAC
+2 254 16
+
+$ pigs bspix 6 1 128 0 # read ADC input 0
+3 0 3 184 # 952
+
+$ pigs bspix 5 0 240 # set DAC to 240
+2 255 255
+
+$ pigs bspix 5 12 0 # read back DAC
+2 254 240
+
+$ pigs bspix 6 1 128 0 # read ADC input 0
+3 0 0 63 # 63
+
+$ pigs bspix 5 0 128 # set DAC to 128
+2 255 255
+
+$ pigs bspix 5 12 0 # read back DAC
+2 254 128
+
+$ pigs bspix 6 1 128 0 # read ADC input 0
+3 0 1 255 # 511
+
+$ pigs bspic 5 # close SPI CS 5
+$ pigs bspic 6 # close SPI CS 6
+
+$ pigs bspic 5 # try to close SPI CS 5 again
+-142
+ERROR: no bit bang SPI in progress on GPIO
+...
+
+
+CF1::
+
+This command calls a user customised function. The meaning of
+any paramaters and the returned value is defined by the
+customiser.
+
+CF2::
+
+This command calls a user customised function. The meaning of
+any paramaters and the returned value is defined by the
+customiser.
+
+CGI::
+This command returns the value of the internal library
+configuration settings.
+
+CSI::
+This command sets the value of the internal library
+configuration settings to [*v*].
+
+EVM ::
+This command starts event reporting on handle [*h*] (returned by
+a prior call to [*NO*]).
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The notification gets reports for each event specified by [*bits*].
+
+...
+$ pigs evm 0 -1 # Shorthand for events 0-31.
+$ pigs evm 0 0xf0 # Get notifications for events 4-7.
+
+$ pigs evm 1 0xf
+-25
+ERROR: unknown handle
+...
+
+EVT ::
+This command triggers event [*event*].
+
+One event, number 31, is predefined. This event is
+auto generated on BSC slave activity.
+
+...
+$ pigs evt 12
+$ pigs evt 5
+
+$ pigs evt 32
+-143
+ERROR: bad event id
+...
+
+FC::
+This command closes a file handle [*h*] previously opened with [*FO*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs fc 0 # First close okay.
+
+$ pigs fc 0 # Second fails.
+-25
+ERROR: unknown handle
+...
+
+FG ::
+
+Level changes on the GPIO [*u*] are not reported unless the level
+has been stable for at least [*stdy*] microseconds. The
+level is then reported. Level changes of less than [*stdy*]
+microseconds are ignored.
+
+The filter only affects callbacks (including pipe notifications).
+
+The [*R/READ*], [*BR1*], and [*BR2*] commands are not affected.
+
+Note, each (stable) edge will be timestamped [*stdy*] microseconds
+after it was first detected.
+
+...
+$ pigs fg 4 250
+
+$ pigs fg 4 1000000
+-125
+ERROR: bad filter parameter
+...
+
+FL ::
+This command returns a list of the files matching [*pat*]. Up
+to [*num*] bytes may be returned.
+
+Upon success the count of returned bytes followed by the matching
+files is returned. On error a negative status code will be returned.
+
+A newline (0x0a) character separates each file name.
+
+Only files which have a matching entry in /opt/pigpio/access may
+be listed.
+
+Suppose /opt/pigpio/access contains
+
+/sys/bus/w1/devices/28*/w1_slave r
+
+...
+$ pigs -a fl "/sys/bus/w1/devices/28*/w1_slave" 5000
+90 /sys/bus/w1/devices/28-000005d34cd2/w1_slave
+/sys/bus/w1/devices/28-001414abbeff/w1_slave
+
+$ pigs -a fl "/sys/bus/*" 5000
+ERROR: no permission to access file
+-137
+...
+
+FN ::
+
+Level changes on the GPIO [*u*] are ignored until a level which has
+been stable for [*stdy*] microseconds is detected. Level
+changes on the GPIO are then reported for [*actv*] microseconds
+after which the process repeats.
+
+The filter only affects callbacks (including pipe notifications).
+
+The [*R/READ*], [*BR1*], and [*BR2*] commands are not affected.
+
+Note, level changes before and after the active period may
+be reported. Your software must be designed to cope with
+such reports.
+
+...
+$ pigs fn 7 250 1000
+
+$ pigs fn 7 2500000 1000
+-125
+ERROR: bad filter parameter
+...
+
+FO ::
+This function returns a handle to a file [*file*] opened
+in a specified mode [*mode*].
+
+Upon success a handle (>=0) is returned. On error a negative status code
+will be returned.
+
+File
+
+A file may only be opened if permission is granted by an entry in
+/opt/pigpio/access. This is intended to allow remote access to files
+in a more or less controlled manner.
+
+Each entry in /opt/pigpio/access takes the form of a file path
+which may contain wildcards followed by a single letter permission.
+The permission may be R for read, W for write, U for read/write,
+and N for no access.
+
+Where more than one entry matches a file the most specific rule
+applies. If no entry matches a file then access is denied.
+
+Suppose /opt/pigpio/access contains the following entries
+
+. .
+/home/* n
+/home/pi/shared/dir_1/* w
+/home/pi/shared/dir_2/* r
+/home/pi/shared/dir_3/* u
+/home/pi/shared/dir_1/file.txt n
+. .
+
+Files may be written in directory dir_1 with the exception
+of file.txt.
+
+Files may be read in directory dir_2.
+
+Files may be read and written in directory dir_3.
+
+If a directory allows read, write, or read/write access then files may
+be created in that directory.
+
+In an attempt to prevent risky permissions the following paths are
+ignored in /opt/pigpio/access.
+
+. .
+a path containing ..
+a path containing only wildcards (*?)
+a path containing less than two non-wildcard parts
+. .
+
+Mode
+
+The mode may have the following values.
+
+ @ Value @ Meaning
+READ @ 1 @ open file for reading
+WRITE @ 2 @ open file for writing
+RW @ 3 @ open file for reading and writing
+
+The following values may be or'd into the mode.
+
+ @ Value @ Meaning
+APPEND @ 4 @ All writes append data to the end of the file
+CREATE @ 8 @ The file is created if it doesn't exist
+TRUNC @ 16 @ The file is truncated
+
+Newly created files are owned by root with permissions owner read and write.
+
+...
+$ ls /ram/*.c
+/ram/command.c /ram/pigpiod.c /ram/pigs.c
+/ram/x_pigpiod_if.c /ram/pig2vcd.c /ram/pigpiod_if2.c
+/ram/x_pigpio.c /ram/x_repeat.c /ram/pigpio.c
+/ram/pigpiod_if.c /ram/x_pigpiod_if2.c
+
+# assumes /opt/pigpio/access contains the following line
+# /ram/*.c r
+
+$ pigs fo /ram/pigpio.c 1
+0
+
+$ pigs fo /ram/new.c 1
+-128
+ERROR: file open failed
+
+$ pigs fo /ram/new.c 9
+1
+
+$ ls /ram/*.c -l
+-rw-r--r-- 1 joan joan 42923 Jul 10 11:22 /ram/command.c
+-rw------- 1 root root 0 Jul 10 16:54 /ram/new.c
+-rw-r--r-- 1 joan joan 2971 Jul 10 11:22 /ram/pig2vcd.c
+-rw------- 1 joan joan 296235 Jul 10 11:22 /ram/pigpio.c
+-rw-r--r-- 1 joan joan 9266 Jul 10 11:22 /ram/pigpiod.c
+-rw-r--r-- 1 joan joan 37331 Jul 10 11:22 /ram/pigpiod_if2.c
+-rw-r--r-- 1 joan joan 33088 Jul 10 11:22 /ram/pigpiod_if.c
+-rw-r--r-- 1 joan joan 7990 Jul 10 11:22 /ram/pigs.c
+-rw-r--r-- 1 joan joan 19970 Jul 10 11:22 /ram/x_pigpio.c
+-rw-r--r-- 1 joan joan 20804 Jul 10 11:22 /ram/x_pigpiod_if2.c
+-rw-r--r-- 1 joan joan 19844 Jul 10 11:22 /ram/x_pigpiod_if.c
+-rw-r--r-- 1 joan joan 19907 Jul 10 11:22 /ram/x_repeat.c
+...
+
+FR::
+This command returns up to [*num*] bytes of data read from the
+file associated with handle [*h*].
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+...
+$ pigs fr 0 10
+5 48 49 128 144 255
+
+$ pigs fr 0 10
+0
+...
+
+FS ::
+This command seeks to a position within the file associated
+with handle [*h*].
+
+The number of bytes to move is [*num*]. Positive offsets
+move forward, negative offsets backwards. The move start
+position is determined by [*from*] as follows.
+
+ @ From
+0 @ start
+1 @ current position
+2 @ end
+
+Upon success the new byte position within the file (>=0) is
+returned. On error a negative status code will be returned.
+
+...
+$ pigs fs 0 200 0 # Seek to start of file plus 200
+200
+
+$ pigs fs 0 0 1 # Return current position
+200
+
+$ pigs fs 0 0 2 # Seek to end of file, return size
+296235
+...
+
+FW::
+This command writes bytes [*bvs*] to the file
+associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs fw 0 23 45 67 89
+...
+
+GDC ::
+
+This command returns the PWM dutycycle in use on GPIO [*u*].
+
+Upon success the dutycycle is returned. On error a negative
+status code will be returned.
+
+For normal PWM the dutycycle will be out of the defined range
+for the GPIO (see [*PRG*]).
+
+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).
+
+...
+$ pigs p 4 129
+$ pigs gdc 4
+129
+
+pigs gdc 5
+-92
+ERROR: GPIO is not in use for PWM
+...
+
+GPW ::
+
+This command returns the servo pulsewidth in use on GPIO [*u*].
+
+Upon success the servo pulsewidth is returned. On error a negative
+status code will be returned.
+
+...
+$ pigs s 4 1235
+$ pigs gpw 4
+1235
+
+$ pigs gpw 9
+-93
+ERROR: GPIO is not in use for servo pulses
+...
+
+H/HELP ::
+This command displays a brief list of the commands and their parameters.
+
+...
+$ pigs h
+
+$ pigs help
+...
+
+HC ::
+This command sets the hardware clock associated with GPIO [*g*] to
+frequency [*cf*]. Frequencies above 30MHz are unlikely to work.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs hc 4 5000 # start a 5 KHz clock on GPIO 4 (clock 0)
+
+$ pigs hc 5 5000000 # start a 5 MHz clcok on GPIO 5 (clock 1)
+-99
+ERROR: need password to use hardware clock 1
+...
+
+The same clock is available on multiple GPIO. The latest
+frequency setting will be used by all GPIO which share a clock.
+
+The GPIO must be one of the following.
+
+4 @clock 0 @All models
+5 @clock 1 @All models but A and B (reserved for system use)
+6 @clock 2 @All models but A and B
+20 @clock 0 @All models but A and B
+21 @clock 1 @All models but A and B Rev.2 (reserved for system use)
+
+32 @clock 0 @Compute module only
+34 @clock 0 @Compute module only
+42 @clock 1 @Compute module only (reserved for system use)
+43 @clock 2 @Compute module only
+44 @clock 1 @Compute module only (reserved for system use)
+
+Access to clock 1 is protected by a password as its use will
+likely crash the Pi. The password is given by or'ing 0x5A000000
+with the GPIO number.
+
+HP ::
+This command sets the hardware PWM associated with GPIO [*g*] to
+frequency [*pf*] with dutycycle [*pdc*]. Frequencies above 30MHz
+are unlikely to work.
+
+NOTE: Any waveform started by [*WVTX*], [*WVTXR*], or [*WVCHA*]
+will be cancelled.
+
+This function is only valid if the pigpio main clock is PCM. The
+main clock defaults to PCM but may be overridden when the pigpio
+daemon is started (option -t).
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+. .
+$ pigs hp 18 100 800000 # 80% dutycycle
+
+$ pigs hp 19 100 200000 # 20% dutycycle
+
+$ pigs hp 19 400000000 100000
+-96
+ERROR: invalid hardware PWM frequency
+. .
+
+The same PWM channel is available on multiple GPIO. The latest
+frequency and dutycycle setting will be used by all GPIO which
+share a PWM channel.
+
+The GPIO must be one of the following.
+
+12 @PWM channel 0 @All models but A and B
+13 @PWM channel 1 @All models but A and B
+18 @PWM channel 0 @All models
+19 @PWM channel 1 @All models but A and B
+
+40 @PWM channel 0 @Compute module only
+41 @PWM channel 1 @Compute module only
+45 @PWM channel 1 @Compute module only
+52 @PWM channel 0 @Compute module only
+53 @PWM channel 1 @Compute module only
+
+The actual number of steps beween off and fully on is the
+integral part of 250M/[*pf*] (375M/[*pf*] for the BCM2711).
+
+The actual frequency set is 250M/steps (375M/steps for the BCM2711).
+
+There will only be a million steps for a [*pf*] of 250 (375 for
+the BCM2711). Lower frequencies will have more steps and higher
+frequencies will have fewer steps. [*pdc*] is
+automatically scaled to take this into account.
+
+HWVER ::
+This command returns the hardware revision of the Pi.
+
+The hardware revision is found in the last 4 characters on the revision
+line of /proc/cpuinfo.
+
+If the hardware revision can not be found or is not a valid hexadecimal
+number the command returns 0.
+
+The revision number can be used to determine the assignment of GPIO
+to pins (see [*g*]).
+
+There are currently three types of board.
+
+Type 1 boards have hardware revision numbers of 2 and 3.
+
+Type 2 boards have hardware revision numbers of 4, 5, 6, and 15.
+
+Type 3 boards have hardware revision numbers of 16 or greater.
+
+for "Revision : 0002" the command returns 2.
+
+for "Revision : 000f" the command returns 15.
+
+for "Revision : 000g" the command returns 0.
+
+...
+$ pigs hwver # On a B+
+16
+...
+
+I2CC ::
+This command closes an I2C handle [*h*] previously opened with [*I2CO*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs i2cc 0 # First close okay.
+
+$ pigs i2cc 0 # Second fails.
+-25
+ERROR: unknown handle
+...
+
+I2CO ::
+This command returns a handle to access device [*id*] on I2C bus [*ib*].
+The device is opened with flags [*if*].
+
+Physically buses 0 and 1 are available on the Pi. Higher
+numbered buses will be available if a kernel supported bus
+multiplexor is being used.
+
+The GPIO used are given in the following table.
+
+ @ SDA @ SCL
+I2C 0 @ 0 @ 1
+I2C 1 @ 2 @ 3
+
+No flags are currently defined. The parameter [*if*] should be 0.
+
+Upon success the next free handle (>=0) is returned. On error a
+negative status code will be returned.
+
+...
+$ pigs i2co 1 0x70 0 # Bus 1, device 0x70, flags 0.
+0
+
+$ pigs i2co 1 0x53 0 # Bus 1, device 0x53, flags 0.
+1
+...
+
+I2CPC ::
+This command writes [*wv*] to register [*r*] of the I2C device
+associated with handle [*h*] and returns a 16-bit word read from the
+device.
+
+Upon success a value between 0 and 65535 will be returned. On error
+a negative status code will be returned.
+
+...
+$ pigs i2cpc 0 37 43210
+39933
+
+$ pigs i2cpc 0 256 43210
+ERROR: bad i2c/spi/ser parameter
+-81
+...
+
+I2CPK ::
+
+This command writes the data bytes [*bvs*] to register [*r*] of the I2C device
+associated with handle [*h*] and returns a device specific number of bytes.
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+...
+$ pigs i2cpk 0 0 0x11 0x12
+6 0 0 0 0 0 0
+...
+
+I2CRB ::
+
+This command returns a single byte read from register [*r*] of the I2C device
+associated with handle [*h*].
+
+Upon success a value between 0 and 255 will be returned. On error
+a negative status code will be returned.
+
+...
+$ pigs i2crb 0 0
+6
+...
+
+I2CRD ::
+
+This command returns [*num*] bytes read from the I2C device associated with
+handle [*h*].
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+This command operates on the raw I2C device. The maximum value of the
+parameter [*num*] is dependent on the I2C drivers and the device
+itself. pigs imposes a limit of about 8000 bytes.
+
+...
+$ pigs i2crd 0 16
+16 6 24 0 0 0 0 0 0 0 0 0 0 0 0 32 78
+...
+
+I2CRI ::
+
+This command returns [*num*] bytes from register [*r*] of the I2C device
+associated with handle [*h*].
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+The parameter [*num*] may be 1-32.
+
+...
+$ pigs i2cri 0 0 16
+16 237 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155
+...
+
+I2CRK ::
+
+This command returns between 1 and 32 bytes read from register [*r*] of
+the I2C device associated with handle [*h*].
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+The number of bytes of returned data is specific to the device and
+register.
+
+...
+$ pigs i2crk 0 0
+6 0 0 0 0 0 0
+
+$ pigs i2crk 0 1
+24 0 0 0 0 0 0 0 0 0 0 0 0 120 222 105 215 128 87 195 217 0 0 0 0
+...
+
+I2CRS ::
+
+This command returns a single byte read from the I2C device
+associated with handle [*h*].
+
+Upon success a value between 0 and 255 will be returned. On error
+a negative status code will be returned.
+
+...
+$ pigs i2crs 0
+0
+...
+
+I2CRW ::
+
+This command returns a single 16 bit word read from register [*r*] of
+the I2C device associated with handle [*h*].
+
+Upon success a value between 0 and 65535 will be returned. On error
+a negative status code will be returned.
+
+...
+$ pigs i2crw 0 0
+6150
+...
+
+I2CWB ::
+
+This command writes a single byte [*bv*] to register [*r*] of the
+I2C device associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs i2cwb 0 10 0x54
+...
+
+I2CWD ::
+
+This command writes a block of bytes [*bvs*] to the I2C device
+associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The number of bytes which may be written in one transaction is
+dependent on the I2C drivers and the device itself. pigs imposes
+a limit of about 500 bytes.
+
+This command operates on the raw I2C device.
+
+...
+$ pigs i2cwd 0 0x01 0x02 0x03 0x04
+...
+
+I2CWI ::
+
+This command writes between 1 and 32 bytes [*bvs*] to register [*r*] of
+the I2C device associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs i2cwi 0 4 0x01 0x04 0xc0
+...
+
+I2CWK ::
+
+This command writes between 1 and 32 bytes [*bvs*] to register [*r*] of
+the I2C device associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+pigs i2cwk 0 4 0x01 0x04 0xc0
+...
+
+I2CWQ ::
+
+This command writes a single [*bit*] to the I2C device associated
+with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs i2cwq 0 1
+...
+
+I2CWS ::
+
+This command writes a single byte [*bv*] to the I2C device associated
+with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs i2cws 0 0x12
+
+$ pigs i2cws 0 0xff
+-82
+ERROR: I2C write failed
+...
+
+I2CWW ::
+
+This command writes a single 16 bit word [*wv*] to register [*r*] of
+the I2C device associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs i2cww 0 0 0xffff
+...
+
+I2CZ ::
+This command executes a sequence of I2C operations. The
+operations to be performed are specified by the contents of [*bvs*]
+which contains the concatenated command codes and associated data.
+
+The following command codes are supported:
+
+Name @ Cmd & Data @ Meaning
+End @ 0 @ No more commands
+Escape @ 1 @ Next P is two bytes
+On @ 2 @ Switch combined flag on
+Off @ 3 @ Switch combined flag off
+Address @ 4 P @ Set I2C address to P
+Flags @ 5 lsb msb @ Set I2C flags to lsb + (msb << 8)
+Read @ 6 P @ Read P bytes of data
+Write @ 7 P ... @ Write P bytes of data
+
+The address, read, and write commands take a parameter P.
+Normally P is one byte (0-255). If the command is preceded by
+the Escape command then P is two bytes (0-65535, least significant
+byte first).
+
+The address defaults to that associated with the handle [*h*].
+The flags default to 0. The address and flags maintain their
+previous value until updated.
+
+...
+Set address 0x53, write 0x32, read 6 bytes
+Set address 0x1E, write 0x03, read 6 bytes
+Set address 0x68, write 0x1B, read 8 bytes
+End
+
+0x04 0x53 0x07 0x01 0x32 0x06 0x06
+0x04 0x1E 0x07 0x01 0x03 0x06 0x06
+0x04 0x68 0x07 0x01 0x1B 0x06 0x08
+0x00
+...
+
+
+M/MODES ::
+
+This command sets GPIO [*g*] to mode [*m*], typically input (read)
+or output (write).
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+Each GPIO can be configured to be in one of 8 different modes. The modes
+are named Input, Output, ALT0, ALT1, ALT2, ALT3, ALT4, and ALT5.
+
+To set the mode use the code for the mode.
+
+Mode @Input@Output@ALT0@ALT1@ALT2@ALT3@ALT4@ALT5
+Code @ R@ W@ 0@ 1@ 2@ 3@ 4@ 5
+
+...
+$ pigs m 4 r # Input (read)
+$ pigs m 4 w # Output (write)
+$ pigs m 4 0 # ALT 0
+$ pigs m 4 5 # ALT 5
+...
+
+MG/MODEG ::
+
+This command returns the current mode of GPIO [*g*].
+
+Upon success the value of the GPIO mode is returned.
+On error a negative status code will be returned.
+
+Value @ 0@ 1@ 2@ 3@ 4@ 5@ 6@ 7
+Mode @Input@Output@ALT5@ALT4@ALT0@ALT1@ALT2@ALT3
+
+...
+$ pigs mg 4
+1
+...
+
+MICS ::
+This command delays execution for [*v*] microseconds.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The main use of this command is expected to be within [*Scripts*].
+
+...
+$ pigs mics 20 # Delay 20 microseconds.
+$ pigs mics 1000000 # Delay 1 second.
+
+$ pigs mics 2000000
+-64
+ERROR: bad MICS delay (too large)
+...
+
+MILS ::
+
+This command delays execution for [*v*] milliseconds.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs mils 2000 # Delay 2 seconds.
+
+$ pigs mils 61000
+-65
+ERROR: bad MILS delay (too large)
+...
+
+NB ::
+
+This command starts notifications on handle [*h*] returned by
+a prior call to [*NO*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The notification gets state changes for each GPIO specified by [*bits*].
+
+...
+$ pigs nb 0 -1 # Shorthand for GPIO 0-31.
+$ pigs nb 0 0xf0 # Get notifications for GPIO 4-7.
+
+$ pigs nb 1 0xf
+-25
+ERROR: unknown handle
+...
+
+NC ::
+
+This command stops notifications on handle [*h*] returned by
+a prior call to [*NO*] and releases the handle for reuse.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs nc 0 # First call succeeds.
+
+$ pigs nc 1 # Second call fails.
+-25
+ERROR: unknown handle
+...
+
+NO ::
+
+This command requests a free notification handle.
+
+A notification is a method for being notified of GPIO state changes via a pipe.
+
+Upon success the command returns a handle greater than or equal to zero.
+On error a negative status code will be returned.
+
+Notifications for handle x will be available at the pipe named /dev/pigpiox
+(where x is the handle number).
+
+E.g. if the command returns 15 then the notifications must be read
+from /dev/pigpio15.
+
+...
+$ pigs no
+0
+...
+
+NP ::
+
+This command pauses notifications on handle [*h*] returned by
+a prior call to [*NO*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+Notifications for the handle are suspended until a new [*NB*] command
+is given for the handle.
+
+...
+$ pigs np 0
+...
+
+P/PWM ::
+
+This command starts PWM on GPIO [*u*] with dutycycle [*v*]. The dutycycle
+varies from 0 (off) to range (fully on). The range defaults to 255.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+This and the servo functionality use the DMA and PWM or PCM peripherals
+to control and schedule the pulsewidths and dutycycles.
+
+The [*PRS*] command may be used to change the default range of 255.
+
+...
+$ pigs p 4 64 # Start PWM on GPIO 4 with 25% dutycycle
+$ pigs p 4 128 # 50%
+$ pigs p 4 192 # 75%
+$ pigs p 4 255 # 100%
+...
+
+PADG ::
+
+This command gets the [*pad*] drive strength [*padma*] in mA.
+
+Returns the pad drive strength if OK. On error a negative status code
+will be returned.
+
+Pad @ GPIO
+0 @ 0-27
+1 @ 28-45
+2 @ 46-53
+
+...
+$ pigs padg 0
+8
+$ pigs pads 0 16
+$ pigs padg 0
+16
+pigs padg 3
+-126
+ERROR: bad pad number
+...
+
+PADS::
+
+This command sets the [*pad*] drive strength [*padma*] in mA.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+Pad @ GPIO
+0 @ 0-27
+1 @ 28-45
+2 @ 46-53
+
+...
+$ pigs pads 0 16
+$ pigs padg 0
+16
+$ pigs pads 0 17
+-127
+ERROR: bad pad drive strength
+...
+
+PARSE ::
+
+Validates the text [*t*] of a script without storing the script.
+
+Upon success nothing is returned. On error a list of detected
+script errors will be given.
+
+See [*Scripts*].
+
+This command may be used to find script syntax faults.
+
+...
+$ pigs parse tag 100 w 22 1 mils 200 w 22 0 mils 800 jmp 100
+
+$ pigs parse tag 0 w 22 1 mills 50 w 22 0 dcr p10 jp 99
+Unknown command: mills
+Unknown command: 50
+Bad parameter to dcr
+Can't resolve tag 99
+...
+
+PFG ::
+
+This command returns the PWM frequency in Hz used for GPIO [*u*].
+
+Upon success the PWM frequency is returned. On error a negative
+status code will be returned.
+
+For normal PWM the frequency will be that defined for the GPIO
+by [*PFS*].
+
+If a hardware clock is active on the GPIO the reported frequency
+will be that set by [*HC*].
+
+If hardware PWM is active on the GPIO the reported frequency
+will be that set by [*HP*].
+
+...
+$ pigs pfg 4
+800
+
+$ pigs pfg 34
+ERROR: GPIO not 0-31
+-2
+...
+
+PFS ::
+This command sets the PWM frequency [*v*] to be used for GPIO [*u*].
+
+The numerically closest frequency to [*v*] will be selected.
+
+Upon success the new frequency is returned. On error a negative status code
+will be returned.
+
+If PWM is currently active on the GPIO it will be
+switched off and then back on at the new frequency.
+
+Each GPIO can be independently set to one of 18 different PWM
+frequencies.
+
+The selectable frequencies depend upon the sample rate which
+may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
+sample rate is set when the pigpio daemon is started.
+
+The frequencies for each sample rate are:
+
+. .
+ Hertz
+
+ 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
+ 1250 1000 800 500 400 250 200 100 50
+
+ 2: 20000 10000 5000 4000 2500 2000 1250 1000 800
+ 625 500 400 250 200 125 100 50 25
+
+ 4: 10000 5000 2500 2000 1250 1000 625 500 400
+ 313 250 200 125 100 63 50 25 13
+sample
+ rate
+ (us) 5: 8000 4000 2000 1600 1000 800 500 400 320
+ 250 200 160 100 80 50 40 20 10
+
+ 8: 5000 2500 1250 1000 625 500 313 250 200
+ 156 125 100 63 50 31 25 13 6
+
+ 10: 4000 2000 1000 800 500 400 250 200 160
+ 125 100 80 50 40 25 20 10 5
+. .
+
+...
+pigs pfs 4 0 # 0 selects the lowest frequency.
+10
+
+$ pigs pfs 4 1000 # Set 1000Hz PWM.
+1000
+
+$ pigs pfs 4 100000 # Very big number selects the highest frequency.
+8000
+...
+
+PIGPV ::
+
+This command returns the pigpio library version.
+
+...
+$ pigs pigpv
+17
+...
+
+PRG ::
+
+This command returns the dutycycle range for GPIO [*u*].
+
+Upon success the range is returned. On error a negative status code
+will be returned.
+
+If a hardware clock or hardware PWM is active on the GPIO the reported
+range will be 1000000 (1M).
+
+...
+$ pigs prg 4
+255
+...
+
+PROC ::
+
+This command stores a script [*t*] for later execution.
+
+If the script is valid a script id (>=0) is returned which is passed
+to the other script commands. On error a negative status code
+will be returned.
+
+See [*Scripts*].
+
+...
+$ pigs proc tag 123 w 4 0 mils 200 w 4 1 mils 300 dcr p0 jp 123
+0
+
+$ pigs proc tag 123 w 4 0 mils 5 w 4 1 mils 5 jmp 12
+ERROR: script has unresolved tag
+-63
+...
+
+PROCD ::
+
+This command deletes script [*sid*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+See [*Scripts*].
+
+...
+$ pigs procd 1
+
+$ pigs procd 1
+ERROR: unknown script id
+-48
+...
+
+PROCP ::
+
+This command returns the status of script [*sid*] as well as the
+current value of its 10 parameters.
+
+Upon success the script status and parameters are returned.
+On error a negative status code will be returned.
+
+The script status may be one of
+
+0 @ being initialised
+1 @ halted
+2 @ running
+3 @ waiting
+4 @ failed
+
+See [*Scripts*].
+
+...
+$ pigs procp 0
+1 0 0 0 0 0 0 0 0 0 0
+...
+
+PROCR ::
+
+This command runs stored script [*sid*] passing it up to 10 optional
+parameters.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+See [*Scripts*].
+
+...
+$ pigs proc tag 123 w 4 0 mils 200 w 4 1 mils 300 dcr p0 jp 123
+0
+
+$ pigs procr 0 50 # Run script 0 with parameter 0 of 50.
+
+$ pigs procp 0
+2 44 0 0 0 0 0 0 0 0 0
+$ pigs procp 0
+2 37 0 0 0 0 0 0 0 0 0
+$ pigs procp 0
+2 10 0 0 0 0 0 0 0 0 0
+$ pigs procp 0
+2 5 0 0 0 0 0 0 0 0 0
+$ pigs procp 0
+2 2 0 0 0 0 0 0 0 0 0
+$ pigs procp 0
+1 -1 0 0 0 0 0 0 0 0 0
+...
+
+PROCS ::
+
+This command stops a running script [*sid*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+See [*Scripts*].
+
+...
+$ pigs procs 0
+
+$ pigs procs 1
+-48
+ERROR: unknown script id
+...
+
+PROCU ::
+
+This command sets the parameters of a stored script [*sid*] passing
+it up to 10 parameters.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+See [*Scripts*].
+
+...
+$ pigs proc tag 0 hp 18 p0 p1 mils 1000 jmp 0
+0
+$ pigs procu 0 50 500000
+$ pigs procr 0
+$ pigs procu 0 100
+$ pigs procu 0 200
+$ pigs procu 0 200 100000
+...
+
+PRRG ::
+
+This command returns the real underlying range used by GPIO [*u*].
+
+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.
+
+On error a negative status code will be returned.
+
+See [*PRS*].
+
+...
+$ pigs prrg 17
+250
+
+$ pigs pfs 17 0
+10
+$ pigs prrg 17
+20000
+
+$ pigs pfs 17 100000
+8000
+$ pigs prrg 17
+25
+...
+
+PRS ::
+
+This command sets the dutycycle range [*v*] to be used for GPIO [*u*].
+Subsequent uses of command [*P/PWM*] will use a dutycycle between 0 (off)
+and [*v*] (fully on).
+
+Upon success the real underlying range used by the GPIO is returned.
+On error a negative status code will be returned.
+
+If PWM is currently active on the GPIO its dutycycle will be scaled to
+reflect the new range.
+
+The real range, the number of steps between fully off and fully on
+for each frequency, is given in the following table.
+
+ #1@ #2@ #3@ #4@ #5@ #6@ #7@ #8@ #9
+ 25@ 50@ 100@ 125@ 200@ 250@ 400@ 500@ 625
+ @ @ @ @ @ @ @ @
+#10@ #11@ #12@ #13@ #14@ #15@ #16@ #17@ #18
+800@1000@1250@2000@2500@4000@5000@10000@20000
+
+The real value set by [*PRS*] is (dutycycle * real range) / range.
+
+See [*PRRG*]
+
+...
+$ pigs prs 18 1000
+250
+...
+
+PUD ::
+
+This command sets the internal pull/up down for GPIO [*g*] to mode [*p*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The mode may be pull-down (D), pull-up (U), or off (O).
+
+...
+$ pigs pud 4 d # Set pull-down on GPIO 4.
+$ pigs pud 4 u # Set pull-up on GPIO 4.
+$ pigs pud 4 o # No pull-up/down on GPIO 4.
+...
+
+R/READ ::
+
+This reads the current level of GPIO [*g*].
+
+Upon success the current level is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs r 17 # Get level of GPIO 17.
+0
+
+$ pigs r 4 # Get level of GPIO 4.
+1
+...
+
+S/SERVO ::
+
+This command starts servo pulses of [*v*] microseconds on GPIO [*u*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The servo pulsewidth may be 0 (off), 500 (most anti-clockwise)
+to 2500 (most clockwise).
+
+The range supported by servos varies and should probably be determined
+by experiment. Generally values between 1000-2000 should be safe.
+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.
+
+...
+$ pigs SERVO 17 1500
+...
+
+This example causes an on pulse of 1500 microseconds duration to be
+transmitted on GPIO 17 at a rate of 50 times per second.
+
+This will command a servo connected to GPIO 17 to rotate to its mid-point.
+
+...
+pigs s 17 0 # Switch servo pulses off.
+...
+
+SERC ::
+
+This command closes a serial handle [*h*] previously opened with [*SERO*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs serc 0 # First close okay.
+
+$ pigs serc 0 # Second close gives error.
+-25
+ERROR: unknown handle
+...
+
+SERDA ::
+
+This command returns the number of bytes of data available
+to be read from the serial device associated with handle [*h*].
+
+Upon success the count of bytes available to be read is
+returned (which may be 0). On error a negative status code
+will be returned.
+
+...
+$ pigs serda 0
+0
+...
+
+SERO::
+
+This command opens the serial [*dev*] at [*b*] bits per second.
+
+No flags are currently defined. [*sef*] should be set to zero.
+
+Upon success a handle (>=0) is returned. On error a negative status code
+will be returned.
+
+The device name must start with /dev/tty or /dev/serial.
+
+
+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.
+
+...
+$ pigs sero /dev/ttyAMA0 9600 0
+0
+
+$ pigs sero /dev/tty1 38400 0
+1
+...
+
+SERR::
+
+This command returns up to [*num*] bytes of data read from the
+serial device associated with handle [*h*].
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+...
+$ pigs serr 0 10
+5 48 49 128 144 255
+
+$ pigs serr 0 10
+0
+...
+
+SERRB::
+
+This command returns a byte of data read from the serial
+device associated with handle [*h*].
+
+Upon success a number between 0 and 255 is returned.
+On error a negative status code will be returned.
+
+...
+$ pigs serrb 0
+23
+$ pigs serrb 0
+45
+...
+
+SERW::
+
+This command writes bytes [*bvs*] to the serial device
+associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs serw 0 23 45 67 89
+...
+
+SERWB::
+
+This command writes a single byte [*bv*] to the serial device
+associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs serwb 0 23
+$ pigs serwb 0 0xf0
+...
+
+SHELL ::
+
+This command uses the system call to execute a shell script [*name*]
+with the given string [*str*] as its parameter.
+
+The exit status of the system call is returned if OK, otherwise
+PI_BAD_SHELL_STATUS.
+
+[*name*] must exist in /opt/pigpio/cgi and must be executable.
+
+The returned exit status is normally 256 times that set
+by the shell script exit function. If the script can't
+be found 32512 will be returned.
+
+The following table gives some example returned statuses.
+
+Script exit status @ Returned system call status
+1 @ 256
+5 @ 1280
+10 @ 2560
+200 @ 51200
+script not found @ 32512
+
+...
+# pass two parameters, hello and world
+$ pigs shell scr1 hello world
+256
+
+# pass three parameters, hello, string with spaces, and world
+$ pigs shell scr1 "hello 'string with spaces' world"
+256
+
+# pass one parameter, hello string with spaces world
+$ pigs shell scr1 "\"hello string with spaces world\""
+256
+
+# non-existent script
+$ pigs shell scr78 par1
+32512
+...
+
+SLR ::
+
+This command returns up to [*num*] bytes of bit bang serial data
+read from GPIO [*u*].
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+The GPIO [*u*] should have been initialised with the [*SLRO*] command.
+
+The bytes returned for each character depend upon the number of
+data bits [*db*] specified in the [*SLRO*] command.
+
+For [*db*] 1-8 there will be one byte per character.
+For [*db*] 9-16 there will be two bytes per character.
+For [*db*] 17-32 there will be four bytes per character.
+
+...
+$ pigs slr 15 20
+6 1 0 23 45 89 0
+...
+
+SLRC ::
+
+This command closes GPIO [*u*] for reading bit bang serial data.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs slrc 23
+
+$ pigs slrc 23
+-38
+ERROR: no serial read in progress on GPIO
+...
+
+SLRI ::
+
+This command sets the logic level for reading bit bang serial data
+on GPIO [*u*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The invert parameter [*v*] is 1 for inverted signal, 0 for normal.
+
+...
+$ pigs slri 17 1 # invert logic on GPIO 17
+
+$ pigs slri 23 0 # use normal logic on GPIO 23
+...
+
+SLRO ::
+
+This command opens GPIO [*u*] for reading bit bang serial data
+at [*b*] baud and [*db*] data bits.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The baud rate may be between 50 and 250000 bits per second.
+
+The received data is held in a cyclic buffer.
+
+It is the user's responsibility to read the data (with [*SLR*])
+in a timely fashion.
+
+...
+$ pigs slro 23 19200 8
+
+$ pigs slro 23 19200 8
+-50
+ERROR: GPIO already in use
+...
+
+SPIC ::
+
+This command closes the SPI handle [*h*] returned by a prior
+call to [*SPIO*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs spic 1
+
+$ pigs spic 1
+-25
+ERROR: unknown handle
+...
+
+SPIO ::
+
+This command returns a handle to a SPI device on channel [*c*].
+
+Data will be transferred at [*b*] bits per second. The flags [*spf*]
+may be used to modify the default behaviour of 4-wire operation,
+mode 0, active low chip select.
+
+Speeds between 32kbps and 125Mbps are allowed. Speeds above 30Mbps
+are unlikely to work.
+
+The Pi has two SPI peripherals: main and auxiliary.
+
+The main SPI has two chip selects (channels), the auxiliary has
+three.
+
+The auxiliary SPI is available on all models but the A and B.
+
+The GPIO used are given in the following table.
+
+ @ MISO @ MOSI @ SCLK @ CE0 @ CE1 @ CE2
+Main SPI @ 9 @ 10 @ 11 @ 8 @ 7 @ -
+Aux SPI @ 19 @ 20 @ 21 @ 18 @ 17 @ 16
+
+The 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 SPI.
+
+. .
+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 main SPI, 1 for the auxiliary SPI.
+
+W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Main
+SPI 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. Main SPI 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
+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
+only.
+
+bbbbbb defines the word size in bits (0-32). The default (0)
+sets 8 bits per word. Auxiliary SPI only.
+
+The [*SPIR*], [*SPIW*], and [*SPIX*] commands 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.
+
+Multi-byte transfers are made in least significant byte first order.
+
+E.g. to transfer 32 11-bit words 64 bytes need to be sent.
+
+E.g. to transfer the 14 bit value 0x1ABC send the bytes 0xBC followed
+by 0x1A.
+
+The other bits in flags should be set to zero.
+
+Upon success a handle (>=0) is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs spio 0 100000 3 # Open channel 0 at 100kbps in mode 3.
+0
+
+$ pigs spio 0 32000 256 # Open channel 0 of auxiliary spi at 32kbps.
+1
+...
+
+SPIR ::
+
+This command returns [*num*] bytes read from the SPI device
+associated with handle [*h*].
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+...
+$ pigs spir 0 10 # Read 10 bytes from the SPI device.
+10 0 0 0 0 0 0 0 0 0 0
+...
+
+SPIW ::
+
+This command writes bytes [*bvs*] to the SPI device
+associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs spiw 0 0x22 0x33 0xcc 0xff
+...
+
+SPIX::
+
+This command writes bytes [*bvs*] to the SPI device
+associated with handle [*h*]. It returns the same
+number of bytes read from the device.
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+...
+$ pigs spix 0 0x22 0x33 0xcc 0xff
+4 0 0 0 0
+...
+
+T/TICK ::
+
+This command returns the current system tick.
+
+Tick is the number of microseconds since system boot.
+
+As tick is an unsigned 32 bit quantity it wraps around after 2^32 microseconds,
+which is approximately 1 hour 12 minutes.
+
+...
+$ pigs t mils 1000 t
+3691823946
+3692833987
+...
+
+TRIG ::
+
+This command sends a trigger pulse of [*pl*] microseconds at level [*L*]
+to GPIO [*u*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The GPIO is set to not level at the end of the pulse.
+
+...
+$ pigs trig 4 10 1
+
+$ pigs trig 4 51 1
+-46
+ERROR: trigger pulse > 50 microseconds
+...
+
+W/WRITE ::
+
+This command sets GPIO [*g*] to level [*L*]. The level may be 0
+(low, off, clear) or 1 (high, on, set).
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs w 23 0
+$ pigs w 23 1
+
+$ pigs w 23 2
+-5
+ERROR: level not 0-1
+...
+
+WDOG ::
+
+This command sets a watchdog of [*v*] milliseconds on GPIO [*u*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The watchdog is nominally in milliseconds.
+
+One watchdog may be registered per GPIO.
+
+The watchdog may be cancelled by setting timeout to 0.
+
+Once a watchdog has been started monitors of the GPIO
+will be triggered every timeout interval after the last
+GPIO activity. The watchdog expiry will be indicated by
+a special TIMEOUT value.
+
+...
+$ pigs wdog 23 90000
+-15
+ERROR: timeout not 0-60000
+
+$ pigs wdog 23 9000
+...
+
+This example causes a report to be written to any notification pipes
+listening on GPIO 23 whenever GPIO 23 changes state or approximately
+every 9000 ms.
+
+WVAG ::
+
+This command adds 1 one or more triplets [*trips*] of GPIO on, GPIO off,
+delay to the existing waveform (if any).
+
+Upon success the total number of pulses in the waveform so far is
+returned. On error a negative status code will be returned.
+
+The triplets will be added at the start of the existing waveform. If
+they are to start offset from the start then the first triplet should
+consist solely of a delay i.e. 0 0 offset.
+
+...
+$ pigs wvag 0x10 0x80 1000 0x80 0x10 9000
+2
+
+$ pigs wvag 0 0 10000 0x10 0x80 1000 0x80 0x10 9000
+4
+...
+
+WVAS ::
+
+This command adds a waveform representing serial data [*bvs*] to
+GPIO [*u*] at [*b*] baud to the existing waveform (if any).
+The serial data starts [*o*] microseconds from the start of the
+waveform.
+
+Upon success the total number of pulses in the waveform so far is
+returned. On error a negative status code will be returned.
+
+The serial data is formatted as one start bit, [*db*] data bits, and
+[*sb*]/2 stop bits.
+
+The baud rate may be between 50 and 1000000 bits per second.
+
+It is legal to add serial data streams with different baud rates to
+the same waveform.
+
+The bytes required for each character depend upon [*db*].
+
+For [*db*] 1-8 there will be one byte per character.
+For [*db*] 9-16 there will be two bytes per character.
+For [*db*] 17-32 there will be four bytes per character.
+
+...
+$ pigs wvas 4 9600 8 2 0 0x30 0x31 0x32 0x33
+23
+
+$ pigs wvas 7 38400 8 2 0 0x41 0x42
+35
+...
+
+WVTAT ::
+
+This command returns the id of the waveform currently
+being transmitted. Chained waves are not supported.
+
+Returns the waveform id or one of the following special
+values:
+
+9998 - transmitted wave not found
+9999 - no wave being transmitted
+
+...
+$ pigs wvtat
+9999
+...
+
+WVBSY ::
+
+This command checks to see if a waveform is currently being transmitted.
+
+Returns 1 if a waveform is currently being transmitted, otherwise 0.
+
+...
+$ pigs wvbsy
+0
+...
+
+WVCHA ::
+
+This command transmits a chain of waveforms.
+
+NOTE: Any hardware PWM started by [*HP*] will
+be cancelled.
+
+The waves to be transmitted are specified by the contents of
+[*bvs*] which contains an ordered list of wave_ids and optional
+command codes and related data.
+
+Upon success 0 is returned. On error a negative status code
+will be returned.
+
+Each wave is transmitted in the order specified. A wave may
+occur multiple times per chain.
+
+A blocks of waves may be transmitted multiple times by using
+the loop commands. The block is bracketed by loop start and
+end commands. Loops may be nested.
+
+Delays between waves may be added with the delay command.
+
+The following command codes are supported:
+
+Name @ Cmd & Data @ Meaning
+Loop Start @ 255 0 @ Identify start of a wave block
+Loop Repeat @ 255 1 x y @ loop x + y*256 times
+Delay @ 255 2 x y @ delay x + y*256 microseconds
+Loop Forever @ 255 3 @ loop forever
+
+If present Loop Forever must be the last entry in the chain.
+
+The code is currently dimensioned to support a chain with roughly
+600 entries and 20 loop counters.
+
+...
+#!/bin/bash
+
+GPIO=4
+WAVES=5
+
+pigs m $GPIO w
+
+for ((i=0; i<$WAVES; i++))
+do
+ pigs wvag $((1<<GPIO)) 0 20 0 $((1<<GPIO)) $(((i+1)*200))
+ w[i]=$(pigs wvcre)
+done
+
+# transmit waves 4+3+2
+# loop start
+# transmit waves 0+0+0
+# loop start
+# transmit waves 0+1
+# delay 5000us
+# loop end (repeat 30 times)
+# loop start
+# transmit waves 2+3+0
+# transmit waves 3+1+2
+# loop end (repeat 10 times)
+# loop end (repeat 5 times)
+# transmit waves 4+4+4
+# delay 20000us
+# transmit waves 0+0+0
+
+pigs wvcha \
+ ${w[4]} ${w[3]} ${w[2]} \
+ 255 0 \
+ ${w[0]} ${w[0]} ${w[0]} \
+ 255 0 \
+ ${w[0]} ${w[1]} \
+ 255 2 0x88 0x13 \
+ 255 1 30 0 \
+ 255 0 \
+ ${w[2]} ${w[3]} ${w[0]} \
+ ${w[3]} ${w[1]} ${w[2]} \
+ 255 1 10 0 \
+ 255 1 5 0 \
+ ${w[4]} ${w[4]} ${w[4]} \
+ 255 2 0x20 0x4E \
+ ${w[0]} ${w[0]} ${w[0]}
+
+while [[ $(pigs wvbsy) -eq 1 ]]; do sleep 0.1; done
+
+for ((i=0; i<$WAVES; i++)); do echo ${w[i]}; pigs wvdel ${w[i]}; done
+...
+
+WVCLR ::
+
+This command clears all waveforms.
+
+Nothing is returned.
+
+...
+$ pigs wvclr
+...
+
+WVCRE ::
+
+This command creates a waveform from the data provided by the prior
+calls to the [*WVAG*] and [*WVAS*] commands.
+
+Upon success a wave id (>=0) is returned. On error a negative status
+code will be returned.
+
+The data provided by the [*WVAG*] and [*WVAS*] commands is
+consumed by this command.
+
+As many waveforms may be created as there is space available.
+The wave id is passed to [*WVTX*] or [*WVTXR*] to specify the
+waveform to transmit.
+
+Normal usage would be
+
+Step 1. [*WVCLR*] to clear all waveforms and added data.
+
+Step 2. [*WVAG*]/[*WVAS*] calls to supply the waveform data.
+
+Step 3. [*WVCRE*] to create the waveform and get a unique id.
+
+Repeat steps 2 and 3 as needed.
+
+Step 4. [*WVTX*] or [*WVTXR*] with the id of the waveform to transmit.
+
+A waveform comprises of one or more pulses.
+
+A pulse specifies
+
+1) the GPIO to be switched on at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
+3) the delay in microseconds before the next pulse.
+
+Any or all the fields can be zero. It doesn't make any sense to
+set all the fields to zero (the pulse will be ignored).
+
+When a waveform is started each pulse is executed in order with
+the specified delay between the pulse and the next.
+
+...
+$ pigs wvas 4 9600 0 23 45 67 89 90
+37
+$ pigs wvcre
+0
+
+$ pigs wvcre
+-69
+ERROR: attempt to create an empty waveform
+...
+
+WVCAP ::
+
+Create a waveform of fixed size. Similar to [*WVCRE*], this command creates a waveform but pads the consumed resources to a fixed size, specified as a [*percent*] of the total resources. Padded waves of equal size can be re-cycled efficiently allowing newly created waves to re-use the resources of deleted waves of the same dimension.
+
+Upon success a wave id (>=0) is returned. On error a negative status code will be returned.
+
+The data provided by the [*WVAG*] and [*WVAS*] commands are consumed by this command.
+
+As many waveforms may be created as there is space available. The wave id is passed to [*WVTX*] or [*WVTXR*] to specify the waveform to transmit.
+
+Normal usage would be
+
+Step 1. [*WVCLR*] to clear all waveforms and added data.
+
+Step 2. [*WVAG*]/[*WVAS*] calls to supply the waveform data.
+
+Step 3. [*WVCAP*] to create a waveform of a uniform size.
+
+Step 4. [*WVTX*] or [*WVTXR*] with the id of the waveform to transmit.
+
+Repeat steps 2 - 4 as needed.
+
+Step 5. Any wave id can now be deleted and another wave of the same size can be created in its place.
+
+Example
+
+...
+# Create a wave that consumes 50% of the total resource:
+
+$ pigs wvag 16 0 5000000 0 16 5000000
+2
+$ pigs wvcap 50
+0
+$ pigs wvtx 0
+11918
+...
+
+WVDEL ::
+
+This command deletes the waveform with id [*wid*].
+
+The wave is flagged for deletion. The resources used by the wave
+will only be reused when either of the following apply.
+
+- all waves with higher numbered wave ids have been deleted or have
+been flagged for deletion.
+
+- a new wave is created which uses exactly the same resources as
+the current wave (see the C source for gpioWaveCreate for details).
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs wvdel 0
+
+$ pigs wvdel 0
+-66
+ERROR: non existent wave id
+...
+
+WVHLT ::
+
+This command aborts the transmission of the current waveform.
+
+Nothing is returned.
+
+This command is intended to stop a waveform started in the repeat mode.
+
+...
+$ pigs wvhlt
+...
+
+WVNEW ::
+
+This clears any existing waveform data ready for the creation of a new
+waveform.
+
+Nothing is returned.
+
+...
+$ pigs wvnew
+...
+
+WVSC ::
+
+The statistic requested by [*ws*] is returned.
+
+[*ws*] identifies the subcommand as follows.
+
+0 Get Cbs
+1 Get High Cbs
+2 Get Max Cbs
+
+...
+$ pigs wvas 4 9600 0 23 45 67 89 90
+37
+
+$ pigs wvsc 0
+74
+$ pigs wvsc 1
+74
+$ pigs wvsc 2
+25016
+...
+
+WVSM ::
+
+The statistic requested by [*ws*] is returned.
+
+[*ws*] identifies the subcommand as follows.
+
+0 Get Micros
+1 Get High Micros
+2 Get Max Micros
+
+...
+$ pigs wvsm 0
+5314
+$ pigs wvsm 1
+5314
+$ pigs wvsm 2
+1800000000
+...
+
+WVSP ::
+
+The statistic requested by [*ws*] is returned.
+
+[*ws*] identifies the subcommand as follows.
+
+0 Get Pulses
+1 Get High Pulses
+2 Get Max Pulses
+
+...
+$ pigs wvsp 0
+37
+$ pigs wvsp 1
+37
+$ pigs wvsp 2
+12000
+...
+
+WVTX ::
+
+This command transmits the waveform with id [*wid*] once.
+
+NOTE: Any hardware PWM started by [*HP*] will be cancelled.
+
+Upon success the number of DMA control blocks in the waveform is returned.
+On error a negative status code will be returned.
+
+...
+$ pigs wvtx 1
+75
+
+$ pigs wvtx 2
+-66
+ERROR: non existent wave id
+...
+
+WVTXM ::
+
+This command transmits the waveform with id [*wid*] using mode [*wmde*].
+
+The mode may be send once (0), send repeatedly (1), send once but
+first sync with previous wave (2), or send repeatedly but first
+sync with previous wave (3).
+
+WARNING: bad things may happen if you delete the previous
+waveform before it has been synced to the new waveform.
+
+NOTE: Any hardware PWM started by [*HP*] will be cancelled.
+
+Upon success the number of DMA control blocks in the waveform is returned.
+On error a negative status code will be returned.
+
+...
+$ pigs wvtxm 1 3
+75
+
+$ pigs wvtxm 2 0
+-66
+ERROR: non existent wave id
+...
+
+WVTXR ::
+
+This command transmits the waveform with id [*wid*] repeatedly.
+
+NOTE: Any hardware PWM started by [*HP*] will be cancelled.
+
+Upon success the number of DMA control blocks in the waveform is returned.
+On error a negative status code will be returned.
+
+...
+$ pigs wvtxr 1
+75
+
+$ pigs wvtxr 2
+-66
+ERROR: non existent wave id
+...
+
+PARAMETERS
+
+actv :: 0-1000000
+
+The number of microseconds level changes are reported for once
+a noise filter has been triggered (by [*stdy*] microseconds of
+a stable level).
+
+b :: baud
+The command expects the baud rate in bits per second for
+the transmission of serial data (I2C/SPI/serial link, waves).
+
+bctl :: BSC control word
+The command expects a BSC control word, see [*BSCX*].
+
+bit :: bit value (0-1)
+The command expects 0 or 1.
+
+bits :: a bit mask
+A mask is used to select one or more GPIO. A GPIO is selected
+if bit (1<<GPIO) is set in the mask.
+
+E.g. a mask of 6 (binary 110) select GPIO 1 and 2, a mask of
+0x103 (binary 100000011) selects GPIO 0, 1, and 8.
+
+bv :: a byte value (0-255)
+The command expects a byte value.
+
+bvs :: byte values (0-255)
+The command expects one or more byte values.
+
+c :: SPI channel (0-1)
+The command expects a SPI channel.
+
+cf :: hardware clock frequency (4689-250M, 13184-375M for the BCM2711)
+The command expects a frequency.
+
+cs :: GPIO (0-31)
+The GPIO used for the slave select signal when bit banging SPI.
+
+db :: serial data bits (1-32)
+The command expects the number of data bits per serial character.
+
+dev :: a tty serial device (/dev/tty* or /dev/serial*)
+The command expects the name of a tty serial device, e.g.
+
+...
+/dev/ttyAMA0
+/dev/ttyUSB0
+/dev/tty0
+/dev/serial0
+...
+
+event :: 0-31
+An event is a signal used to inform one or more consumers
+to start an action.
+
+file :: a file name
+The file name must match an entry in /opt/pigpio/access.
+
+from :: 0-2
+Position to seek from [*FS*].
+
+ @ From
+0 @ start
+1 @ current position
+2 @ end
+
+g :: GPIO (0-53)
+The command expects a GPIO.
+
+There are 54 General Purpose Input Outputs (GPIO) named gpio0 through gpio53.
+
+They are split into two banks. Bank 1 consists of gpio0 through gpio31.
+Bank 2 consists of gpio32 through gpio53.
+
+All the GPIO which are safe for the user to read and write are in bank 1.
+Not all GPIO in bank 1 are safe though. Type 1 boards have 17 safe GPIO.
+Type 2 boards have 21. Type 3 boards have 26.
+
+See [*HWVER*].
+
+The user GPIO are marked with an X in the following table.
+
+ @ 0@ 1@ 2@ 3@ 4@ 5@ 6@ 7@ 8@ 9@10@11@12@13@14@15
+Type 1 @ X@ X@ -@ -@ X@ -@ -@ X@ X@ X@ X@ X@ -@ -@ X@ X
+Type 2 @ -@ -@ X@ X@ X@ -@ -@ X@ X@ X@ X@ X@ -@ -@ X@ X
+Type 3 @ @ @ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X
+ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
+ @16@17@18@19@20@21@22@23@24@25@26@27@28@29@30@31
+Type 1 @ -@ X@ X@ -@ -@ X@ X@ X@ X@ X@ -@ -@ -@ -@ -@ -
+Type 2 @ -@ X@ X@ -@ -@ -@ X@ X@ X@ X@ -@ X@ X@ X@ X@ X
+Type 3 @ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ -@ -@ -@ -
+
+You are not prevented from writing to unsafe GPIO. The consequences
+of doing so range from no effect, to a crash, or corrupted data.
+
+h :: handle (>=0)
+The command expects a handle.
+
+A handle is a number referencing an object opened by one of [*FO*],
+[*I2CO*], [*NO*], [*SERO*], [*SPIO*].
+
+ib :: I2C bus (>=0)
+The command expects an I2C bus number.
+
+id :: I2C device (0-0x7F)
+The command expects the address of an I2C device.
+
+if :: I2C flags (0)
+The command expects an I2C flags value. No flags are currently defined.
+
+L :: level (0-1)
+The command expects a GPIO level.
+
+m :: mode (RW540123)
+The command expects a mode character.
+
+Each GPIO can be configured to be in one of 8 different modes. The modes
+are named Input, Output, ALT0, ALT1, ALT2, ALT3, ALT4, and ALT5.
+
+To set the mode use the code for the mode.
+
+The value is returned by the mode get command.
+
+Mode @ Input @ Output @ ALT0 @ ALT1 @ ALT2 @ ALT3 @ ALT4 @ ALT5
+Code @ R @ W @ 0 @ 1 @ 2 @ 3 @ 4 @ 5
+Value @ 0 @ 1 @ 4 @ 5 @ 6 @ 7 @ 3 @ 2
+
+miso :: GPIO (0-31)
+The GPIO used for the MISO signal when bit banging SPI.
+
+mode :: file open mode
+One of the following values.
+
+ @ Value @ Meaning
+READ @ 1 @ open file for reading
+WRITE @ 2 @ open file for writing
+RW @ 3 @ open file for reading and writing
+
+The following values can be or'd into the mode.
+
+ @ Value @ Meaning
+APPEND @ 4 @ All writes append data to the end of the file
+CREATE @ 8 @ The file is created if it doesn't exist
+TRUNC @ 16 @ The file is truncated
+
+mosi :: GPIO (0-31)
+The GPIO used for the MOSI signal when bit banging SPI.
+
+name :: the name of a script
+Only alphanumeric characters, '-' and '_' are allowed in the name.
+
+num :: maximum number of bytes to return (1-)
+The command expects the maximum number of bytes to return.
+
+For the I2C and SPI commands the requested number of bytes will always
+be returned.
+
+For the serial and file commands the smaller of the number of
+bytes available to be read (which may be zero) and [*num*] bytes
+will be returned.
+
+o :: offset (>=0)
+Serial data is stored offset microseconds from the start of the waveform.
+
+p :: PUD (ODU)
+The command expects a PUD character.
+
+Each GPIO can be configured to use or not use an internal pull up or
+pull down resistor. This is useful to provide a default state for inputs.
+
+A pull up will default the input to 1 (high).
+
+A pull down will default the input to 0 (low).
+
+To set the pull up down state use the command character for the state.
+
+Pull Up Down @Off@Pull Down@Pull Up
+Command Character@ O@ D@ U
+
+There is no mechanism to read the pull up down state.
+
+pad :: 0-2
+A set of GPIO which share common drivers.
+
+Pad @ GPIO
+0 @ 0-27
+1 @ 28-45
+2 @ 46-53
+
+padma:: 1-16
+The mA which may be drawn from each GPIO whilst still guaranteeing the
+high and low levels.
+
+pars :: script parameters
+The command expects 0 to 10 numbers as parameters to be passed to the script.
+
+pat :: a file name pattern
+A file path which may contain wildcards. To be accessible the path
+must match an entry in /opt/pigpio/access.
+
+pdc :: hardware PWM dutycycle (0-1000000)
+The command expects a dutycycle.
+
+percent :: percent (1-100)
+The percent of wave resources to allocate to a wave. It can be useful
+to create waves of fixed sizes to prevent wave fragmentation (where
+there are plenty of resources but not a large enough contiguous space).
+
+pf :: hardware PWM frequency (1-125M, 1-187.5M for the BCM2711)
+The command expects a frequency.
+
+pl :: pulse length (1-100)
+The command expects a pulse length in microseconds.
+
+r :: register (0-255)
+The command expects an I2C register number.
+
+sb :: serial stop (half) bits (2-8)
+The command expects the number of stop (half) bits per serial character.
+
+scl :: user GPIO (0-31)
+The command expects the number of the GPIO to be used for SCL
+when bit banging I2C.
+
+sclk :: user GPIO (0-31)
+The GPIO used for the SCLK signal when bit banging SPI.
+
+sda :: user GPIO (0-31)
+The command expects the number of the GPIO to be used for SDA
+when bit banging I2C.
+
+sef :: serial flags (32 bits)
+The command expects a flag value. No serial flags are currently defined.
+
+sid :: script id (>= 0)
+The command expects a script id as returned by a call to [*PROC*].
+
+spf :: SPI flags (32 bits)
+See [*SPIO*] and [*BSPIO*].
+
+stdy :: 0-300000
+
+The number of microseconds level changes must be stable for
+before reporting the level changed ([*FG*]) or triggering
+the active part of a noise filter ([*FN*]).
+
+str :: a string
+The command expects a string.
+
+t :: a string
+The command expects a string.
+
+trips :: triplets
+The command expects 1 or more triplets of GPIO on, GPIO off, delay.
+
+E.g. 0x400000 0 100000 0 0x400000 900000 defines two pulses as follows
+
+ GPIO on @ GPIO off @ delay
+0x400000 (GPIO 22)@ 0 (None)@100000 (1/10th s)
+ 0 (None)@0x400000 (GPIO 22)@900000 (9/10th s)
+
+u :: user GPIO (0-31)
+The command expects the number of a user GPIO.
+
+A number of commands are restricted to GPIO in bank 1,
+in particular the PWM commands, the servo command,
+the watchdog command, and the notification command.
+
+It is your responsibility to ensure that the PWM and servo commands
+are only used on safe GPIO.
+
+See [*g*]
+
+uvs :: values
+The command expects an arbitrary number of >=0 values (possibly none).
+Any after the first two must be <= 255.
+
+v :: value
+The command expects a number.
+
+wid :: wave id (>=0)
+The command expects a wave id.
+
+When a waveform is created it is given an id (0, 1, 2, ...).
+
+wmde :: mode (0-3)
+The command expects a wave transmission mode.
+
+0 = send once
+1 = send repeatedly
+2 = send once but first sync with previous wave
+3 = send repeatedly but first sync with previous wave
+
+ws :: wave stats sucommand (0-2)
+The command expects a subcommand.
+
+0 = current value.
+1 = highest value so far.
+2 = maximum possible value.
+
+wv :: word value (0-65535)
+The command expects a word value.
+
+SCRIPTS
+
+Scripts are programs to be stored and executed by the pigpio daemon.
+They are intended to mitigate any performance problems associated with
+the pigpio daemon server/client model.
+
+*Example*
+
+A trivial example might be useful. Suppose you want to toggle a GPIO
+on and off as fast as possible.
+
+From the command line you could write
+
+...
+for ((i=0; i<1000;i++)); do pigs w 22 1 w 22 0; done
+...
+
+Timing that you will see it takes about 14 seconds, or roughly
+70 toggles per second.
+
+Using the pigpio Python module you could use code such as
+
+...
+#!/usr/bin/env python
+
+import time
+
+import pigpio
+
+PIN=4
+
+TOGGLE=10000
+
+pi = pigpio.pi() # Connect to local Pi.
+
+s = time.time()
+
+for i in range(TOGGLE):
+ pi.write(PIN, 1)
+ pi.write(PIN, 0)
+
+e = time.time()
+
+print("pigpio did {} toggles per second".format(int(TOGGLE/(e-s))))
+
+pi.stop()
+...
+
+Timing that shows a speed improvement to roughly 800 toggles per second.
+
+Now let's use a script.
+
+...
+pigs proc tag 999 w 22 1 w 22 0 dcr p0 jp 999
+...
+
+Ignore the details for now.
+
+Let's time the script running.
+
+Again, ignore the details for now.
+
+...
+time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\
+ do sleep 0.2; done)
+...
+
+The script takes roughly 12 seconds to complete, or 800,000 toggles per second.
+
+That is the advantage of a stored script.
+
+Some details.
+
+...
+pigs proc tag 999 w 22 1 w 22 0 dcr p0 jp 999
+...
+
+proc introduces a script. Everything after proc is part of the script.
+tag 999 names the current position in the script.
+w 22 1 writes 1 to GPIO 22.
+w 22 0 writes 0 to GPIO 22.
+dcr p0 decrements parameter 0.
+jp 999 jumps to tag 999 if the result is positive.
+
+...
+time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\
+ do sleep 0.2; done)
+...
+
+pigs procr 0 10000000 starts script 0 with parameter 0 of 10 million.
+
+The rest is bash apart from
+
+pigs procp 0 asks for the status and parameters of script 0.
+The status will be 2 while the script is running and 1 when it is complete.
+
+*Virtual machine*
+
+A script runs within a virtual machine with
+
+a 32 bit accumulator A.
+a flags register F.
+a program counter PC.
+
+Each script has
+
+10 parameters named 0 through 9.
+150 variables named 0 through 149.
+50 labels which are named by any unique number.
+
+*Commands*
+
+Many pigpio commands may be used within a script. However
+some commands do not work within the script model as designed and
+are not permitted.
+
+The following commands are not permitted within a script:
+
+File - FL FO FR FW
+
+I2C - BI2CZ I2CPK I2CRD I2CRI I2CRK I2CWD I2CWI I2CWK I2CZ
+
+Misc - BSCX CF1 CF2 SHELL
+
+Script control - PARSE PROC PROCD PROCP PROCR PROCS PROCU
+
+Serial - SERO SERR SERW SLR
+
+SPI - BSPIO BSPIX SPIR SPIW SPIX
+
+Waves - WVAG WVAS WVCHA WVGO WVGOR
+
+The following commands are only permitted within a script:
+
+Command@Description @Definition
+ADD x @Add x to accumulator @A+=x; F=A
+AND x @And x with accumulator @A&=x; F=A
+CALL L @Call subroutine at tag L @push(PC+1); PC=L
+CMP x @Compare x with accumulator @F=A-x
+DCR y @Decrement register @--*y; F=*y
+DCRA @Decrement accumulator @--A; F=A
+DIV x @Divide x into accumulator @A/=x; F=A
+EVTWT @Wait for an event to occur @A=wait(x); F=A
+HALT @Halt @Halt
+INR y @Increment register @++*y; F=*y
+INRA @Increment accumulator @++A; F=A
+JM L @Jump if minus to tag L @if (F<0) PC=L
+JMP L @Jump to tag L @PC=L
+JNZ L @Jump if non-zero to tag L @if (F) PC=L
+JP L @Jump if positive to tag L @if (F>=0) PC=L
+JZ L @Jump if zero to tag L @if (!F) PC=L
+LD y x @Load register with x @*y=x
+LDA x @Load accumulator with x @A=x
+MLT x @Multiply x with accumulator @A*=x; F=A
+MOD x @Modulus x with accumulator @A%=x; F=A
+OR x @Or x with accumulator @A|=x; F=A
+POP y @Pop register @y=pop()
+POPA @Pop accumulator @A=pop()
+PUSH y @Push register @push(y)
+PUSHA @Push accumulator @push(A)
+RET @Return from subroutine @PC=pop()
+RL y x @Rotate left register x bits @*y<<=x; F=*y
+RLA x @Rotate left accumulator x bits @A<<=x; F=A
+RR y x @Rotate right register x bits @*y>>=x; F=*y
+RRA x @Rotate right accumulator x bits @A>>=x; F=A
+STA y @Store accumulator in register @y=A
+SUB x @Subtract x from accumulator @A-=x; F=A
+SYS str@Run external script (/opt/pigpio/cgi/str) @system(str); F=A
+TAG L @Label the current script position @N/A
+WAIT x @Wait for a GPIO in x to change state @A=wait(x); F=A
+X y1 y2@Exchange contents of registers y1 and y2 @t=*y1;*y1=*y2;*y2=t
+XA y @Exchange contents of accumulator and register@t=A;A=*y;*y=t
+XOR x @Xor x with accumulator @A^=x; F=A
+
+x may be a constant, a parameter (p0-p9), or a variable (v0-v149).
+
+y may be a parameter (p0-p9), or a variable (v0-v149). If p or v isn't
+specified y is assumed to be a variable.
+
+The EVTWT command parameter is a bit-mask with 1 set for events of interest.
+
+The WAIT command parameter is a bit-mask with 1 set for GPIO of interest.
+
+The SYS script receives two unsigned parameters: the accumulator A and
+the current GPIO levels.
+
diff --git a/DOC/src/html/download.html b/DOC/src/html/download.html
new file mode 100644
index 0000000..740a3c8
--- /dev/null
+++ b/DOC/src/html/download.html
@@ -0,0 +1,68 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.11" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>download</title>
+</head>
+<body>
+If the pigpio daemon is running it should be killed (sudo killall
+pigpiod) before make install and restarted afterwards (sudo
+pigpiod).<br>
+<br>
+<span style="font-weight: bold;">The initial part of the make, the
+compilation of pigpio.c, takes 100 seconds on early model
+Pis.&nbsp; Be patient.&nbsp; The overall install takes just over 3
+minutes.</span><br style="font-weight: bold;">
+<h3>Download and install latest version<br></h3>
+<code>
+wget https://github.com/joan2937/pigpio/archive/master.zip<br>
+unzip master.zip<br>
+cd pigpio-master<br>
+make<br>
+sudo make install<br>
+</code>
+<br>
+If the Python part of the install fails it may be because you need
+the setup tools.<br>
+<br>
+<code>sudo apt install python-setuptools
+python3-setuptools<br></code><br>
+<br>
+<h3>To check the library</h3>
+These tests make extensive use of GPIO 25 (pin 22).&nbsp; Make sure
+nothing, or only a LED, is connected to the GPIO before running the
+tests.&nbsp; Most tests are statistical in nature and so may on
+occasion fail.&nbsp; Repeated failures on the same test or many
+failures in a group of tests indicate a problem.<br>
+<code><br>
+sudo ./x_pigpio # check C I/F<br>
+<br>
+sudo pigpiod&nbsp;&nbsp;&nbsp; # start daemon<br>
+<br>
+./x_pigpiod_if2 # check C&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I/F to
+daemon<br>
+./x_pigpio.py&nbsp;&nbsp; # check Python I/F to daemon<br>
+./x_pigs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # check
+pigs&nbsp;&nbsp; I/F to daemon<br>
+./x_pipe&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # check
+pipe&nbsp;&nbsp; I/F to daemon<br>
+<br>
+<br></code>
+<h3>To compile, link, and run a C program</h3>
+<code>gcc -Wall -pthread -o foobar foobar.c -lpigpio -lrt<br>
+sudo ./foobar</code><code><br></code><br>
+<h3>To start the pigpio daemon<br></h3>
+<code>sudo pigpiod<br></code>
+<h3>To stop the pigpio daemon<br></h3>
+<code>sudo killall pigpiod<br></code><br>
+<h3>github</h3>
+<code>git clone https://github.com/joan2937/pigpio</code><br>
+<h3>Raspbian (raspberrypi.org image)</h3>
+<p>This may not be the most recent version.&nbsp; You can check the
+version with the command pigpiod -v.<br></p>
+<code>sudo apt-get update<br>
+sudo apt-get install pigpio python-pigpio python3-pigpio</code><br>
+<br>
+</body>
+</html>
diff --git a/DOC/src/html/ex_LDR.html b/DOC/src/html/ex_LDR.html
new file mode 100644
index 0000000..3c54c68
--- /dev/null
+++ b/DOC/src/html/ex_LDR.html
@@ -0,0 +1,150 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>LDR example</title>
+</head>
+<body>
+<p>The following code shows a method of reading analogue sensors on
+the digital input only Pi.&nbsp; A Light Dependent Resistor (LDR)
+varies its resistance according to the incident light
+intensisty.</p>
+<h3>SETUP</h3>
+<img src="images/LDR-fritz.png" alt="fritzing diagram" style=
+"width: 200px; height: 300px;" align="left" hspace="10">The LDR
+used is a Cadmium Sulphide device with a 1MOhm dark resistance and
+2-4KOhm at 100 lux.&nbsp; The capacitor is a 104
+ceramic.<span itemprop="name"><br>
+<br>
+One end of the capacitor is connected to Pi ground.<br>
+<br>
+One end of the LDR is connected to Pi 3V3.<br>
+<br>
+The other ends of the capacitor and LDR are connected to a spare
+gpio.</span><br>
+<p>Here P1-1 is used for 3V3, P1-20 is used for ground, and gpio 18
+(P1-12) is used for the gpio.<br clear="all"></p>
+<p><img src="images/LDR-photo.jpg" style=
+"width: 500px; height: 667px;" alt="photo of set-up"></p>
+<h3>CODE</h3>
+<code>#include &lt;stdio.h&gt;<br>
+<br>
+#include &lt;pigpio.h&gt;<br>
+<br>
+/*
+-----------------------------------------------------------------------<br>
+
+<br>
+&nbsp;&nbsp; 3V3 ----- Light Dependent Resistor --+-- Capacitor
+----- Ground<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++-- gpio<br>
+<br>
+<br>
+&nbsp; cc -o LDR LDR.c -lpigpio -lpthread -lrt<br>
+&nbsp; sudo ./LDR<br>
+<br>
+*/<br>
+<br>
+#define LDR 18<br>
+<br>
+/* forward declaration */<br>
+<br>
+void alert(int pin, int level, uint32_t tick);<br>
+<br>
+int main (int argc, char *argv[])<br>
+{<br>
+&nbsp;&nbsp; if (gpioInitialise()&lt;0) return 1;<br>
+<br>
+&nbsp;&nbsp; gpioSetAlertFunc(LDR, alert); /* call alert when LDR
+changes state */<br>
+&nbsp;&nbsp;&nbsp;&nbsp;<br>
+&nbsp;&nbsp; while (1)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioSetMode(LDR, PI_OUTPUT); /*
+drain capacitor */<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioWrite(LDR, PI_OFF);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioDelay(200); /* 50 micros is
+enough, 200 is overkill */<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioSetMode(LDR, PI_INPUT); /* start
+capacitor recharge */<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioDelay(10000); /* nominal 100
+readings per second */<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; gpioTerminate();<br>
+}<br>
+<br>
+void alert(int pin, int level, uint32_t tick)<br>
+{<br>
+&nbsp;&nbsp; static uint32_t inited = 0;<br>
+&nbsp;&nbsp; static uint32_t lastTick, firstTick;<br>
+<br>
+&nbsp;&nbsp; uint32_t diffTick;<br>
+<br>
+&nbsp;&nbsp; if (inited)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; diffTick = tick - lastTick;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lastTick = tick;<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (level == 1) printf("%u %d\ ",
+tick-firstTick, diffTick);<br>
+&nbsp;&nbsp; }<br>
+&nbsp;&nbsp; else<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inited = 1;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; firstTick = tick;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lastTick = firstTick;<br>
+&nbsp;&nbsp; }<br>
+}<br></code>
+<h3>BUILD</h3>
+<code>cc -o LDR LDR.c -lpigpio -lrt -lpthread<br></code>
+<h3>RUN</h3>
+<code>sudo ./LDR &gt;LDR.dat &amp;</code><br>
+<br>
+While the program is running you can capture the waveform using the
+notification feature built in to pigpio.&nbsp; Issue the following
+commands on the Pi.<br>
+<br>
+<code>pigs no<br>
+pig2vcd&nbsp; &lt;/dev/pigpio0 &gt;LDR.vcd &amp;<br>
+pigs nb 0 0x40000 # set bit for gpio 18<br></code>
+<p>Change the light falling on the LDR for a few seconds (e.g.
+shine a torch on it or shade it with your hands).<br></p>
+<code>pigs nc 0</code><br>
+<p>The file LDR.vcd will contain the captured waveform, which can
+be viewed using GTKWave.</p>
+<p>Overview</p>
+<img src="images/LDR-wave-1.png" style=
+"width: 600px; height: 100px;" alt="LDR waveform 1"><br>
+<p>Reading circa every 10ms<br></p>
+<img src="images/LDR-wave-2.png" style=
+"width: 600px; height: 100px;" alt="LDR waveform 2"><br>
+<p>One reading, circa 400us<br></p>
+<img src="images/LDR-wave-3.png" style=
+"width: 600px; height: 100px;" alt="LDR waveform 3"><br>
+<p>The file LDR.dat will contain pairs of timestamps and recharge
+time (in us).&nbsp; The following&nbsp; script will convert the
+timestamps into seconds.<span style=
+"font-style: italic;"><br></span></p>
+<p><code>awk '{print $1/1000000, $2}' LDR.dat
+&gt;LDR-secs.dat</code></p>
+<p>Gnuplot is a useful tool to graph data.<br></p>
+plot [14:24] 'LDR-secs.dat' with lines title 'LDR'
+<p>Gnuplot readings 14-24 seconds<br></p>
+<p><img src="images/LDR-gnup-1.png" style=
+"width: 600px; height: 321px;" alt="gnuplot 1"></p>
+plot [18:21] 'LDR-secs.dat' with lines title 'LDR'<br>
+<br>
+Gnuplot readings 18-21 seconds
+<p><img src="images/LDR-gnup-2.png" style=
+"width: 600px; height: 321px;" alt="Gnuplot 2"></p>
+</body>
+</html>
diff --git a/DOC/src/html/ex_ir_remote.html b/DOC/src/html/ex_ir_remote.html
new file mode 100644
index 0000000..2400a11
--- /dev/null
+++ b/DOC/src/html/ex_ir_remote.html
@@ -0,0 +1,253 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>IR remote example</title>
+</head>
+<body>
+<p>The following code shows one way to read an infrared remote
+control device (the sort used in TVs and stereo systems).</p>
+<h3>SETUP</h3>
+<img alt="fritzing diagram" style="width: 200px; height: 317px;"
+src="images/ir-fritz.png" align="left" hspace="10">The device used
+is a <span itemprop="name">SFH5110 (IR Receiver for remote control,
+carrier 38 kHz).<br>
+<br></span> Pin 1 (left from front) may be connected to any spare
+gpio.&nbsp; Here it's connected via a 4K7 current limiting
+resistor.&nbsp; This isn't really needed as the device has an
+internal 23K resistor in-line.&nbsp; It does no harm though.<br>
+<br>
+Pin 2 should be connected to a Pi ground pin.<br>
+<br>
+Pin 3 should be connected to a Pi 5V pin.<br>
+<p>Here pin 1 to gpio7 (P1-26) via a 4K7 resistor, pin 2 to ground
+(P1-14), and pin 3 to 5V (P1-2).<br clear="all"></p>
+<p><img src="images/ir-photo.jpg" style=
+"width: 500px; height: 500px;" alt="photo of set-up"></p>
+<h3>CODE</h3>
+<code>#include &lt;stdio.h&gt;<br>
+<br>
+#include &lt;pigpio.h&gt;<br>
+<br>
+#define IR_PIN 7<br>
+<br>
+#define OUTSIDE_CODE 0<br>
+#define INSIDE_CODE&nbsp; 1<br>
+<br>
+#define MIN_MESSAGE_GAP 3000<br>
+#define MAX_MESSAGE_END 3000<br>
+<br>
+#define MAX_TRANSITIONS 500<br>
+<br>
+/*<br>
+&nbsp;&nbsp; using the FNV-1a
+hash&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
+
+&nbsp;&nbsp; from
+http://isthe.com/chongo/tech/comp/fnv/#FNV-param<br>
+*/<br>
+<br>
+#define FNV_PRIME_32 16777619<br>
+#define FNV_BASIS_32 2166136261U<br>
+<br>
+static volatile uint32_t ir_hash = 0;<br>
+<br>
+typedef struct<br>
+{<br>
+&nbsp;&nbsp; int state;<br>
+&nbsp;&nbsp; int count;<br>
+&nbsp;&nbsp; int level;<br>
+&nbsp;&nbsp; uint16_t micros[MAX_TRANSITIONS];<br>
+} decode_t;<br>
+<br>
+/* forward declarations */<br>
+<br>
+void&nbsp;&nbsp;&nbsp;&nbsp; alert(int gpio, int level, uint32_t
+tick);<br>
+uint32_t getHash(decode_t * decode);<br>
+void&nbsp;&nbsp;&nbsp;&nbsp; updateState(decode_t * decode, int
+level, uint32_t micros);<br>
+<br>
+int main(int argc, char * argv[])<br>
+{<br>
+&nbsp;&nbsp; if (gpioInitialise()&lt;0)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1 ;<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; /* IR pin as input */<br>
+<br>
+&nbsp;&nbsp; gpioSetMode(IR_PIN, PI_INPUT);<br>
+<br>
+&nbsp;&nbsp; /* 5ms max gap after last pulse */<br>
+<br>
+&nbsp;&nbsp; gpioSetWatchdog(IR_PIN, 5);<br>
+<br>
+&nbsp;&nbsp; /* monitor IR level changes */<br>
+<br>
+&nbsp;&nbsp; gpioSetAlertFunc(IR_PIN, alert);<br>
+<br>
+&nbsp;&nbsp; while (1)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ir_hash)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* non-zero means
+new decode */<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("ir code is
+%u\ ", ir_hash);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ir_hash = 0;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioDelay(100000); /* check remote
+10 times per second */<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; gpioTerminate();<br>
+}<br>
+<br>
+void alert(int gpio, int level, uint32_t tick)<br>
+{<br>
+&nbsp;&nbsp; static int inited = 0;<br>
+<br>
+&nbsp;&nbsp; static decode_t activeHigh, activeLow;<br>
+<br>
+&nbsp;&nbsp; static uint32_t lastTick;<br>
+<br>
+&nbsp;&nbsp; uint32_t diffTick;<br>
+<br>
+&nbsp;&nbsp; if (!inited)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inited = 1;<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; activeHigh.state = OUTSIDE_CODE;
+activeHigh.level = PI_LOW;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; activeLow.state&nbsp; =
+OUTSIDE_CODE; activeLow.level&nbsp; = PI_HIGH;<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lastTick = tick;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; diffTick = tick - lastTick;<br>
+<br>
+&nbsp;&nbsp; if (level != PI_TIMEOUT) lastTick = tick;<br>
+<br>
+&nbsp;&nbsp; updateState(&amp;activeHigh, level, diffTick);<br>
+&nbsp;&nbsp; updateState(&amp;activeLow, level, diffTick);<br>
+}<br>
+<br>
+void updateState(decode_t * decode, int level, uint32_t micros)<br>
+{<br>
+&nbsp;&nbsp; /*<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; We are dealing with active high as
+well as active low<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; remotes.&nbsp; Abstract the common
+functionality.<br>
+&nbsp;&nbsp; */<br>
+<br>
+&nbsp;&nbsp; if (decode-&gt;state == OUTSIDE_CODE)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (level == decode-&gt;level)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (micros &gt;
+MIN_MESSAGE_GAP)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+decode-&gt;state = INSIDE_CODE;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+decode-&gt;count = 0;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp; }<br>
+&nbsp;&nbsp; else<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (micros &gt; MAX_MESSAGE_END)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* end of message
+*/<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* ignore if last
+code not consumed */<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!ir_hash)
+ir_hash = getHash(decode);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; decode-&gt;state =
+OUTSIDE_CODE;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if
+(decode-&gt;count &lt; (MAX_TRANSITIONS-1))<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+if (level != PI_TIMEOUT)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+decode-&gt;micros[decode-&gt;count++] = micros;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp; }<br>
+}<br>
+<br>
+int compare(unsigned int oldval, unsigned int newval)<br>
+{<br>
+&nbsp;&nbsp; if&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (newval &lt; (oldval
+* 0.75)) {return 1;}<br>
+&nbsp;&nbsp; else if (oldval &lt; (newval * 0.75)) {return 2;}<br>
+&nbsp;&nbsp;
+else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+{return 4;}<br>
+}<br>
+<br>
+uint32_t getHash(decode_t * decode)<br>
+{<br>
+&nbsp;&nbsp; /* use FNV-1a */<br>
+<br>
+&nbsp;&nbsp; uint32_t hash;<br>
+&nbsp;&nbsp; int i, value;<br>
+<br>
+&nbsp;&nbsp; if (decode-&gt;count &lt; 6) {return 0;}<br>
+<br>
+&nbsp;&nbsp; hash = FNV_BASIS_32;<br>
+<br>
+&nbsp;&nbsp; for (i=0; i&lt;(decode-&gt;count-2); i++)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value =
+compare(decode-&gt;micros[i], decode-&gt;micros[i+2]);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash = hash ^ value;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash = (hash * FNV_PRIME_32);<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; return hash;<br>
+}<br></code>
+<h3>BUILD</h3>
+<code>cc -o ir_remote ir_remote.c -lpigpio -lrt
+-lpthread<br></code>
+<h3>RUN</h3>
+<code>sudo ./ir_remote</code><br>
+<p>A hash code is formed from the level transitions detected during
+a remote key press.&nbsp; This is likely to be unique over multiple
+remotes and keys.</p>
+<p>While the program is running you can capture the waveform using
+the notification feature built in to pigpio.&nbsp; Issue the
+following commands on the Pi.</p>
+<code>pigs no<br>
+pig2vcd&nbsp; &lt;/dev/pigpio0 &gt;ir.vcd &amp;<br>
+pigs nb 0 0x80 # set bits for gpios 7 (0x80)<br></code>
+<p>Press a few different remotes and keys.&nbsp; Then enter<br></p>
+<code>pigs nc 0</code><br>
+<p>The file ir.vcd will contain the captured waveform, which can be
+viewed using GTKWave.</p>
+<p>Overview</p>
+<img src="images/ir-wave-1.png" style=
+"width: 600px; height: 100px;" alt="ir remote waveform 1"><br>
+<p>Remote A typical waveform</p>
+<img src="images/ir-wave-2.png" style=
+"width: 600px; height: 100px;" alt="ir remote waveform 2"><br>
+<p>Remote B typical waveform</p>
+<img style="width: 600px; height: 100px;" alt=
+"ir remote waveform 3" src="images/ir-wave-3.png">
+</body>
+</html>
diff --git a/DOC/src/html/ex_motor_shield.html b/DOC/src/html/ex_motor_shield.html
new file mode 100644
index 0000000..777ba9e
--- /dev/null
+++ b/DOC/src/html/ex_motor_shield.html
@@ -0,0 +1,254 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>Arduino motor shield example</title>
+</head>
+<body>
+The following example demonstrates the use of an Arduino shield
+from the Rasperry Pi.<br>
+<br>
+The shield used is a clone of the Adafruit motor shield.&nbsp; See
+<a href="http://shieldlist.org/adafruit/motor">shieldlist.org</a>
+for details.<br>
+<br>
+For the demonstration DC motors 3 and 4 are being driven forwards
+and backwards with changing speeds (speeds are controlled via
+PWM).<br>
+<br>
+Seven connections are made between the Pi and the shield.&nbsp;
+Four to latch the motor states (latch, enable, data, clock); Two to
+control motor speed (PWM 3 and 4); and ground.<br>
+<br>
+The code used was ported from the Adafruit Arduino code and
+converted to use the pigpio library.&nbsp; Only the DC motor code
+was ported.<br>
+<br>
+A video of the shield in use is available at <a href=
+"http://youtu.be/Z_l3C246oVI">youtube.com</a><br>
+<code><br>
+#include &lt;stdio.h&gt;</code> <code><br>
+<br>
+#include &lt;pigpio.h&gt;<br>
+<br>
+/*<br>
+&nbsp;&nbsp; This code may be used to drive the Adafruit (or
+clones) Motor Shield.<br>
+<br>
+&nbsp;&nbsp; The code as written only supports DC motors.<br>
+<br>
+&nbsp;&nbsp; http://shieldlist.org/adafruit/motor<br>
+<br>
+&nbsp;&nbsp; The shield pinouts are<br>
+<br>
+&nbsp;&nbsp; D12 MOTORLATCH<br>
+&nbsp;&nbsp; D11 PMW motor 1<br>
+&nbsp;&nbsp; D10 Servo 1<br>
+&nbsp;&nbsp; D9&nbsp; Servo 2<br>
+&nbsp;&nbsp; D8&nbsp; MOTORDATA<br>
+<br>
+&nbsp;&nbsp; D7&nbsp; MOTORENABLE<br>
+&nbsp;&nbsp; D6&nbsp; PWM motor 4<br>
+&nbsp;&nbsp; D5&nbsp; PWM motor 3<br>
+&nbsp;&nbsp; D4&nbsp; MOTORCLK<br>
+&nbsp;&nbsp; D3&nbsp; PWM motor 2<br>
+<br>
+&nbsp;&nbsp; The motor states (forward, backward, brake, release)
+are encoded using the<br>
+&nbsp;&nbsp; MOTOR_ latch pins.&nbsp; This saves four gpios.<br>
+*/<br>
+<br>
+typedef unsigned char uint8_t;<br>
+<br>
+#define BIT(bit) (1 &lt;&lt; (bit))<br>
+<br>
+/* assign gpios to drive the shield pins */<br>
+<br>
+/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+Shield&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Pi */<br>
+<br>
+#define MOTORLATCH&nbsp; 14<br>
+#define MOTORCLK&nbsp;&nbsp;&nbsp; 24<br>
+#define MOTORENABLE 25<br>
+#define MOTORDATA&nbsp;&nbsp; 15<br>
+<br>
+#define MOTOR_3_PWM&nbsp; 7<br>
+#define MOTOR_4_PWM&nbsp; 8<br>
+<br>
+/*<br>
+&nbsp;&nbsp; The only other connection needed between the Pi and
+the shield<br>
+&nbsp;&nbsp; is ground to ground. I used Pi P1-6 to shield gnd
+(next to D13).<br>
+*/<br>
+<br>
+/* assignment of motor states to latch */<br>
+<br>
+#define MOTOR1_A 2<br>
+#define MOTOR1_B 3<br>
+#define MOTOR2_A 1<br>
+#define MOTOR2_B 4<br>
+#define MOTOR4_A 0<br>
+#define MOTOR4_B 6<br>
+#define MOTOR3_A 5<br>
+#define MOTOR3_B 7<br>
+<br>
+#define FORWARD&nbsp; 1<br>
+#define BACKWARD 2<br>
+#define BRAKE&nbsp;&nbsp;&nbsp; 3<br>
+#define RELEASE&nbsp; 4<br>
+<br>
+static uint8_t latch_state;<br>
+<br>
+void latch_tx(void)<br>
+{<br>
+&nbsp;&nbsp; unsigned char i;<br>
+<br>
+&nbsp;&nbsp; gpioWrite(MOTORLATCH, PI_LOW);<br>
+<br>
+&nbsp;&nbsp; gpioWrite(MOTORDATA, PI_LOW);<br>
+<br>
+&nbsp;&nbsp; for (i=0; i&lt;8; i++)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioDelay(10);&nbsp; // 10 micros
+delay<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioWrite(MOTORCLK, PI_LOW);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (latch_state &amp; BIT(7-i))
+gpioWrite(MOTORDATA, PI_HIGH);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+gpioWrite(MOTORDATA, PI_LOW);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioDelay(10);&nbsp; // 10 micros
+delay<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioWrite(MOTORCLK, PI_HIGH);<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; gpioWrite(MOTORLATCH, PI_HIGH);<br>
+}<br>
+<br>
+void init(void)<br>
+{<br>
+&nbsp;&nbsp; latch_state = 0;<br>
+<br>
+&nbsp;&nbsp; latch_tx();<br>
+<br>
+&nbsp;&nbsp; gpioWrite(MOTORENABLE, PI_LOW);<br>
+}<br>
+<br>
+void DCMotorInit(uint8_t num)<br>
+{<br>
+&nbsp;&nbsp; switch (num)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 1: latch_state &amp;=
+~BIT(MOTOR1_A) &amp; ~BIT(MOTOR1_B); break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 2: latch_state &amp;=
+~BIT(MOTOR2_A) &amp; ~BIT(MOTOR2_B); break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 3: latch_state &amp;=
+~BIT(MOTOR3_A) &amp; ~BIT(MOTOR3_B); break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 4: latch_state &amp;=
+~BIT(MOTOR4_A) &amp; ~BIT(MOTOR4_B); break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default: return;<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; latch_tx();<br>
+<br>
+&nbsp;&nbsp; printf("Latch=%08X\ ", latch_state);<br>
+}<br>
+<br>
+void DCMotorRun(uint8_t motornum, uint8_t cmd)<br>
+{<br>
+&nbsp;&nbsp; uint8_t a, b;<br>
+<br>
+&nbsp;&nbsp; switch (motornum)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 1: a = MOTOR1_A; b = MOTOR1_B;
+break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 2: a = MOTOR2_A; b = MOTOR2_B;
+break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 3: a = MOTOR3_A; b = MOTOR3_B;
+break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 4: a = MOTOR4_A; b = MOTOR4_B;
+break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default: return;<br>
+&nbsp;&nbsp; }<br>
+&nbsp;<br>
+&nbsp;&nbsp; switch (cmd)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case FORWARD:&nbsp; latch_state
+|=&nbsp; BIT(a); latch_state &amp;= ~BIT(b); break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case BACKWARD: latch_state &amp;=
+~BIT(a); latch_state |=&nbsp; BIT(b); break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case RELEASE:&nbsp; latch_state
+&amp;= ~BIT(a); latch_state &amp;= ~BIT(b); break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default: return;<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; latch_tx();<br>
+<br>
+&nbsp;&nbsp; printf("Latch=%08X\ ", latch_state);<br>
+}<br>
+<br>
+int main (int argc, char *argv[])<br>
+{<br>
+&nbsp;&nbsp; int i;<br>
+<br>
+&nbsp;&nbsp; if (gpioInitialise()&lt;0) return 1;<br>
+<br>
+&nbsp;&nbsp; gpioSetMode(MOTORLATCH,&nbsp; PI_OUTPUT);<br>
+&nbsp;&nbsp; gpioSetMode(MOTORENABLE, PI_OUTPUT);<br>
+&nbsp;&nbsp; gpioSetMode(MOTORDATA,&nbsp;&nbsp; PI_OUTPUT);<br>
+&nbsp;&nbsp; gpioSetMode(MOTORCLK,&nbsp;&nbsp;&nbsp;
+PI_OUTPUT);<br>
+<br>
+&nbsp;&nbsp; gpioSetMode(MOTOR_3_PWM, PI_OUTPUT);<br>
+&nbsp;&nbsp; gpioSetMode(MOTOR_4_PWM, PI_OUTPUT);<br>
+<br>
+&nbsp;&nbsp; gpioPWM(MOTOR_3_PWM, 0);<br>
+&nbsp;&nbsp; gpioPWM(MOTOR_4_PWM, 0);<br>
+<br>
+&nbsp;&nbsp; init();<br>
+<br>
+&nbsp;&nbsp; for (i=60; i&lt;160; i+=20)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioPWM(MOTOR_3_PWM, i);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioPWM(MOTOR_4_PWM, 220-i);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(3, FORWARD);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(4, BACKWARD);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep(2);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(3, RELEASE);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(4, RELEASE);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep(2);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioPWM(MOTOR_4_PWM, i);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioPWM(MOTOR_3_PWM, 220-i);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(3, BACKWARD);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(4, FORWARD);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep(2);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(3, RELEASE);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(4, RELEASE);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep(2);<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; gpioPWM(MOTOR_4_PWM, 0);<br>
+&nbsp;&nbsp; gpioPWM(MOTOR_3_PWM, 0);<br>
+<br>
+&nbsp;&nbsp; DCMotorRun(3, RELEASE);<br>
+&nbsp;&nbsp; DCMotorRun(4, RELEASE);<br>
+<br>
+&nbsp;&nbsp; gpioTerminate();<br>
+}<br></code>
+</body>
+</html>
diff --git a/DOC/src/html/ex_rotary_encoder.html b/DOC/src/html/ex_rotary_encoder.html
new file mode 100644
index 0000000..b95711e
--- /dev/null
+++ b/DOC/src/html/ex_rotary_encoder.html
@@ -0,0 +1,185 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>Rotary encoder sample</title>
+</head>
+<body>
+<p>The following code shows one way to read an incremental
+mechanical rotary enoder (the sort used for volume control in audio
+systems).&nbsp; These rotary encoders have two switches A and B
+which return a quadrature output, i.e. they are 90 degrees out of
+phase.</p>
+<h3>SETUP</h3>
+<img alt="fritzing diagram" style="width: 200px; height: 300px;"
+src="images/re-fritz.png" align="left" hspace="10">The common
+(centre) terminal should be connected to a Pi ground.
+<p>The A and B terminals may be connected to any spare gpios.</p>
+<p>Here A to gpio18 (P1-12), common to ground (P1-20), B to gpio7
+(P1-26).<br clear="all"></p>
+<p><img src="images/re-photo.jpg" style=
+"width: 400px; height: 300px;" alt="photo of set-up"></p>
+<h3>CODE</h3>
+<code>#include &lt;stdio.h&gt;<br>
+<br>
+#include &lt;pigpio.h&gt;<br>
+<br>
+/*<br>
+&nbsp;&nbsp; Rotary encoder connections:<br>
+<br>
+&nbsp;&nbsp; Encoder A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - gpio
+18&nbsp;&nbsp; (pin P1-12)<br>
+&nbsp;&nbsp; Encoder B&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - gpio
+7&nbsp;&nbsp;&nbsp; (pin P1-26)<br>
+&nbsp;&nbsp; Encoder Common - Pi ground (pin P1-20)<br>
+*/<br>
+<br>
+#define ENCODER_A 18<br>
+#define ENCODER_B&nbsp; 7<br>
+<br>
+static volatile int encoderPos;<br>
+<br>
+/* forward declaration */<br>
+<br>
+void encoderPulse(int gpio, int lev, uint32_t tick);<br>
+<br>
+int main(int argc, char * argv[])<br>
+{<br>
+&nbsp;&nbsp; int pos=0;<br>
+<br>
+&nbsp;&nbsp; if (gpioInitialise()&lt;0) return 1;<br>
+<br>
+&nbsp;&nbsp; gpioSetMode(ENCODER_A, PI_INPUT);<br>
+&nbsp;&nbsp; gpioSetMode(ENCODER_B, PI_INPUT);<br>
+<br>
+&nbsp;&nbsp; /* pull up is needed as encoder common is grounded
+*/<br>
+<br>
+&nbsp;&nbsp; gpioSetPullUpDown(ENCODER_A, PI_PUD_UP);<br>
+&nbsp;&nbsp; gpioSetPullUpDown(ENCODER_B, PI_PUD_UP);<br>
+<br>
+&nbsp;&nbsp; encoderPos = pos;<br>
+<br>
+&nbsp;&nbsp; /* monitor encoder level changes */<br>
+<br>
+&nbsp;&nbsp; gpioSetAlertFunc(ENCODER_A, encoderPulse);<br>
+&nbsp;&nbsp; gpioSetAlertFunc(ENCODER_B, encoderPulse);<br>
+<br>
+&nbsp;&nbsp; while (1)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (pos != encoderPos)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pos =
+encoderPos;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("pos=%d\ ",
+pos);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioDelay(20000); /* check pos 50
+times per second */<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; gpioTerminate();<br>
+}<br>
+<br>
+void encoderPulse(int gpio, int level, uint32_t tick)<br>
+{<br>
+&nbsp;&nbsp; /*<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++---------+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++---------+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
+&nbsp;&nbsp; A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
+&nbsp;&nbsp;
++---------+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++---------+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +-----
+1<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++---------+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++---------+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+0<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
+&nbsp;&nbsp; B&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
+&nbsp;&nbsp; ----+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++---------+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++---------+&nbsp; 1<br>
+<br>
+&nbsp;&nbsp; */<br>
+<br>
+&nbsp;&nbsp; static int levA=0, levB=0, lastGpio = -1;<br>
+<br>
+&nbsp;&nbsp; if (gpio == ENCODER_A) levA = level; else levB =
+level;<br>
+<br>
+&nbsp;&nbsp; if (gpio != lastGpio) /* debounce */<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lastGpio = gpio;<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((gpio == ENCODER_A) &amp;&amp;
+(level == 0))<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!levB)
+++encoderPos;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ((gpio == ENCODER_B)
+&amp;&amp; (level == 1))<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (levA)
+--encoderPos;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp; }<br>
+}<br></code>
+<h3>BUILD</h3>
+<code>cc -o rotary_encoder rotary_encoder.c -lpigpio -lrt
+-lpthread<br></code>
+<h3>RUN</h3>
+<code>sudo ./rotary_encoder</code><br>
+<p>While the program is running you can capture the waveform using
+the notification feature built in to pigpio.&nbsp; Issue the
+following commands on the Pi.</p>
+<code>pigs no<br>
+pig2vcd&nbsp; &lt;/dev/pigpio0 &gt;re.vcd &amp;<br>
+pigs nb 0 0x40080 # set bits for gpios 7 (0x80) and 18
+(0x40000)<br></code>
+<p>Twiddle the rotary encoder forwards and backwards for a few
+seconds.&nbsp; Then enter<br></p>
+<code>pigs nc 0</code><br>
+<p>The file re.vcd will contain the captured waveform, which can be
+viewed using GTKWave.</p>
+<br>
+Overview<br>
+<br>
+<img src="images/re-wave-1.png" style=
+"width: 600px; height: 100px;" alt=
+"rotary encoder waveform overview"><br>
+<br>
+Detail of switch bounce.&nbsp; Contact A bounces for circa 700 us
+before completing the level transition<br>
+<br>
+<img src="images/re-wave-2.png" style=
+"width: 600px; height: 100px;" alt=
+"rotary encoder waveform detail"><br>
+</body>
+</html>
diff --git a/DOC/src/html/ex_sonar_ranger.html b/DOC/src/html/ex_sonar_ranger.html
new file mode 100644
index 0000000..8edb9c2
--- /dev/null
+++ b/DOC/src/html/ex_sonar_ranger.html
@@ -0,0 +1,164 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>Sonar ranger example</title>
+</head>
+<body>
+<p>The following code shows a method of reading a class of sonar
+rangers.&nbsp; These rangers requires a trigger pulse.&nbsp;
+Shortly after receiving a trigger they transmit a noise pulse and
+set the echo line high.&nbsp; When the echo is received the echo
+line is set low.<br></p>
+<h3>SETUP</h3>
+<img src="images/son-fritz.png" alt="fritzing diagram" style=
+"width: 200px; height: 600px;" align="left" hspace="10"><br>
+<br>
+<br>
+<br>
+<br>
+The ranger used is a SRF05 (check the pinouts, there are many
+variants).<br>
+<br>
+The fritzing diagram shows the back of the ranger, i.e. pin 1 is
+the rightmost.<br>
+<br>
+Pin 1 is 5V.<br>
+Pin 2 is the trigger line.<br>
+Pin 3 is the echo line.<br>
+Pin 4 is out (unused).<br>
+Pin 5 is ground.<br>
+<br clear="all">
+<p><img src="images/son-photo.jpg" style=
+"width: 500px; height: 376px;" alt="photo of set-up"></p>
+<h3>CODE</h3>
+<code>#include &lt;stdio.h&gt;<br>
+<br>
+#include &lt;pigpio.h&gt;<br>
+<br>
+/*<br>
+<br>
+P1&nbsp; Name&nbsp; gpio&nbsp;&nbsp;&nbsp; used for<br>
+<br>
+&nbsp;2&nbsp; 5V&nbsp;&nbsp;&nbsp; ---&nbsp;&nbsp;&nbsp;&nbsp;
+5V<br>
+&nbsp;6&nbsp; GND&nbsp;&nbsp; ---&nbsp;&nbsp;&nbsp;&nbsp;
+Ground<br>
+24&nbsp; CE0&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+Sonar echo<br>
+26&nbsp; CE1&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+Sonar trigger<br>
+<br>
+*/<br>
+<br>
+#define SONAR_TRIGGER 7<br>
+#define SONAR_ECHO&nbsp;&nbsp;&nbsp; 8<br>
+<br>
+/* forward prototypes */<br>
+<br>
+void sonarTrigger(void);<br>
+<br>
+void sonarEcho(int gpio, int level, uint32_t tick);<br>
+<br>
+int main(int argc, char *argv[])<br>
+{<br>
+&nbsp;&nbsp; if (gpioInitialise()&lt;0) return 1;<br>
+<br>
+&nbsp;&nbsp; gpioSetMode(SONAR_TRIGGER, PI_OUTPUT);<br>
+&nbsp;&nbsp; gpioWrite&nbsp; (SONAR_TRIGGER, PI_OFF);<br>
+<br>
+&nbsp;&nbsp; gpioSetMode(SONAR_ECHO,&nbsp;&nbsp;&nbsp;
+PI_INPUT);<br>
+<br>
+&nbsp;&nbsp; /* update sonar 20 times a second, timer #0 */<br>
+<br>
+&nbsp;&nbsp; gpioSetTimerFunc(0, 50, sonarTrigger); /* every 50ms
+*/<br>
+<br>
+&nbsp;&nbsp; /* monitor sonar echos */<br>
+<br>
+&nbsp;&nbsp; gpioSetAlertFunc(SONAR_ECHO, sonarEcho);<br>
+<br>
+&nbsp;&nbsp; while (1) sleep(1);<br>
+<br>
+&nbsp;&nbsp; gpioTerminate();<br>
+<br>
+&nbsp;&nbsp; return 0;<br>
+}<br>
+<br>
+void sonarTrigger(void)<br>
+{<br>
+&nbsp;&nbsp; /* trigger a sonar reading */<br>
+<br>
+&nbsp;&nbsp; gpioWrite(SONAR_TRIGGER, PI_ON);<br>
+<br>
+&nbsp;&nbsp; gpioDelay(10); /* 10us trigger pulse */<br>
+<br>
+&nbsp;&nbsp; gpioWrite(SONAR_TRIGGER, PI_OFF);<br>
+}<br>
+<br>
+void sonarEcho(int gpio, int level, uint32_t tick)<br>
+{<br>
+&nbsp;&nbsp; static uint32_t startTick, firstTick=0;<br>
+<br>
+&nbsp;&nbsp; int diffTick;<br>
+<br>
+&nbsp;&nbsp; if (!firstTick) firstTick = tick;<br>
+<br>
+&nbsp;&nbsp; if (level == PI_ON)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; startTick = tick;<br>
+&nbsp;&nbsp; }<br>
+&nbsp;&nbsp; else if (level == PI_OFF)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; diffTick = tick - startTick;<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("%u %u\ ", tick-firstTick,
+diffTick);<br>
+&nbsp;&nbsp; }<br>
+}<br></code>
+<h3>BUILD</h3>
+<code>cc -o sonar sonar.c -lpigpio -lrt -lpthread<br></code>
+<h3>RUN</h3>
+<code>sudo ./sonar &gt;sonar.dat &amp;</code><br>
+<br>
+While the program is running you can capture the waveform using the
+notification feature built in to pigpio.&nbsp; Issue the following
+commands on the Pi.<br>
+<br>
+<code>pigs no<br>
+pig2vcd&nbsp; &lt;/dev/pigpio0 &gt;sonar.vcd &amp;<br>
+pigs nb 0 0x180 # set bits for gpios 7 and 8<br></code>
+<p>Move an object in front of the sonar ranger for a few
+seconds.<br></p>
+<code>pigs nc 0</code><br>
+<p>The file sonar.vcd will contain the captured waveform, which can
+be viewed using GTKWave.</p>
+<p>Overview</p>
+<img src="images/son-wave-1.png" style=
+"width: 600px; height: 100px;" alt="LDR waveform 1"><br>
+<p>Reading circa every 10ms<br></p>
+<img src="images/son-wave-2.png" style=
+"width: 600px; height: 100px;" alt="Sonar waveform 2"><br>
+<p>One reading, circa 400us<br></p>
+<img src="images/son-wave-3.png" style=
+"width: 600px; height: 100px;" alt="Sonar waveform 3"><br>
+<p>another</p>
+<img style="width: 600px; height: 100px;" alt="Sonar waveform 4"
+src="images/son-wave-4.png"><br>
+<p>The file sonar.dat will contain pairs of timestamps and echo
+length (in us).&nbsp; The following&nbsp; script will convert the
+timestamps into seconds.<span style=
+"font-style: italic;"><br></span></p>
+<p><code>awk '{print $1/1000000, $2}' sonar.dat
+&gt;sonar-secs.dat</code></p>
+<p>Gnuplot is a useful tool to graph data.<br></p>
+plot 'sonar-secs.dat' title 'Sonar'<br>
+<p><img src="images/son-gnup-1.png" style=
+"width: 600px; height: 321px;" alt="gnuplot 1"><br>
+&nbsp;plot [10:25] 'sonar-secs.dat' title 'Sonar'<br></p>
+<p><img src="images/son-gnup-2.png" style=
+"width: 600px; height: 321px;" alt="gnuplot 1"></p>
+</body>
+</html>
diff --git a/DOC/src/html/faq.html b/DOC/src/html/faq.html
new file mode 100644
index 0000000..b8d6df5
--- /dev/null
+++ b/DOC/src/html/faq.html
@@ -0,0 +1,462 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content=
+"HTML Tidy for HTML5 for Linux version 5.6.0">
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>faq</title>
+</head>
+<body>
+<a href="#Are_my_GPIO_broken">Are my GPIO broken?</a><br>
+<br>
+<a href="#Audio_is_broken">Audio is broken</a><br>
+<br>
+<a href="#Cant_initialise_pigpio_library">Can´t initialise pigpio
+library</a><br>
+<br>
+<a href="#Cant_lock_varrunpigpio.pid">Can´t lock
+var/run/pigpio.pid</a><br>
+<br>
+<a href="#Hello_World">Hello World!</a><br>
+<br>
+<a href="#make_fails">Clock skew, make fails</a><br>
+<br>
+<a href="#Have_I_fried_my_GPIO">Have I fried my GPIO?</a><br>
+<br>
+<a href="#How_do_I_debounce_inputs">How do I debounce
+inputs?</a><br>
+<br>
+<a href="#How_fast_is_SPI">How fast is SPI?</a><br>
+<br>
+<a href="#Library_update_fails">Library update didn't work</a><br>
+<br>
+<a href="#make_fails">make fails with clock skew</a><br>
+<br>
+<a href="#Porting_pigpio">Porting pigpio to another CPU/SoC</a><br>
+<br>
+<a href="#Sound_isnt_working">Sound isn't working</a><br>
+<br>
+<a href="#Library_update_fails">Symbol not found</a><br>
+<br>
+<a href="#What_is_I2C">What is I2C?</a><br>
+<br>
+<a href="#What_is_Serial">What is Serial?</a><br>
+<br>
+<a href="#What_is_SPI">What is SPI?</a><br>
+<br>
+<a href="#Which_library">Which library should I use?</a><br>
+<br>
+<h3><a name="Are_my_GPIO_broken" id="Are_my_GPIO_broken"></a>Are my
+GPIO broken?</h3>
+<p>See <a href="#Have_I_fried_my_GPIO">Have I fried my
+GPIO?</a><br></p>
+<h3><a name="Audio_is_broken" id="Audio_is_broken"></a>Audio is
+broken</h3>
+<p>See <a href="#Sound_isnt_working">Sound isn't
+working</a><br></p>
+<h3><a name="Cant_lock_varrunpigpio.pid" id=
+"Cant_lock_varrunpigpio.pid"></a>Can´t lock
+/var/run/pigpio.pid</h3>
+<p>See <a href=
+"#Cant_initialise_pigpio_library">Can´t_initialise_pigpio_library</a><br>
+</p>
+<h3><a name="Cant_initialise_pigpio_library" id=
+"Cant_initialise_pigpio_library"></a>Can´t initialise pigpio
+library</h3>
+<p>This message means the pigpio daemon is already running.<br></p>
+<p>The default daemon is called pigpiod and may be removed as
+follows.<br></p>
+Check that it is running with the command
+<p><code>ps aux | grep pigpiod</code></p>
+<p>Kill the daemon with<br></p>
+<p><code>sudo killall pigpiod</code></p>
+<p>If your own program is acting as the daemon it may be removed as
+follows.</p>
+<p>Find its process id (<span style=
+"font-style: italic;">pid</span>).<br></p>
+<p><code>cat /var/run/pigpio.pid</code><br></p>
+<p>Kill the program with<br></p>
+<p><code>sudo kill -9 <span style=
+"font-style: italic;">pid</span></code><br></p>
+If the above doesn't work do the following and try starting the
+daemon again
+<p><code>sudo rm /var/run/pigpio.pid<br></code></p>
+<p>To start the daemon do</p>
+<p><code>sudo pigpiod</code></p>
+<h3><a name="Have_I_fried_my_GPIO" id=
+"Have_I_fried_my_GPIO"></a>Have I fried my GPIO?</h3>
+<p>If you think you have damaged one or more GPIO you can carry out
+a diagnostic test.</p>
+<p>The test is a command line script called <a rel="nofollow"
+class="external text" href=
+"http://abyz.me.uk/rpi/pigpio/code/gpiotest.zip">gpiotest</a></p>
+For the duration of the test nothing must be connected to the GPIO
+(no LEDs, wires, ribbon cables etc.).
+<p>The test checks that each GPIO may be read and written and that
+the internal resistor pull-ups and pull-downs are functional.</p>
+<p>A <a rel="nofollow" class="external text" href=
+"https://www.youtube.com/watch?v=sCJFLKWaxHo&amp;feature=youtu.be">video</a>
+showing what happens to the GPIO during a test.</p>
+<p>A test with all GPIO okay.</p>
+<pre>This program checks the Pi's (user) gpios.
+
+The program reads and writes all the gpios. Make sure NOTHING
+is connected to the gpios during this test.
+
+The program uses the pigpio daemon which must be running.
+
+To start the daemon use the command sudo pigpiod.
+
+Press the ENTER key to continue or ctrl-C to abort...
+
+Testing...
+Skipped non-user gpios: 0 1 28 29 30 31
+Tested user gpios: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18<br> 19 20 21 22 23 24 25 26 27
+Failed user gpios: None
+</pre>
+<p>A test showing failed GPIO.</p>
+<pre>This program checks the Pi's (user) gpios.
+
+The program reads and writes all the gpios. Make sure NOTHING
+is connected to the gpios during this test.
+
+The program uses the pigpio daemon which must be running.
+
+To start the daemon use the command sudo pigpiod.
+
+Press the ENTER key to continue or ctrl-C to abort...
+
+Testing...
+Write 1 to gpio 17 failed.
+Pull up on gpio 17 failed.
+Write 1 to gpio 18 failed.
+Pull up on gpio 18 failed.
+Write 0 to gpio 23 failed.
+Pull down on gpio 23 failed.
+Write 0 to gpio 24 failed.
+Pull down on gpio 24 failed.
+Write 1 to gpio 27 failed.
+Pull up on gpio 27 failed.
+Skipped non-user gpios: 0 1 28 29 30 31
+Tested user gpios: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18<br> 19 20 21 22 23 24 25 26 27
+Failed user gpios: 17 18 23 24 27
+</pre>
+<h3><a name="How_do_I_debounce_inputs" id=
+"How_do_I_debounce_inputs"></a>How do I debounce inputs?</h3>
+<p>Some devices like mechanical switches can generate multiple
+interrupts as they bounce between on and off.&nbsp; It is possible
+to debounce the inputs in hardware by the correct use of resistors
+and capacitors.<br></p>
+<p>In software use the glitch filter which ignores all events
+shorter than a set number of microseconds.&nbsp; C <a href=
+"cif.html#gpioGlitchFilter">gpioGlitchFilter</a>, Python <a href=
+"python.html#set_glitch_filter">set_glitch_filter</a>.<br></p>
+<h3><a name="How_fast_is_SPI" id="How_fast_is_SPI"></a>How fast is
+SPI?</h3>
+The SPI throughput in samples per second depends on a number of
+factors.<br>
+<br>
+<ul>
+<li>The SPI bit rate (transfer rate in bits per second)</li>
+</ul>
+<ul>
+<li>The number of bytes transferred per sample (a 12 bit ADC sample
+may require 3 bytes to transfer)</li>
+</ul>
+<ul>
+<li>The driver used</li>
+</ul>
+<p>Two of those factors are fixed, the variable is the driver
+used.</p>
+<p>The pigpio driver is considerably faster than the Linux SPI
+driver as is demonstrated by the following graphs.<br></p>
+<p>Each graph shows the SPI bit rate in bits per second along the
+horizontal axis.&nbsp; The samples per second achieved is shown on
+the vertical axis.&nbsp; Each graph contains plots assuming 1 to 5
+bytes per transfer.<br></p>
+<p>The source code used for the tests is <a href=
+"code/spi-driver-speed.c">spi-driver-speed.c</a> and <a href=
+"code/spi-pigpio-speed.c">spi-pigpio-speed.c</a><br></p>
+<p><img alt="spi-lnx-pibr1.png" src="images/spi-lnx-pibr1.png"></p>
+<hr>
+<p><img alt="spi-pig-pibr1.png" src="images/spi-pig-pibr1.png"></p>
+<hr>
+<p><img alt="spi-lnx-pi3b.png" src="images/spi-lnx-pi3b.png"></p>
+<hr>
+<p><img alt="spi-pig-pi3b.png" src="images/spi-pig-pi3b.png"></p>
+<h3><a name="Library_update_fails" id=
+"Library_update_fails"></a>Library update didn't work</h3>
+<p>pigpio places files in the following locations<br></p>
+<p>/usr/local/include (pigpio.h, pigpiod_if.h, pigpiod_if2.h)<br>
+/usr/local/lib (libpigpio.so, libpigpiod_if.so,
+libpigpiod_if2.so)<br>
+/usr/local/bin (pig2vcd, pigpiod, pigs)<br>
+/usr/local/man (man pages)<br></p>
+The raspberrypi.org image containing pigpio uses different
+locations.<br>
+<p>/usr/include (pigpio.h, pigpiod_if.h, pigpiod_if2.h)<br>
+/usr/lib (libpigpio.so, libpigpiod_if.so, libpigpiod_if2.so)<br>
+/usr/bin (pig2vcd, pigpiod, pigs)<br>
+/usr/man (man pages)<br></p>
+<p>Mostly this doesn't matter as the /usr/local directories will
+generally be earlier in the search path.&nbsp; The pigpio built
+includes, binaries, and manuals are normally found first.<br></p>
+<p>However the wrong libraries may be linked during the
+compilation.&nbsp; If this is the case remove the /usr/lib entries
+for libpigpio.so , libpigpiod_if.so, and libpigpiod_if2.so</p>
+<h3><a name="Hello_World" id="Hello_World"></a>Hello World!</h3>
+<p>The following examples show how to use the various components of
+the pigpio library.</p>
+<p>Each example shows how to read the level of a GPIO.</p>
+<h4>C</h4>
+read_cif.c
+<pre>
+#include &lt;stdio.h&gt;
+#include &lt;pigpio.h&gt;
+
+int main(int argc, char *argv[])
+{
+ int GPIO=4;
+ int level;
+
+ if (gpioInitialise() &lt; 0) return 1;
+
+ level = gpioRead(GPIO);
+
+ printf("GPIO %d is %d\n", GPIO, level);
+
+ gpioTerminate();
+}
+ </pre>
+<p>Build</p>
+<code>gcc -pthread -o read_cif read_cif.c -lpigpio</code>
+<p>Run</p>
+<code>sudo ./read_cif</code>
+<h4>C via pigpio daemon</h4>
+read_pdif.c
+<pre>
+#include &lt;stdio.h&gt;
+#include &lt;pigpiod_if2.h&gt;
+
+int main(int argc, char *argv[])
+{
+ int pi;
+ int GPIO=4;
+ int level;
+
+ pi = pigpio_start(0, 0); /* Connect to local Pi. */
+
+ if (pi &lt; 0)
+ {
+ printf("Can't connect to pigpio daemon\n");
+ return 1;
+ }
+
+ level = gpio_read(pi, GPIO);
+
+ printf("GPIO %d is %d\n", GPIO, level);
+
+ pigpio_stop(pi); /* Disconnect from local Pi. */
+
+ return 0;
+}
+</pre>
+<p>Build</p>
+<code>gcc -pthread -o read_pdif read_pdif.c -lpigpiod_if2</code>
+<p>Run</p>
+<code>./read_pdif</code>
+<h4>Python</h4>
+read_gpio.py
+<pre>
+#!/usr/bin/env python
+
+import pigpio
+
+GPIO=4
+
+pi = pigpio.pi()
+if not pi.connected:
+ exit()
+
+level = pi.read(GPIO)
+
+print("GPIO {} is {}".format(GPIO, level))
+
+pi.stop()
+ </pre>
+<p>Run</p>
+<code>python read_gpio.py</code>
+<h4>pigs</h4>
+<pre>
+pigs r 4
+ </pre>
+<h4>pipe I/F</h4>
+<pre>
+echo "r 4" &gt;/dev/pigpio
+cat /dev/pigout
+ </pre>
+<h3><a name="make_fails" id="make_fails"></a>make fails with clock
+skew</h3>
+<p>If make fails with one of the following messages it is probably
+because the Pi's clock is wrong.<br></p>
+<p><code>make: Warning: File 'xxx' has modification time x s in the
+future<br>
+make: warning: Clock skew detected. Your build may be
+incomplete.</code></p>
+<p>make uses the current time to work out which files need to be
+rebuilt (a file is rebuilt if it depends on other files which have
+a later time-stamp).<br></p>
+<p>The solution is to make sure the system clock is correct.&nbsp;
+If the Pi is networked this will not normally be a problem.<br></p>
+<p>To set the date and time use the date command as in the
+following example.</p>
+<p><code>sudo date -d "2017-03-01 18:47:00"</code></p>
+<h3><a name="Porting_pigpio" id="Porting_pigpio"></a>Porting pigpio
+to another CPU/SoC</h3>
+<h3><a name="Sound_isnt_working" id="Sound_isnt_working"></a>Sound
+isn't working</h3>
+<p>The Pi contains two pieces of hardware, a PWM peripheral and a
+PCM peripheral, to generate sound.&nbsp; The PWM peripheral is
+normally used and generates medium quality audio out of the
+headphone jack.&nbsp; The PCM peripheral may be used by add-ons
+such as HATs and generates high quality audio.<br></p>
+<p>pigpio uses at least one of these peripherals during normal
+operation (for timing DMA transfers).&nbsp; pigpio will use both
+peripherals if waves or the hardware PWM function is used.<br></p>
+<p>By default pigpio uses the PCM peripheral leaving the PWM
+peripheral free for medium quality audio.<br></p>
+<p>You can change the default with a configuration option.&nbsp;
+For C use <a href="cif.html#gpioCfgClock">gpioCfgClock</a>, for the
+<a href="pigpiod.html">pigpio daemon</a> use the -t option.</p>
+<h3><a name="What_is_I2C" id="What_is_I2C"></a>What is I2C?</h3>
+<p>I2C is a data link between the Pi (master) and one or more
+slaves.</p>
+<p>Data may be sent and received but the Pi initiates all
+transfers.<br></p>
+<p>I2C is a medium speed link.&nbsp; On the Pi the default speed is
+100 kbps, but 400 kbps also works.<br></p>
+<p>I2C is implemented as a bus with two lines called<br></p>
+<ul>
+<li>SDA - for data</li>
+<li>SCL - for a clock</li>
+</ul>
+On the Pi bus 1 is used which uses GPIO 2 (pin 3) for SDA and GPIO
+3 (pin 5) for SCL.<br>
+<br>
+Only one slave device may be communicated with at a time.&nbsp;
+Each message from the Pi includes the slave to be addressed and
+whether a read or write is to be performed.<br>
+<br>
+When the Pi (master) wishes to talk to a slave it begins by issuing
+a start sequence on the I2C bus. A start sequence is one of two
+special sequences defined for the I2C bus, the other being the stop
+sequence. The start sequence and stop sequence are special in that
+these are the only places where the SDA (data line) is allowed to
+change while the SCL (clock line) is high. When data is being
+transferred, SDA must remain stable and not change whilst SCL is
+high. The start and stop sequences mark the beginning and end of a
+transaction with the slave device.<br>
+<br>
+<img style="width: 600px;" alt="I2C start and stop sequences" src=
+"images/faq-i2c-ss.png"><br>
+<br>
+Data is transferred in 8-bit bytes. The bytes are placed on the SDA
+line starting with the most significant bit. The SCL line is then
+pulsed high, then low. For every byte transferred, the device
+receiving the data sends back an acknowledge bit, so there are
+actually 9 SCL clock pulses to transfer each 8-bit byte of data. If
+the receiving device sends back a low ACK bit, then it has received
+the data and is ready to accept another byte. If it sends back a
+high then it is indicating it cannot accept any further data and
+the master should terminate the transfer by sending a stop
+sequence.<br>
+<br>
+<p><img style="width: 600px;" alt="I2C waveform" src=
+"images/faq-i2c.jpg"><br></p>
+<h3><a name="What_is_Serial" id="What_is_Serial"></a>What is
+Serial?</h3>
+<p>Serial is a data link between the Pi and one other
+device.<br></p>
+<p>Data may be sent and received.&nbsp; Either the Pi or the device
+can initiate a transfer.<br></p>
+<p>Serial is a low to medium speed link.&nbsp; On the Pi speeds of
+50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600,
+19200, 38400, 57600, 115200, and 230400 bps may be used.<br></p>
+<p>Serial is implemented with one line for transmit called TXD and
+one line for receive called RXD.<br></p>
+<p>If only receive or transmit are required the other line need not
+be connected.<br></p>
+<p>The Pi uses GPIO 14 (pin 8) for TXD and GPIO 15 (pin 10) for
+RXD.<br></p>
+<p>Data is normally transmitted in 8-bit bytes with a start bit,
+eight data bits, no parity, and one stop bit.&nbsp; This is
+represented as 8N1.&nbsp; The number of transmitted bits per second
+(bps) is called the baud rate.&nbsp;&nbsp; The time for each bit,
+<span style="font-style: italic;">1 / baud rate</span> seconds, is
+referred to as the bit period.<br></p>
+<p>The lines are in the high state when no data is being
+transmitted.&nbsp; The start of a byte is signalled by the line
+going low for one bit period (the start bit).&nbsp; The data bits
+are then sent least significant bit firsts (low if the bit is 0,
+high if the bit is 1).&nbsp; The data bits are followed by the
+optional parity bit.&nbsp; Finally the line is set high for at
+least the number of stop bit periods.&nbsp; The line will stay high
+if there are no more bytes to be transmitted.<br></p>
+<p><img style="width: 600px;" alt="Serial waveform" src=
+"images/faq-serial.jpg"><br></p>
+<h3><a name="What_is_SPI" id="What_is_SPI"></a>What is SPI?</h3>
+<p>SPI is a data link between the Pi (master) and one or more
+slaves.</p>
+<p>Data may be sent and received but the Pi initiates all
+transfers.<br></p>
+<p>SPI is a medium to high speed link.&nbsp; On the Pi speeds of 32
+kbps to 8 Mbps may be used.<br></p>
+<p>SPI is implemented as a bus with three lines called<br></p>
+<ul>
+<li>MOSI - for data from the Pi to the slave</li>
+<li>MISO - for data from the slave to the Pi</li>
+<li>SCLK - for a clock</li>
+</ul>
+Only one slave device may be communicated with at a time.&nbsp; An
+additional line per slave called slave select is used to identify
+the slave to be addressed.
+<p>The Pi has two SPI buses<br></p>
+<ol>
+<li>the main SPI bus
+<ul>
+<li>MOSI GPIO 10 (pin 19)</li>
+<li>MISO GPIO 9 (pin 21)</li>
+<li>SCLK GPIO 11 (pin 23)</li>
+<li>Slave selects</li>
+<li style="list-style: none; display: inline">
+<ul>
+<li>CE0 GPIO 8 (pin 24)</li>
+<li>CE1 GPIO 7 (pin 26)</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>the auxiliary SPI bus
+<ul>
+<li>MOSI GPIO 20 (pin 38)</li>
+<li>MISO GPIO 19 (pin 35)</li>
+<li>SCLK GPIO 21 (pin 40)</li>
+<li>Slave selects</li>
+<li style="list-style: none; display: inline">
+<ul>
+<li>CE0 GPIO 18 (pin 12)</li>
+<li>CE1 GPIO 17 (pin 11)</li>
+<li>CE2 GPIO 16 (pin 36)<br></li>
+</ul>
+</li>
+</ul>
+</li>
+</ol>
+<p><img style="width: 600px;" alt="SPI waveform" src=
+"images/faq-spi.jpg"><br></p>
+<p><br></p>
+<h3><a name="Which_library" id="Which_library"></a>Which library
+should I use?</h3>
+<p><br></p>
+</body>
+</html>
diff --git a/DOC/src/html/index.html b/DOC/src/html/index.html
new file mode 100644
index 0000000..0b8e33c
--- /dev/null
+++ b/DOC/src/html/index.html
@@ -0,0 +1,659 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="content-type">
+<title>pigpio</title>
+</head>
+<body>
+pigpio is a library for the Raspberry which allows control of the
+General Purpose Input Outputs (GPIO).&nbsp; pigpio works on all
+versions of the Pi.
+<p><a href="download.html">Download</a><br></p>
+<h3>Features<br></h3>
+<ul>
+<li>
+<p>hardware timed sampling and time-stamping of GPIO 0-31 every 5
+us<br></p>
+</li>
+<li>
+<p>hardware timed PWM on all of GPIO 0-31<br></p>
+</li>
+<li>
+<p>hardware timed servo pulses on all of GPIO 0-31</p>
+</li>
+<li>
+<p>callbacks on GPIO 0-31 level change (time accurate to a few
+us)</p>
+</li>
+<li>
+<p>notifications via pipe on GPIO 0-31 level change<br></p>
+</li>
+<li>
+<p>callbacks at timed intervals</p>
+</li>
+<li>
+<p>reading/writing all of the GPIO in a bank (0-31, 32-53) as a
+single operation</p>
+</li>
+<li>
+<p>GPIO reading, writing, modes, and internal pulls<br></p>
+</li>
+<li>
+<p>socket and pipe interfaces for the bulk of the functionality</p>
+</li>
+<li>
+<p>waveforms to generate GPIO level changes (time accurate to a few
+us)</p>
+</li>
+<li>
+<p>software serial links using any user GPIO</p>
+</li>
+<li>
+<p>rudimentary permission control through the socket and pipe
+interfaces<br></p>
+</li>
+<li>creating and running scripts on the pigpio daemon</li>
+</ul>
+<h3>General</h3>
+The pigpio <a href="cif.html">library</a> is written in the C
+programming language.<br>
+<br>
+The <a href="pigpiod.html">pigpio daemon</a> offers a <a href=
+"sif.html">socket</a> and <a href="pif.html">pipe</a> interface to
+the underlying C library.<br>
+<br>
+A <a href="pdif2.html">C library</a> and a <a href=
+"python.html">Python module</a> allow control of the GPIO via the
+pigpio daemon.<br>
+<br>
+There is third party support for a number of <a href=
+"index.html#Other_Languages">other languages</a>.&nbsp;
+<h3>piscope</h3>
+<p><a href="piscope.html">piscope</a> is a logic analyser (digital
+waveform viewer).<br></p>
+piscope is a GTK+3 application and uses pigpio to provide raw GPIO
+level data.&nbsp; piscope may be run on a Pi or on any machine
+capable of compiling a GTK+3 application.
+<h3><a name="GPIO" id="GPIO"></a>GPIO</h3>
+<p><span style="font-weight: bold;">ALL GPIO</span> are identified
+by their <span style="font-weight: bold;">Broadcom
+number</span>.&nbsp; See <a href=
+"http://elinux.org/RPi_Low-level_peripherals#General_Purpose_Input.2FOutput_.28GPIO.29">
+elinux.org</a><br></p>
+There are 54 GPIO in total, arranged in two banks.<br>
+<p>Bank 1 contains GPIO 0-31.&nbsp; Bank 2 contains GPIO
+32-53.<br></p>
+For all types of Pi it is safe to read all the GPIO. If you try to
+write a system GPIO or change its mode you can crash the Pi or
+corrupt the data on the SD card.<br>
+<br>
+There are several types of board, each with different expansion
+headers, giving physical access to different GPIO.&nbsp;
+<ul>
+<li><a href="#Type_1">Type 1</a> - Model B (original model)</li>
+<li><a href="#Type_2">Type 2</a> - Model A, B (revision 2)</li>
+<li><a href="#Type_3">Type 3</a> - Model A+, B+, Pi Zero, Pi2B,
+Pi3B</li>
+<li><a href="#CM">Compute Module</a> - Compute Module</li>
+</ul>
+<h4><a name="Type_1" id="Type_1"></a>Type 1 - Model B (original
+model)</h4>
+<ul>
+<li>26 pin header (P1).</li>
+</ul>
+<ul>
+<li>Hardware revision numbers of 2 and 3.</li>
+</ul>
+<ul>
+<li>User GPIO 0-1, 4, 7-11, 14-15, 17-18, 21-25.</li>
+</ul>
+<table summary="" style="width: 60%; text-align: left;"
+cellspacing="0" cellpadding="0" border="0">
+<tbody>
+<tr>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+<br></td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">3V3</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">1</td>
+<td style="text-align: center;">2</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">5V</td>
+</tr>
+<tr>
+<td style="text-align: center;">SDA</td>
+<td style="text-align: center;">0<br></td>
+<td style="text-align: center;">3</td>
+<td style="text-align: center;">4</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">5V</td>
+</tr>
+<tr>
+<td style="text-align: center;">SCL</td>
+<td style="text-align: center;">1<br></td>
+<td style="text-align: center;">5</td>
+<td style="text-align: center;">6</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">4</td>
+<td style="text-align: center;">7</td>
+<td style="text-align: center;">8</td>
+<td style="text-align: center;">14</td>
+<td style="text-align: center;">TXD</td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">9</td>
+<td style="text-align: center;">10</td>
+<td style="text-align: center;">15</td>
+<td style="text-align: center;">RXD</td>
+</tr>
+<tr>
+<td style="text-align: center;">ce1</td>
+<td style="text-align: center;">17</td>
+<td style="text-align: center;">11</td>
+<td style="text-align: center;">12</td>
+<td style="text-align: center;">18</td>
+<td style="text-align: center;">ce0</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">21</td>
+<td style="text-align: center;">13</td>
+<td style="text-align: center;">14</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">22</td>
+<td style="text-align: center;">15</td>
+<td style="text-align: center;">16</td>
+<td style="text-align: center;">23</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">3V3</td>
+<td style="text-align: center;">-<br></td>
+<td style="text-align: center;">17</td>
+<td style="text-align: center;">18</td>
+<td style="text-align: center;">24</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">MOSI</td>
+<td style="text-align: center;">10</td>
+<td style="text-align: center;">19</td>
+<td style="text-align: center;">20</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;">MISO</td>
+<td style="text-align: center;">9</td>
+<td style="text-align: center;">21</td>
+<td style="text-align: center;">22</td>
+<td style="text-align: center;">25</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">SCLK</td>
+<td style="text-align: center;">11</td>
+<td style="text-align: center;">23</td>
+<td style="text-align: center;">24</td>
+<td style="text-align: center;">8</td>
+<td style="text-align: center;">CE0</td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">25</td>
+<td style="text-align: center;">26</td>
+<td style="text-align: center;">7</td>
+<td style="text-align: center;">CE1</td>
+</tr>
+</tbody>
+</table>
+<br>
+<h4><a name="Type_2" id="Type_2"></a>Type 2 - Model A, B (revision
+2)</h4>
+26 pin header (P1) and an additional 8 pin header (P5).
+<ul>
+<li>Hardware revision numbers of 4, 5, 6 (B), 7, 8, 9 (A), and 13,
+14, 15 (B).</li>
+</ul>
+<ul>
+<li>User GPIO 2-4, 7-11, 14-15, 17-18, 22-25, 27-31.<br></li>
+</ul>
+<table summary="" style="width: 60%; text-align: left;"
+cellspacing="0" cellpadding="0" border="0">
+<tbody>
+<tr>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+<br></td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">3V3</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">1</td>
+<td style="text-align: center;">2</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">5V</td>
+</tr>
+<tr>
+<td style="text-align: center;">SDA</td>
+<td style="text-align: center;">2</td>
+<td style="text-align: center;">3</td>
+<td style="text-align: center;">4</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">5V</td>
+</tr>
+<tr>
+<td style="text-align: center;">SCL</td>
+<td style="text-align: center;">3</td>
+<td style="text-align: center;">5</td>
+<td style="text-align: center;">6</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">4</td>
+<td style="text-align: center;">7</td>
+<td style="text-align: center;">8</td>
+<td style="text-align: center;">14</td>
+<td style="text-align: center;">TXD</td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">9</td>
+<td style="text-align: center;">10</td>
+<td style="text-align: center;">15</td>
+<td style="text-align: center;">RXD</td>
+</tr>
+<tr>
+<td style="text-align: center;">ce1</td>
+<td style="text-align: center;">17</td>
+<td style="text-align: center;">11</td>
+<td style="text-align: center;">12</td>
+<td style="text-align: center;">18</td>
+<td style="text-align: center;">ce0</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">27</td>
+<td style="text-align: center;">13</td>
+<td style="text-align: center;">14</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">22</td>
+<td style="text-align: center;">15</td>
+<td style="text-align: center;">16</td>
+<td style="text-align: center;">23</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">3V3</td>
+<td style="text-align: center;">-<br></td>
+<td style="text-align: center;">17</td>
+<td style="text-align: center;">18</td>
+<td style="text-align: center;">24</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">MOSI</td>
+<td style="text-align: center;">10</td>
+<td style="text-align: center;">19</td>
+<td style="text-align: center;">20</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;">MISO</td>
+<td style="text-align: center;">9</td>
+<td style="text-align: center;">21</td>
+<td style="text-align: center;">22</td>
+<td style="text-align: center;">25</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">SCLK</td>
+<td style="text-align: center;">11</td>
+<td style="text-align: center;">23</td>
+<td style="text-align: center;">24</td>
+<td style="text-align: center;">8</td>
+<td style="text-align: center;">CE0</td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">25</td>
+<td style="text-align: center;">26</td>
+<td style="text-align: center;">7</td>
+<td style="text-align: center;">CE1</td>
+</tr>
+</tbody>
+</table>
+<br>
+<table summary="" style="width: 60%; text-align: left;"
+cellspacing="0" cellpadding="0" border="0">
+<tbody>
+<tr>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+<br></td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">5V<br></td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">1</td>
+<td style="text-align: center;">2</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">3V3</td>
+</tr>
+<tr>
+<td style="text-align: center;">SDA<br></td>
+<td style="text-align: center;">28</td>
+<td style="text-align: center;">3</td>
+<td style="text-align: center;">4</td>
+<td style="text-align: center;">29</td>
+<td style="text-align: center;">SCL</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">30</td>
+<td style="text-align: center;">5</td>
+<td style="text-align: center;">6</td>
+<td style="text-align: center;">31</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground<br></td>
+<td style="text-align: center;">-<br></td>
+<td style="text-align: center;">7</td>
+<td style="text-align: center;">8</td>
+<td style="text-align: center;">-<br></td>
+<td style="text-align: center;">Ground</td>
+</tr>
+</tbody>
+</table>
+<br>
+<h4><a name="Type_3" id="Type_3"></a>Type 3 - Model A+, B+, Pi
+Zero, Pi Zero W, Pi2B, Pi3B, Pi4B<br></h4>
+<ul>
+<li>40 pin expansion header (J8).</li>
+</ul>
+<ul>
+<li>Hardware revision numbers of 16 or greater.</li>
+</ul>
+<ul>
+<li>User GPIO 2-27 (0 and 1 are reserved).<br></li>
+</ul>
+<table summary="" style="width: 60%; text-align: left;"
+cellspacing="0" cellpadding="0" border="0">
+<tbody>
+<tr>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+<br></td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">3V3</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">1</td>
+<td style="text-align: center;">2</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">5V</td>
+</tr>
+<tr>
+<td style="text-align: center;">SDA</td>
+<td style="text-align: center;">2</td>
+<td style="text-align: center;">3</td>
+<td style="text-align: center;">4</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">5V</td>
+</tr>
+<tr>
+<td style="text-align: center;">SCL</td>
+<td style="text-align: center;">3</td>
+<td style="text-align: center;">5</td>
+<td style="text-align: center;">6</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">4</td>
+<td style="text-align: center;">7</td>
+<td style="text-align: center;">8</td>
+<td style="text-align: center;">14</td>
+<td style="text-align: center;">TXD</td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">9</td>
+<td style="text-align: center;">10</td>
+<td style="text-align: center;">15</td>
+<td style="text-align: center;">RXD</td>
+</tr>
+<tr>
+<td style="text-align: center;">ce1</td>
+<td style="text-align: center;">17</td>
+<td style="text-align: center;">11</td>
+<td style="text-align: center;">12</td>
+<td style="text-align: center;">18</td>
+<td style="text-align: center;">ce0</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">27</td>
+<td style="text-align: center;">13</td>
+<td style="text-align: center;">14</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">22</td>
+<td style="text-align: center;">15</td>
+<td style="text-align: center;">16</td>
+<td style="text-align: center;">23</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">3V3</td>
+<td style="text-align: center;">-<br></td>
+<td style="text-align: center;">17</td>
+<td style="text-align: center;">18</td>
+<td style="text-align: center;">24</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">MOSI</td>
+<td style="text-align: center;">10</td>
+<td style="text-align: center;">19</td>
+<td style="text-align: center;">20</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;">MISO</td>
+<td style="text-align: center;">9</td>
+<td style="text-align: center;">21</td>
+<td style="text-align: center;">22</td>
+<td style="text-align: center;">25</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">SCLK</td>
+<td style="text-align: center;">11</td>
+<td style="text-align: center;">23</td>
+<td style="text-align: center;">24</td>
+<td style="text-align: center;">8</td>
+<td style="text-align: center;">CE0</td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">25</td>
+<td style="text-align: center;">26</td>
+<td style="text-align: center;">7</td>
+<td style="text-align: center;">CE1</td>
+</tr>
+<tr>
+<td style="text-align: center;">ID_SD</td>
+<td style="text-align: center;">0</td>
+<td style="text-align: center;">27</td>
+<td style="text-align: center;">28</td>
+<td style="text-align: center;">1</td>
+<td style="text-align: center;">ID_SC</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">5</td>
+<td style="text-align: center;">29</td>
+<td style="text-align: center;">30</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">6</td>
+<td style="text-align: center;">31</td>
+<td style="text-align: center;">32</td>
+<td style="text-align: center;">12</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">13</td>
+<td style="text-align: center;">33</td>
+<td style="text-align: center;">34</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;">miso</td>
+<td style="text-align: center;">19</td>
+<td style="text-align: center;">35</td>
+<td style="text-align: center;">36</td>
+<td style="text-align: center;">16</td>
+<td style="text-align: center;">ce2</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">26</td>
+<td style="text-align: center;">37</td>
+<td style="text-align: center;">38</td>
+<td style="text-align: center;">20</td>
+<td style="text-align: center;">mosi</td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">39</td>
+<td style="text-align: center;">40</td>
+<td style="text-align: center;">21</td>
+<td style="text-align: center;">sclk</td>
+</tr>
+</tbody>
+</table>
+<br>
+<h4><a name="CM" id="CM"></a>Compute Module</h4>
+<p>All 54 GPIO may be physically accessed.&nbsp; Some are reserved
+for system use - refer to the Compute Module documentation.<br></p>
+<p>Only GPIO 0-31 are supported for hardware timed sampling, PWM,
+servo pulses, alert callbacks, waves, and software serial
+links.<br></p>
+<h3><a name="Other_Languages" id="Other_Languages"></a>Other
+Languages</h3>
+<p>There are several third party projects which provide wrappers
+for pigpio.<br></p>
+<p>Some are listed here:<br></p>
+<ul>
+<li><a href="https://github.com/skvamme/pigpio">Erlang</a>
+(skvamme)</li>
+<li><a href="https://github.com/mattjlewis/pigpioj">Java</a> JNI
+wrapper around the pigpio C library (mattlewis)</li>
+<li><a href="https://github.com/mattjlewis/diozero">Java</a> via
+diozero, a high level wrapper around pigpio, Pi4J, wiringPi etc
+(mattlewis)</li>
+<li><a href="https://github.com/nkolban/jpigpio">Java</a>
+(nkolban)</li>
+<li><a href=
+"https://github.com/unosquare/pigpio-dotnet">.NET/mono</a>
+(unosquare)</li>
+<li><a href="https://github.com/fivdi/pigpio">Node.js</a>
+A wrapper for the pigpio C library (fivdi)</li>
+<li><a href="https://github.com/guymcswain/pigpio-client">Node.js</a>
+A client for pigpio socket interface (guymcswain)</li>
+<li><a href="https://metacpan.org/pod/RPi::PIGPIO">Perl</a> (Gligan
+Calin Horea)</li>
+<li><a href=
+"https://github.com/nak1114/ruby-extension-pigpio">Ruby</a>
+(Nak)</li>
+<li><a href=
+"https://github.com/vasmalltalk/pigpio-vast">Smalltalk</a>(Instantiations)</li>
+<li><a href=
+"https://github.com/UBogun/Xojo-pigpio">Xojo</a>(UBogun)</li>
+<li><a href=
+"https://github.com/eugenedakin/pigpio-GPIO">Xojo</a>(Eugene Dakin)</li>
+</ul>
+<hr style="width: 100%; height: 2px;">
+<p><font size="-2">The PWM and servo pulses are timed using the DMA
+and PWM/PCM peripherals.&nbsp; This use was inspired by Richard
+Hirst's <a href="https://github.com/richardghirst/PiBits" target=
+"_blank">servoblaster</a> kernel module.</font></p>
+</body>
+</html>
diff --git a/DOC/src/html/misc.html b/DOC/src/html/misc.html
new file mode 100644
index 0000000..4c6f305
--- /dev/null
+++ b/DOC/src/html/misc.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>Miscellaneous</title>
+</head>
+<body>
+There are two C libraries which provide a socket interface to the
+pigpio daemon.&nbsp; They provide an interface very similar to the
+pigpio Python module.<br>
+<ul>
+<li>The original <a href="./pdif.html">pigpiod_if</a> library is
+now deprecated and will no longer be updated.&nbsp; This library is
+limited to controlling one Pi at a time.</li>
+</ul>
+<ul>
+<li>The new <a href="./pdif2.html">pigpiod_if2</a> library which
+should be used for new code.&nbsp; This library allows multiple Pis
+to be controlled at one time.</li>
+</ul>
+Additional details of the pigpio <a href="./sif.html">socket</a>
+interface.<br>
+<br>
+Additional details of the pigpio <a href="./pif.html">pipe</a>
+interface.<br>
+<br>
+<a href="pig2vcd.html">pig2vcd</a> is a utility which converts
+pigpio notifications into the VCD (Value Change Dump) format.&nbsp;
+VCD can be read by many programs, in particular <a href=
+"http://gtkwave.sourceforge.net/">GTKWave</a>.
+</body>
+</html>
diff --git a/DOC/src/html/pif.html b/DOC/src/html/pif.html
new file mode 100644
index 0000000..bc924ff
--- /dev/null
+++ b/DOC/src/html/pif.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>Pipe interface</title>
+</head>
+<body>
+pigpio provides a pipe interface to many of its functions.<br>
+<br>
+The pipe interface is available whenever pigpio is running, either
+because it has been started as a daemon, or it has been linked in
+to a running user program.&nbsp; The pipe interface can be disabled
+by the program which initialises the library.&nbsp; pigpiod offers
+the -f option to disable the pipe interface.&nbsp; User programs
+should call <a href=
+"http://abyz.me.uk/rpi/pigpio/cif.html#gpioCfgInterfaces">gpioCfgInterfaces</a>
+if they wish to disable the pipe interface.<br>
+<br>
+pigpio listens for commands on pipe /dev/pigpio.&nbsp; The commands
+consist of a command identifier with, depending on the command,
+zero, one, or two parameters.&nbsp; The result, if any, may be read
+from pipe /dev/pigout.&nbsp; If any errors are detected a message
+will be written to pipe /dev/pigerr.<br>
+<br>
+<br>
+The format of the commands is identical to those used by <a href=
+"pigs.html">pigs</a>.
+</body>
+</html>
diff --git a/DOC/src/html/piscope.html b/DOC/src/html/piscope.html
new file mode 100644
index 0000000..c381057
--- /dev/null
+++ b/DOC/src/html/piscope.html
@@ -0,0 +1,216 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta name="generator" content=
+"HTML Tidy for HTML5 for Linux version 5.6.0">
+<meta content="text/html; charset=utf-8" http-equiv="content-type">
+<title>piscope</title>
+</head>
+<body>
+<h2>Introduction<br></h2>
+<a href="piscope.tar">piscope</a> is a logic analyser (digital
+waveform viewer) for the Raspberry.&nbsp; It shows the state (high
+or low) of selected GPIO in real-time.<br>
+<br>
+See <a href="http://youtu.be/2apqOiLHEzs">video</a>.<br>
+<br>
+piscope uses the services of the pigpio <a href=
+"download.html">library</a>.&nbsp; pigpio needs to be running on
+the Pi whose GPIO are to be monitored.<br>
+<br>
+The pigpio library may be started as a daemon (background process)
+by the following command.<br>
+<br>
+<code>sudo pigpiod<br></code><br>
+piscope may be invoked in several different ways<br>
+<br>
+<table summary="" style=
+"text-align: left; width: 90%; height: 246px;" cellspacing="2"
+cellpadding="2" border="1">
+<tbody>
+<tr>
+<td style="width: 15%;"><small>Pi<br></small></td>
+<td style="vertical-align: top; width: 55%;"><small><span style=
+"font-style: italic;">pi_host</span> ~ $ piscope
+&amp;<br></small></td>
+<td style="vertical-align: top; width: 30%;"><small>Pi captures
+data<br>
+Pi processes data<br>
+Pi displays data<br></small></td>
+</tr>
+<tr>
+<td style="vertical-align: top;"><small>Pi plus Linux PC<br>
+<br>
+(with the<br>
+display on a remote<br>
+&nbsp; Linux PC)<br></small></td>
+<td style="vertical-align: top;"><small><span style=
+"font-style: italic;">remote_host</span> ~ $ ssh -X <span style=
+"font-style: italic;">pi_host</span><br></small><small><span style=
+"font-style: italic;">pi_host</span> ~ $ piscope
+&amp;</small><small><br></small></td>
+<td style="vertical-align: top;"><small>Pi captures data<br>
+Pi processes data<br>
+Remote Linux PC displays data<br></small></td>
+</tr>
+<tr>
+<td style="vertical-align: top;"><small>Pi plus Windows PC<br>
+<br>
+(with the<br>
+display on a remote<br>
+&nbsp; Windows PC)</small></td>
+<td style="vertical-align: top;"><small>You need to install an SSH
+client (putty suggested) and a X11 server (xming suggested).<br>
+<br>
+Run Program Files -&gt; Xming -&gt; XLaunch and accept the
+defaults.<br>
+<br>
+Run putty and enter the Pi's host name or IP address.&nbsp; Click
+on SSH X11 and tick Enable X11 forwarding and then select
+Open.</small><br>
+<small><br></small> <small><span style=
+"font-style: italic;">pi_host</span> ~ $ piscope
+&amp;</small><br></td>
+<td style="vertical-align: top;"><small>Pi captures data<br>
+Pi processes data<br>
+Remote Windows PC displays data</small></td>
+</tr>
+<tr>
+<td style="vertical-align: top;"><small>Pi plus Linux PC<br>
+<br>
+(with the display and processing on a remote Linux
+PC)<br></small></td>
+<td style="vertical-align: top;"><small><span style=
+"font-style: italic;">remote_host</span> ~ $ export
+PIGPIO_ADDR=<span style="font-style: italic;">pi_host</span><br>
+<span style="font-style: italic;">remote_host</span> ~ $ piscope
+&amp;<br></small></td>
+<td style="vertical-align: top;"><small>Pi captures data<br>
+Remote processes data<br>
+Remote displays data<br></small></td>
+</tr>
+</tbody>
+</table>
+<br>
+piscope operates in one of three modes<br>
+<br>
+<table summary="" style="text-align: left; width: 90%;"
+cellspacing="2" cellpadding="2" border="1">
+<tbody>
+<tr>
+<td style="vertical-align: top;">Live<br></td>
+<td style="vertical-align: top;">The latest GPIO samples are
+displayed.<br>
+<br>
+The mode will automatically change to Pause if a sampling trigger
+is detected.<br>
+<br>
+There are four triggers.&nbsp; Each trigger is made up of a
+combination of GPIO states (one of don't care, low, high, edge,
+falling, or rising per GPIO).&nbsp; Triggers are always
+counted.&nbsp; In addition a trigger may be sample to, sample
+around, or sample from, a so called sampling trigger.<br></td>
+<td style="vertical-align: top;">New samples are added to the
+sample buffer.<br>
+<br>
+Once the sample buffer is full the <span style=
+"font-weight: bold;">oldest</span> samples are discarded.</td>
+</tr>
+<tr>
+<td style="vertical-align: top;">Play<br></td>
+<td style="vertical-align: top;">Recorded GPIO samples are
+displayed.<br>
+<br>
+The play speed may be varied between 64 times real-time to 1/32768
+of real-time.<br>
+<br>
+The page up key increases the play speed by a factor of 2.&nbsp;
+The page down key decreases the play speed by a factor of 2.&nbsp;
+The home key sets the play speed to 1X.<br></td>
+<td style="vertical-align: top;">New samples are added to the
+sample buffer.<br>
+<br>
+Once the sample buffer is full <span style=
+"font-weight: bold;">new</span> samples are discarded.</td>
+</tr>
+<tr>
+<td style="vertical-align: top;">Pause<br></td>
+<td style="vertical-align: top;">Recorded GPIO samples are
+displayed.<br>
+<br>
+The left and right cursor keys move the blue marker to the previous
+or next edge.&nbsp; By default all GPIO edges are considered.&nbsp;
+Clicking on a GPIO name will limit edge searches to the highlighted
+GPIO only.<br>
+<br>
+The left and right square bracket keys move the blue marker to the
+previous or next trigger.<br>
+<br>
+The time between the blue and gold markers is displayed.&nbsp; The
+gold marker is set to the blue marker by a press of the 'g'
+key.<br></td>
+<td style="vertical-align: top;">New samples are added to the
+sample buffer.<br>
+<br>
+Once the sample buffer is full <span style=
+"font-weight: bold;">new</span> samples are discarded.</td>
+</tr>
+</tbody>
+</table>
+<br>
+In all modes the down and up cursor keys zoom the time scale in and
+out.<br>
+<br>
+Samples can be saved with File Save All Samples or File Save
+Selected Samples.
+<p>To select samples enter pause mode. Press 1 to specify the start
+of the samples (green marker) and 2 to specify the end of the
+samples (red marker).</p>
+<p>The samples may be saved in the native piscope format or in VCD
+format.</p>
+<p>Data saved in VCD format may be viewed and further processed
+with GTKWave.</p>
+<p>Data saved in the native piscope format may be restored later
+with File Restore Saved Data.</p>
+<h2>Installation</h2>
+<p>To download and install piscope.</p>
+<h3>Pi (pre-built image)</h3>
+<code>wget abyz.me.uk/rpi/pigpio/piscope.tar<br>
+tar xvf piscope.tar<br>
+cd PISCOPE<br>
+make hf<br>
+make install</code><span style="font-weight: bold;"><br></span>
+<h3>Linux 64 bit X86/AMD (pre-built image)</h3>
+<code>wget abyz.me.uk/rpi/pigpio/piscope.tar<br>
+tar xvf piscope.tar<br>
+cd PISCOPE<br>
+make x86_64<br>
+make install<br></code>
+<h3>All machines (building from source)</h3>
+You only need to perform this step if you want to build the
+executable from the source files.&nbsp; This is not needed if you
+use a pre-built image.<br>
+<span style="font-weight: bold;"><br>
+WARNING</span>: Installing gtk+-3.0 uses a lot of SD card
+space.<br>
+<br>
+Most of the space used by gtk+-3.0 is taken up by unneeded *-dbg
+packages.<br>
+<br>
+With *-dbg packages an additional 3753MB SD space is required.<br>
+<br>
+If you edit the list of packages to be downloaded and remove the
+*-dbg packages only 134MB of additional SD space is needed (as at
+the time of writing).<br>
+<br>
+<code>#<br></code> <code># *** This may take a lot of time and use
+a lot of SD card space ***<br></code> <code>#<br>
+sudo apt-get install gtk+-3.0<br></code> <code>#<br></code>
+<code>wget abyz.me.uk/rpi/pigpio/piscope.tar<br>
+tar xvf piscope.tar<br>
+cd PISCOPE<br>
+make<br>
+make install<br></code><br>
+</body>
+</html>
diff --git a/DOC/src/html/sif.html b/DOC/src/html/sif.html
new file mode 100644
index 0000000..67b880b
--- /dev/null
+++ b/DOC/src/html/sif.html
@@ -0,0 +1,2004 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="content-type">
+<title>Socket interface</title>
+</head>
+<body>
+pigpio provides a socket interface to many of its functions.<br>
+<br>
+The socket interface is available whenever pigpio is running,
+either because it has been started as a daemon, or it has been
+linked in to a running user program.<br>
+<br>
+The socket interface can be disabled by the program which
+initialises the library.&nbsp; pigpiod offers the -k option to
+disable the socket interface.&nbsp; User programs should call
+<a href="cif.html#gpioCfgInterfaces">gpioCfgInterfaces</a> if they
+wish to disable the socket interface.<br>
+<br>
+pigpio listens for connections on port 8888 by default.&nbsp; This
+default may be overridden when pigpio starts by the <a href=
+"cif.html#gpioCfgSocketPort">gpioCfgSocketPort</a> function
+call.&nbsp; The pigpio daemon uses this function to provide an
+option to change the port number.<br>
+<br>
+The pigs utility is an example of using the socket interface from
+C.<span style="font-weight: bold;"><br></span>
+<h3><a name="Request" id="Request"></a>Request</h3>
+<p>pigpio expects messages of type <a href=
+"sif.html#cmdCmd_t">cmdCmd_t</a> immediately followed with an
+extension for a few commands.<br>
+<br>
+The caller should fill in cmd, p1, p2, p3/res, and any extension as
+needed.&nbsp; p3 will always be zero unless the command requires an
+extension in which case p3 will be the length in bytes of the
+extension.<br>
+<br>
+The <a href="sif.html#cmdCmd_t">cmdCmd_t</a> is echoed back with
+the result, if any, in p3/res, and an extension immediately
+afterwards for a few commands.<br></p>
+<table summary="" style="width: 80%;" cellspacing="2" cellpadding=
+"2" border="1">
+<tbody>
+<tr>
+<td style="font-weight: bold;">COMMAND</td>
+<td style="font-weight: bold;">cmd<br></td>
+<td style="font-weight: bold;">p1</td>
+<td style="font-weight: bold;">p2</td>
+<td style="font-weight: bold;">p3</td>
+<td style="font-weight: bold;">Extension<br></td>
+</tr>
+<tr>
+<td>MODES</td>
+<td>0</td>
+<td>gpio</td>
+<td>mode</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>MODEG</td>
+<td>1</td>
+<td>gpio</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PUD</td>
+<td>2</td>
+<td>gpio</td>
+<td>pud</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>READ</td>
+<td>3</td>
+<td>gpio</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WRITE</td>
+<td>4</td>
+<td>gpio</td>
+<td>level</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PWM</td>
+<td>5</td>
+<td>gpio</td>
+<td>dutycycle</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PRS</td>
+<td>6</td>
+<td>gpio</td>
+<td>range</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PFS</td>
+<td>7</td>
+<td>gpio</td>
+<td>frequency</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERVO</td>
+<td>8</td>
+<td>gpio</td>
+<td>pulsewidth</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WDOG</td>
+<td>9</td>
+<td>gpio</td>
+<td>timeout</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BR1</td>
+<td>10</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BR2</td>
+<td>11</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BC1</td>
+<td>12</td>
+<td>bits</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BC2</td>
+<td>13</td>
+<td>bits</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BS1</td>
+<td>14</td>
+<td>bits</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BS2</td>
+<td>15</td>
+<td>bits</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>TICK</td>
+<td>16</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>HWVER</td>
+<td>17</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NO</td>
+<td>18</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NB</td>
+<td>19</td>
+<td>handle</td>
+<td>bits</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NP</td>
+<td>20</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NC</td>
+<td>21</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PRG</td>
+<td>22</td>
+<td>gpio</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PFG</td>
+<td>23</td>
+<td>gpio</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PRRG</td>
+<td>24</td>
+<td>gpio</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>HELP<br></td>
+<td>25</td>
+<td>N/A<br></td>
+<td>N/A<br></td>
+<td>N/A<br></td>
+<td>N/A<br></td>
+</tr>
+<tr>
+<td>PIGPV</td>
+<td>26</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVCLR</td>
+<td>27</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVAG</td>
+<td>28</td>
+<td>0</td>
+<td>0</td>
+<td>12*X</td>
+<td>gpioPulse_t pulse[X]</td>
+</tr>
+<tr>
+<td>WVAS</td>
+<td>29</td>
+<td>gpio</td>
+<td>baud</td>
+<td>12+X</td>
+<td>uint32_t databits<br>
+uint32_t stophalfbits<br>
+uint32_t offset<br>
+uint8_t data[X]</td>
+</tr>
+<tr>
+<td>N/A<br></td>
+<td>30</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>N/A<br></td>
+<td>31</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVBSY</td>
+<td>32</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVHLT</td>
+<td>33</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVSM</td>
+<td>34</td>
+<td>subcmd</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVSP</td>
+<td>35</td>
+<td>subcmd</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVSC</td>
+<td>36</td>
+<td>subcmd</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>TRIG</td>
+<td>37</td>
+<td>gpio</td>
+<td>pulselen</td>
+<td>4</td>
+<td>uint32_t level</td>
+</tr>
+<tr>
+<td>PROC</td>
+<td>38</td>
+<td>0</td>
+<td>0</td>
+<td>X</td>
+<td>uint8_t text[X]</td>
+</tr>
+<tr>
+<td>PROCD</td>
+<td>39</td>
+<td>script_id</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PROCR</td>
+<td>40</td>
+<td>script_id</td>
+<td>0</td>
+<td>4*X<br></td>
+<td>uint32_t pars[X]<br></td>
+</tr>
+<tr>
+<td>PROCS</td>
+<td>41</td>
+<td>script_id</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SLRO</td>
+<td>42</td>
+<td>gpio</td>
+<td>baud</td>
+<td>4</td>
+<td>uint32_t databits<br></td>
+</tr>
+<tr>
+<td>SLR</td>
+<td>43</td>
+<td>gpio</td>
+<td>count</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SLRC</td>
+<td>44</td>
+<td>gpio</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PROCP</td>
+<td>45</td>
+<td>script_id</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>MICS</td>
+<td>46</td>
+<td>micros</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>MILS</td>
+<td>47</td>
+<td>millis</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PARSE</td>
+<td>48</td>
+<td>N/A</td>
+<td>N/A<br></td>
+<td>N/A<br></td>
+<td>N/A</td>
+</tr>
+<tr>
+<td>WVCRE</td>
+<td>49</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVDEL</td>
+<td>50</td>
+<td>wave_id</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVTX</td>
+<td>51</td>
+<td>wave_id</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVTXR</td>
+<td>52</td>
+<td>wave_id</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVNEW</td>
+<td>53</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CO</td>
+<td>54</td>
+<td>bus</td>
+<td>device</td>
+<td>4</td>
+<td>uint32_t flags</td>
+</tr>
+<tr>
+<td>I2CC</td>
+<td>55</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRD</td>
+<td>56</td>
+<td>handle</td>
+<td>count</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWD</td>
+<td>57</td>
+<td>handle</td>
+<td>0</td>
+<td>X</td>
+<td>uint8_t data[X]</td>
+</tr>
+<tr>
+<td>I2CWQ</td>
+<td>58</td>
+<td>handle</td>
+<td>bit</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRS</td>
+<td>59</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWS</td>
+<td>60</td>
+<td>handle</td>
+<td>byte</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRB</td>
+<td>61</td>
+<td>handle</td>
+<td>register</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWB</td>
+<td>62</td>
+<td>handle</td>
+<td>register</td>
+<td>4</td>
+<td>uint32_t byte</td>
+</tr>
+<tr>
+<td>I2CRW</td>
+<td>63</td>
+<td>handle</td>
+<td>register</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWW</td>
+<td>64</td>
+<td>handle</td>
+<td>register</td>
+<td>4</td>
+<td>uint32_t word</td>
+</tr>
+<tr>
+<td>I2CRK</td>
+<td>65</td>
+<td>handle</td>
+<td>register<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWK</td>
+<td>66</td>
+<td>handle</td>
+<td>register<br></td>
+<td>X</td>
+<td>uint8_t bvs[X]<br></td>
+</tr>
+<tr>
+<td>I2CRI</td>
+<td>67</td>
+<td>handle</td>
+<td>register<br></td>
+<td>4</td>
+<td>uint32_t num<br></td>
+</tr>
+<tr>
+<td>I2CWI</td>
+<td>68</td>
+<td>handle</td>
+<td>register<br></td>
+<td>X<br></td>
+<td>uint8_t bvs[X]<br></td>
+</tr>
+<tr>
+<td>I2CPC</td>
+<td>69</td>
+<td>handle</td>
+<td>register<br></td>
+<td>4</td>
+<td>uint32_t word<br></td>
+</tr>
+<tr>
+<td>I2CPK</td>
+<td>70</td>
+<td>handle</td>
+<td>register<br></td>
+<td>X<br></td>
+<td>uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td>SPIO<br></td>
+<td>71</td>
+<td>channel</td>
+<td>baud</td>
+<td>4</td>
+<td>uint32_t flags</td>
+</tr>
+<tr>
+<td>SPIC</td>
+<td>72</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SPIR</td>
+<td>73</td>
+<td>handle</td>
+<td>count</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SPIW</td>
+<td>74</td>
+<td>handle</td>
+<td>0</td>
+<td>X</td>
+<td>uint8_t data[X]</td>
+</tr>
+<tr>
+<td>SPIX</td>
+<td>75</td>
+<td>handle</td>
+<td>0</td>
+<td>X</td>
+<td>uint8_t data[X]</td>
+</tr>
+<tr>
+<td>SERO</td>
+<td>76</td>
+<td>baud</td>
+<td>flags</td>
+<td>X</td>
+<td>uint8_t device[X]</td>
+</tr>
+<tr>
+<td>SERC</td>
+<td>77</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERRB</td>
+<td>78</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERWB</td>
+<td>79</td>
+<td>handle</td>
+<td>byte</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERR</td>
+<td>80</td>
+<td>handle</td>
+<td>count</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERW</td>
+<td>81</td>
+<td>handle</td>
+<td>0</td>
+<td>X</td>
+<td>uint8_t data[X]</td>
+</tr>
+<tr>
+<td>SERDA</td>
+<td>82</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">GDC<br></td>
+<td style="vertical-align: top;">83<br></td>
+<td style="vertical-align: top;">gpio<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">GPW<br></td>
+<td style="vertical-align: top;">84<br></td>
+<td style="vertical-align: top;">gpio<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">HC<br></td>
+<td style="vertical-align: top;">85<br></td>
+<td style="vertical-align: top;">gpio<br></td>
+<td style="vertical-align: top;">frequency<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">HP<br></td>
+<td style="vertical-align: top;">86<br></td>
+<td style="vertical-align: top;">gpio<br></td>
+<td style="vertical-align: top;">frequency<br></td>
+<td style="vertical-align: top;">4<br></td>
+<td style="vertical-align: top;">uint32_t dutycycle<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CF1<br></td>
+<td style="vertical-align: top;">87<br></td>
+<td style="vertical-align: top;">arg1<br></td>
+<td style="vertical-align: top;">arg2<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t argx[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CF2<br></td>
+<td style="vertical-align: top;">88<br></td>
+<td style="vertical-align: top;">arg1<br></td>
+<td style="vertical-align: top;">retMax<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t argx[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BI2CC<br></td>
+<td style="vertical-align: top;">89<br></td>
+<td style="vertical-align: top;">sda<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BI2CO<br></td>
+<td style="vertical-align: top;">90<br></td>
+<td style="vertical-align: top;">sda<br></td>
+<td style="vertical-align: top;">scl<br></td>
+<td style="vertical-align: top;">4<br></td>
+<td style="vertical-align: top;">uint32_t baud<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BI2CZ<br></td>
+<td style="vertical-align: top;">91<br></td>
+<td style="vertical-align: top;">sda<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">I2CZ<br></td>
+<td style="vertical-align: top;">92<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">WVCHA<br></td>
+<td style="vertical-align: top;">93<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">SLRI<br></td>
+<td style="vertical-align: top;">94<br></td>
+<td style="vertical-align: top;">gpio<br></td>
+<td style="vertical-align: top;">invert<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CGI<br></td>
+<td style="vertical-align: top;">95<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CSI<br></td>
+<td style="vertical-align: top;">96<br></td>
+<td style="vertical-align: top;">config<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FG<br></td>
+<td style="vertical-align: top;">97<br></td>
+<td style="vertical-align: top;">gpio<br></td>
+<td style="vertical-align: top;">steady<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FN<br></td>
+<td style="vertical-align: top;">98<br></td>
+<td style="vertical-align: top;">gpio<br></td>
+<td style="vertical-align: top;">steady<br></td>
+<td style="vertical-align: top;">4<br></td>
+<td style="vertical-align: top;">uint32_t active<br></td>
+</tr>
+<tr>
+<td>NOIB</td>
+<td>99</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">WVTXM<br></td>
+<td style="vertical-align: top;">100<br></td>
+<td style="vertical-align: top;">wave_id<br></td>
+<td style="vertical-align: top;">mode<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">WVTAT<br></td>
+<td style="vertical-align: top;">101<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">PADS<br></td>
+<td style="vertical-align: top;">102<br></td>
+<td style="vertical-align: top;">pad<br></td>
+<td style="vertical-align: top;">strength<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">PADG<br></td>
+<td style="vertical-align: top;">103<br></td>
+<td style="vertical-align: top;">pad<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FO<br></td>
+<td style="vertical-align: top;">104<br></td>
+<td style="vertical-align: top;">mode<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t file[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FC<br></td>
+<td style="vertical-align: top;">105<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FR<br></td>
+<td style="vertical-align: top;">106<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">count<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FW<br></td>
+<td style="vertical-align: top;">107<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FS<br></td>
+<td style="vertical-align: top;">108<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">offset<br></td>
+<td style="vertical-align: top;">4<br></td>
+<td style="vertical-align: top;">uint32_t from<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FL<br></td>
+<td style="vertical-align: top;">109<br></td>
+<td style="vertical-align: top;">count<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t pattern[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">SHELL<br></td>
+<td style="vertical-align: top;">110<br></td>
+<td style="vertical-align: top;">len(name)<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">len(name)+<br>
+1+<br>
+len(string)<br></td>
+<td style="vertical-align: top;">uint8_t name[len(name)]<br>
+uint8_t null (0)<br>
+uint8_t string[len(string)]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSPIC<br></td>
+<td style="vertical-align: top;">111<br></td>
+<td style="vertical-align: top;">CS<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSPIO<br></td>
+<td style="vertical-align: top;">112<br></td>
+<td style="vertical-align: top;">CS<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">20<br></td>
+<td style="vertical-align: top;">uint32_t MISO<br>
+uint32_t MOSI<br>
+uint32_t SCLK<br>
+uint32_t baud<br>
+uint32_t spi_flags<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSPIX<br></td>
+<td style="vertical-align: top;">113<br></td>
+<td style="vertical-align: top;">CS<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSCX<br></td>
+<td style="vertical-align: top;">114<br></td>
+<td style="vertical-align: top;">control<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">EVM<br></td>
+<td style="vertical-align: top;">115<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">bits<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">EVT<br></td>
+<td style="vertical-align: top;">116<br></td>
+<td style="vertical-align: top;">event<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td valign="top">PROCU<br></td>
+<td valign="top">117<br></td>
+<td valign="top">script_id<br></td>
+<td valign="top">0<br></td>
+<td valign="top">4*X<br></td>
+<td valign="top">uint32_t pars[X]<br></td>
+</tr>
+</tbody>
+</table>
+<h3><a name="Response" id="Response"></a>Response</h3>
+<p>The response has cmd/p1/p2 as in the request.&nbsp; p3/res holds
+the return value.&nbsp; If the command returns additional values
+they will be in the immediately following extension.<br></p>
+Normally res should be treated as a 32 bit signed value and will be
+greater than or equal to zero.&nbsp; Upon failure res will be less
+than 0 and contains an error code.<br>
+<p>There are a few commands where the returned value should be
+treated as a 32 bit unsigned value.&nbsp; These commands can not
+fail.&nbsp; They are indicated with a * after the command
+name.<br></p>
+<p>Commands with an extension have the size of the extension in
+bytes returned in res (or &lt;0 on error as above).</p>
+<table summary="" style="width: 80%;" cellspacing="2" cellpadding=
+"2" border="1">
+<tbody>
+<tr>
+<td style="font-weight: bold;">COMMAND</td>
+<td style="font-weight: bold;">cmd<br></td>
+<td style="vertical-align: top; font-weight: bold;">p1<br></td>
+<td style="vertical-align: top; font-weight: bold;">p2<br></td>
+<td style="font-weight: bold;">res<br></td>
+<td style="font-weight: bold;">Extension<br></td>
+</tr>
+<tr>
+<td>MODES</td>
+<td>0</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>MODEG</td>
+<td>1</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>mode<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PUD</td>
+<td>2</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>READ</td>
+<td>3</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>level<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WRITE</td>
+<td>4</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PWM</td>
+<td>5</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PRS</td>
+<td>6</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PFS</td>
+<td>7</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERVO</td>
+<td>8</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WDOG</td>
+<td>9</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BR1 *</td>
+<td>10</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>bits<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BR2 *</td>
+<td>11</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>bits<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BC1</td>
+<td>12</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BC2</td>
+<td>13</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BS1</td>
+<td>14</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BS2</td>
+<td>15</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>TICK *<br></td>
+<td>16</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>tick<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>HWVER *<br></td>
+<td>17</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>version<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NO</td>
+<td>18</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>handle<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NB</td>
+<td>19</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NP</td>
+<td>20</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NC</td>
+<td>21</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PRG</td>
+<td>22</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>range<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PFG</td>
+<td>23</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>frequency<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PRRG</td>
+<td>24</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>real range<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>HELP</td>
+<td>25</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>N/A<br></td>
+<td>N/A<br></td>
+</tr>
+<tr>
+<td>PIGPV *<br></td>
+<td>26</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>version<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVCLR</td>
+<td>27</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVAG</td>
+<td>28</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave pulses<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVAS</td>
+<td>29</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave pulses<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>N/A<br></td>
+<td>30</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>-<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>N/A<br></td>
+<td>31</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>-<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVBSY</td>
+<td>32</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>busy (1) or not busy (0)<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVHLT</td>
+<td>33</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVSM</td>
+<td>34</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave micros<br>
+wave micros - high<br>
+wave micros - max<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVSP</td>
+<td>35</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave pulses<br>
+wave pulses - high<br>
+wave pulses - max<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVSC</td>
+<td>36</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave DMA CBs<br>
+wave DMA CBs - high<br>
+wave DMA CBs - max<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>TRIG</td>
+<td>37</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-</td>
+</tr>
+<tr>
+<td>PROC</td>
+<td>38</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>script id<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PROCD</td>
+<td>39</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PROCR</td>
+<td>40</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>script status<br></td>
+<td>-</td>
+</tr>
+<tr>
+<td>PROCS</td>
+<td>41</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SLRO</td>
+<td>42</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SLR</td>
+<td>43</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>X<br></td>
+<td>uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td>SLRC</td>
+<td>44</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PROCP</td>
+<td>45</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>44</td>
+<td>uint32_t script_status<br>
+uint32_t pars[10]<br></td>
+</tr>
+<tr>
+<td>MICS</td>
+<td>46</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>MILS</td>
+<td>47</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PARSE</td>
+<td>48</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>N/A<br></td>
+<td>-</td>
+</tr>
+<tr>
+<td>WVCRE</td>
+<td>49</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave id<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVDEL</td>
+<td>50</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVTX</td>
+<td>51</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave DMA CBs<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVTXR</td>
+<td>52</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave DMA CBs<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVNEW</td>
+<td>53</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CO</td>
+<td>54</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>handle</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CC</td>
+<td>55</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRD</td>
+<td>56</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>X<br></td>
+<td>uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td>I2CWD</td>
+<td>57</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWQ</td>
+<td>58</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRS</td>
+<td>59</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>byte value<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWS</td>
+<td>60</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRB</td>
+<td>61</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>byte value<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWB</td>
+<td>62</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRW</td>
+<td>63</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>word value<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWW</td>
+<td>64</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRK</td>
+<td>65</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWK</td>
+<td>66</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRI</td>
+<td>67</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>X<br></td>
+<td>uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td>I2CWI</td>
+<td>68</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CPC</td>
+<td>69</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>word value<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CPK</td>
+<td>70</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>X<br></td>
+<td>uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td>SPIO<br></td>
+<td>71</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>handle<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SPIC</td>
+<td>72</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SPIR</td>
+<td>73</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>X<br></td>
+<td>uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td>SPIW</td>
+<td>74</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SPIX</td>
+<td>75</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>X</td>
+<td>uint8_t data[X]</td>
+</tr>
+<tr>
+<td>SERO</td>
+<td>76</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>handle<br></td>
+<td>-</td>
+</tr>
+<tr>
+<td>SERC</td>
+<td>77</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERRB</td>
+<td>78</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>byte value<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERWB</td>
+<td>79</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERR</td>
+<td>80</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>X<br></td>
+<td>uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td>SERW</td>
+<td>81</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERDA</td>
+<td>82</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>data ready count<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">GDC<br></td>
+<td style="vertical-align: top;">83<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">dutycycle<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">GPW<br></td>
+<td style="vertical-align: top;">84<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">pulsewidth<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">HC<br></td>
+<td style="vertical-align: top;">85<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">HP<br></td>
+<td style="vertical-align: top;">86<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CF1<br></td>
+<td style="vertical-align: top;">87<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">value<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CF2<br></td>
+<td style="vertical-align: top;">88<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t retBuf[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BI2CC<br></td>
+<td style="vertical-align: top;">89<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BI2CO<br></td>
+<td style="vertical-align: top;">90<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BI2CZ<br></td>
+<td style="vertical-align: top;">91<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">I2CZ<br></td>
+<td style="vertical-align: top;">92<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">WVCHA<br></td>
+<td style="vertical-align: top;">93<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">SLRI<br></td>
+<td style="vertical-align: top;">94<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CGI<br></td>
+<td style="vertical-align: top;">95<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">config<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CSI<br></td>
+<td style="vertical-align: top;">96<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FG<br></td>
+<td style="vertical-align: top;">97<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FN<br></td>
+<td style="vertical-align: top;">98<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td>NOIB</td>
+<td>99</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">WVTXM<br></td>
+<td style="vertical-align: top;">100<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">wave DMA CBs<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">WVTAT<br></td>
+<td style="vertical-align: top;">101<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">wave id<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">PADS<br></td>
+<td style="vertical-align: top;">102<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">PADG<br></td>
+<td style="vertical-align: top;">103<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">strength<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FO<br></td>
+<td style="vertical-align: top;">104<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FC<br></td>
+<td style="vertical-align: top;">105<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FR<br></td>
+<td style="vertical-align: top;">106<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FW<br></td>
+<td style="vertical-align: top;">107<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FS<br></td>
+<td style="vertical-align: top;">108<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">position<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FL<br></td>
+<td style="vertical-align: top;">109<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t filenames[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">SHELL<br></td>
+<td style="vertical-align: top;">110<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">exit status<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSPIC<br></td>
+<td style="vertical-align: top;">111<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSPIO<br></td>
+<td style="vertical-align: top;">112<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSPIX<br></td>
+<td style="vertical-align: top;">113<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]</td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSCX<br></td>
+<td style="vertical-align: top;">114<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">X+4<br></td>
+<td style="vertical-align: top;">uint32_t status<br>
+uint8_t data[X]</td>
+</tr>
+<tr>
+<td style="vertical-align: top;">EVM<br></td>
+<td style="vertical-align: top;">115<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">EVT<br></td>
+<td style="vertical-align: top;">116<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td valign="top">PROCU<br></td>
+<td valign="top">117<br></td>
+<td valign="top">-<br></td>
+<td valign="top">-<br></td>
+<td valign="top">0<br></td>
+<td valign="top">-<br></td>
+</tr>
+</tbody>
+</table>
+<code><br></code>
+<h3><a name="cmdCmd_t" id="cmdCmd_t"></a>cmdCmd_t</h3>
+<code>typedef struct<br>
+{<br>
+&nbsp;&nbsp; uint32_t cmd;<br>
+&nbsp;&nbsp; uint32_t p1;<br>
+&nbsp;&nbsp; uint32_t p2;<br>
+&nbsp;&nbsp; union<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint32_t p3;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint32_t ext_len;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint32_t res;<br>
+&nbsp;&nbsp; };<br>
+} cmdCmd_t;<br></code><br>
+</body>
+</html>