Merge pull request #343 from joan2937/master

Synchronize develop branch with master.
This commit is contained in:
Guy McSwain 2020-04-29 15:48:08 -05:00 committed by GitHub
commit 471712c513
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
119 changed files with 10333 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
DOC/HTML/images/caps.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
DOC/HTML/images/driver.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

BIN
DOC/HTML/images/faq-i2c.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
DOC/HTML/images/faq-spi.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
DOC/HTML/images/faq1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
DOC/HTML/images/faq2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
DOC/HTML/images/faq3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
DOC/HTML/images/imu-1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
DOC/HTML/images/imu-2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
DOC/HTML/images/imu-3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
DOC/HTML/images/ir-rx.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
DOC/HTML/images/keypad.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
DOC/HTML/images/lcd.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
DOC/HTML/images/ldr-cap.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
DOC/HTML/images/ldr.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
DOC/HTML/images/leds.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
DOC/HTML/images/meter.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
DOC/HTML/images/motor.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
DOC/HTML/images/msp430.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
DOC/HTML/images/nano.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
DOC/HTML/images/oled-2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
DOC/HTML/images/oled.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

BIN
DOC/HTML/images/pins.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
DOC/HTML/images/pisc-1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
DOC/HTML/images/pisc-2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
DOC/HTML/images/pisc-3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
DOC/HTML/images/pot.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
DOC/HTML/images/psu.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
DOC/HTML/images/reverse.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
DOC/HTML/images/rf-rx-2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
DOC/HTML/images/rf-rx.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
DOC/HTML/images/rf-tx.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
DOC/HTML/images/rotary.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
DOC/HTML/images/rpi.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
DOC/HTML/images/serial.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
DOC/HTML/images/servo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
DOC/HTML/images/sidebar.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
DOC/HTML/images/speaker.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

BIN
DOC/HTML/images/srf02.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
DOC/HTML/images/srf04.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
DOC/HTML/images/stepper.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
DOC/HTML/images/topbar.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1015 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
DOC/HTML/images/ubec-2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
DOC/HTML/images/wheel.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
DOC/HTML/images/wires.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
DOC/HTML/images/yl-40.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@ -0,0 +1,52 @@
body
{
font-size: 100%;
font-family: Arial, Helvetica, sans-serif;
color: #101010;
margin-left: 1%; margin-right: 10%;
}
h1 {font-size: 2.4em; color: #5d9dce; font-weight: bold;}
h2 {font-size: 1.8em; color: #5d9dce; font-weight: bold;}
h3 {font-size: 1.4em; color: #5d9dce; font-weight: bold;}
h4 {font-size: 1.2em; color: #5d9dce;}
h5 {font-size: 1.0em; color: #5d9dce;}
h6 {font-size: 0.8em; color: #5d9dce;}
code {display:block;font-size:80%; font-family: "Courier New", Courier, monospace; background-color:#D0D0D0;}
pre {font-size:80%; font-family: Courier; background-color:#D0D020;}
table.ev
{
border: 3px solid green;
}
td.ev1
{
width: 200px;
border: 1px solid green;
}
td.ev2
{
border: 1px solid green;
}
a.l1:link,a.l1:visited
{
display:block;
font-weight:bold;
color:#FFFFFF;
background-color:#98bf21;
width:120px;
text-align:center;
padding:4px;
text-decoration:none;
}
a.l1:hover,a.l1:active
{
background-color:#7A991A;
}

View File

@ -0,0 +1,3 @@
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#map_canvas { height: 100% }

2
DOC/MAN/README Normal file
View File

@ -0,0 +1,2 @@
Placeholder directory for man pages.

16
DOC/README Normal file
View File

@ -0,0 +1,16 @@
bin various scripts to generate man pages and HTML
dbase defines the structure of the web documentation
HTML auto generated html web site
makedoc run to regenerate documentation
MAN auto generated man pages
src/defs edit to change pigs, pigpiod, pig2vcd, and examples docs
src/html edit to change the fairly invariant web pages
DO NOT ADD auto generated HTML to this directory
tmp stores temporary files, may be deleted

5
DOC/bin/backup.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
# backup database
cp dbase/pigpio.sqlite dbase/pigpio.sqlite.bak

14
DOC/bin/body.py Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env python3
import glob
for fn in glob.glob("src/html/*.html"):
f = open(fn)
h = f.read()
f.close()
s1,d1,e1=h.partition("<body>")
s2,d2,e2=e1.partition("</body>")
f = open("tmp/body/" + fn[9:-5] + ".body", "w")
f.write(s2)
f.close()

21
DOC/bin/build_site.py Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env python3
import os
import sqlite3
db=sqlite3.connect("dbase/pigpio.sqlite")
c=db.cursor()
c.execute("select file_name from pigpio")
names = c.fetchall()
for n in names:
os.system("bin/html.py {0} >HTML/{0}.html".format(n[0]))
print(n[0])
c.close()
db.close()

563
DOC/bin/cmakdoc.py Executable file
View File

@ -0,0 +1,563 @@
#!/usr/bin/env python3
import sys
pigpio_m1="""
.\" Process this file with
.\" groff -man -Tascii pigpio.3
.\"
.TH pigpio 3 2012-2020 Linux "pigpio archive"
.SH NAME
pigpio - A C library to manipulate the Pi's GPIO.\n
.SH SYNOPSIS\n
#include <pigpio.h>\n
gcc -Wall -pthread -o prog prog.c -lpigpio -lrt\n
sudo ./prog
.SH DESCRIPTION\n
"""
pigpiod_if_m1="""
.\" Process this file with
.\" groff -man -Tascii pigpiod_if.3
.\"
.TH pigpiod_if 3 2012-2020 Linux "pigpio archive"
.SH NAME
pigpiod_if - A C library to interface to the pigpio daemon.\n
.SH SYNOPSIS\n
#include <pigpiod_if.h>\n
gcc -Wall -pthread -o prog prog.c -lpigpiod_if -lrt\n
./prog
.SH DESCRIPTION\n
"""
pigpiod_if2_m1="""
.\" Process this file with
.\" groff -man -Tascii pigpiod_if2.3
.\"
.TH pigpiod_if2 3 2012-2020 Linux "pigpio archive"
.SH NAME
pigpiod_if2 - A C library to interface to the pigpio daemon.\n
.SH SYNOPSIS\n
#include <pigpiod_if2.h>\n
gcc -Wall -pthread -o prog prog.c -lpigpiod_if2 -lrt\n
./prog
.SH DESCRIPTION\n
"""
pigpiod_m1="""
.\" Process this file with
.\" groff -man -Tascii pigpiod.1
.\"
.TH pigpiod 1 2012-2020 Linux "pigpio archive"
.SH NAME
pigpiod - A utility to start the pigpio library as a daemon.\n
.SH SYNOPSIS\n
sudo pigpiod [OPTION]...
.SH DESCRIPTION\n
"""
pig2vcd_m1="""
.\" Process this file with
.\" groff -man -Tascii pig2vcd.1
.\"
.TH pig2vcd 1 2012-2020 Linux "pigpio archive"
.SH NAME
pig2vd - A utility to convert pigpio notifications to VCD.\n
.SH SYNOPSIS\n
pig2vcd </dev/pigpioXX >file.VCD
.SH DESCRIPTION\n
"""
pigpio_m2="""
.SH SEE ALSO\n
pigpiod(1), pig2vcd(1), pigs(1), pigpiod_if(3), pigpiod_if2(3)
.SH AUTHOR\n
joan@abyz.me.uk
"""
pigpiod_if_m2="""
.SH SEE ALSO\n
pigpiod(1), pig2vcd(1), pigs(1), pigpio(3), pigpiod_if2(3)
.SH AUTHOR\n
joan@abyz.me.uk
"""
pigpiod_if2_m2="""
.SH SEE ALSO\n
pigpiod(1), pig2vcd(1), pigs(1), pigpio(3), pigpiod_if(3)
.SH AUTHOR\n
joan@abyz.me.uk
"""
pigpiod_m2="""
.SH SEE ALSO\n
pig2vcd(1), pigs(1), pigpio(3), pigpiod_if(3), pigpiod_if2(3)
.SH AUTHOR\n
joan@abyz.me.uk
"""
pig2vcd_m2="""
.SH SEE ALSO\n
pigpiod(1), pigs(1), pigpio(3), pigpiod_if(3), pigpiod_if2(3)
.SH AUTHOR\n
joan@abyz.me.uk
"""
def emit(s):
sys.stdout.write(s)
def get_line(f):
line = f.readline()
if man:
line = line.replace(" \n", "\n.br\n")
else:
line = line.replace("<", "&lt;")
line = line.replace(">", "&gt;")
line = line.replace(" \n", "<br>\n")
return line
def nostar(k):
if k[0] == "*":
return k[1:]
else:
return k
NONE =0
MAN =1
TEXT =2
OVERVIEW=4
FUNC =5
DESC =6
OPT =7
PARAMS =8
DEFS =9
param_used = []
param_defd = []
param_refd = []
at = NONE
in_code = False
in_pard = False
in_table = False
if len(sys.argv) > 2:
obj = sys.argv[1]
fn = sys.argv[2]
if len(sys.argv) > 3:
man = True
else:
man = False
else:
exit("bad args, need page file [man]")
try:
f = open(fn, "r")
except:
exit("aborting, can't open {}".format(fn))
if man:
if obj == "pigpio":
emit(pigpio_m1)
elif obj == "pigpiod_if":
emit(pigpiod_if_m1)
elif obj == "pigpiod_if2":
emit(pigpiod_if2_m1)
elif obj == "pigpiod":
emit(pigpiod_m1)
elif obj == "pig2vcd":
emit(pig2vcd_m1)
emit("\n.ad l\n")
emit("\n.nh\n")
while True:
line = get_line(f)
if line == "":
for p in param_used:
if p not in param_defd:
sys.stderr.write("{} used but not defined.\n".format(p))
for p in param_defd:
if p not in param_used and p not in param_refd:
sys.stderr.write("{} defined but not used.\n".format(p))
break
if line == "/*MAN\n":
at = MAN
continue
elif line == "MAN*/\n":
at = NONE
continue
if line == "/*TEXT\n":
at = TEXT
continue
elif line == "TEXT*/\n":
at = NONE
continue
elif line == "/*OVERVIEW\n":
if man:
emit("\n.SH OVERVIEW\n")
else:
emit("<h2>OVERVIEW</h2>")
emit(
"<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
at = OVERVIEW
continue
elif line == "OVERVIEW*/\n":
if man:
emit(".SH FUNCTIONS\n")
else:
emit("</tbody></table>")
emit("<h2>FUNCTIONS</h2>")
at = NONE
elif line == "/*F*/\n":
in_code = False
fdef=""
line = get_line(f)
at = FUNC
elif line == "/*D\n":
# Function definition should be complete.
fdef = fdef.replace("\n", " ")
while fdef.find(" ") != -1:
fdef = fdef.replace(" ", " ")
fdef = fdef.replace("( ", "(")
(rf, sep1, end1) = fdef.partition("(")
(parl, sep2, end2) = end1.partition(")")
tps = parl.split(",")
rf = rf.split(" ")
ret = rf[0]
func = rf[1]
if ret not in param_used:
param_used.append(ret)
if man:
t = "\\fB" + ret + " " + func + "(" + parl + ")\\fP"
emit("\n.IP \"{}\"\n.IP \"\" 4\n".format(t))
else:
emit("<h3><a name=\"{}\"></a><a href=\"#{}\"><small>{}</small></a> {}".
format(nostar(func), ret, ret,func))
emit("<small>(")
x = 0
for tp in tps:
tp = tp.strip()
(t, sep3, p) = tp.partition(" ")
t = t.strip()
p = p.strip()
if (p != ""):
if p not in param_used:
param_used.append(p)
if t not in param_used:
param_used.append(t)
if x > 0:
if man:
pass
else:
emit(", ")
x += 1
if man:
pass
else:
emit("<a href=\"#{}\">{}</a> <a href=\"#{}\">{}</a>".
format(t, t, p, p))
else:
if man:
pass
else:
emit("{}".format(t))
if man:
pass
else:
emit(")</small></h3>\n")
line = get_line(f)
at = DESC
elif line == "D*/\n":
at = NONE
elif line == "/*O\n":
if man:
emit(".SH OPTIONS\n")
else:
emit("<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
at = OPT
continue
elif line == "O*/\n":
if man:
pass
else:
emit("</tbody></table>")
at = NONE
continue
elif line == "/*PARAMS\n":
last_par = "*"
if man:
emit(".SH PARAMETERS\n")
else:
emit("<h2>PARAMETERS</h2>")
at = PARAMS
continue
elif line == "PARAMS*/\n":
at = NONE
elif line.startswith("/*DEF_S "):
title = line[8:-3]
in_code = True
if man:
emit(".SH {}\n".format(title))
emit("\n.EX\n")
else:
emit("<h2>{}</h2>".format(title))
emit("<code>")
at = DEFS
continue
elif line == "/*DEF_E*/\n":
in_code = False
if man:
emit("\n.EE\n")
else:
emit("</code>")
at = NONE
continue
if at != NONE and at != OVERVIEW:
if line.find("@") != -1:
if not in_table:
in_table = True
if man:
pass
else:
emit("<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
if man:
line = line.replace("@", " ")
emit(line)
# emit("\n.br\n")
emit(".br\n")
else:
emit("<tr>")
cols = line.split("@")
for col in cols:
emit("<td>{}</td>".format(col.strip()))
emit("</tr>")
continue
else:
if in_table:
in_table = False
if man:
pass
else:
emit("</tbody></table>")
if line == "...\n" or line == ". .\n":
if in_code:
in_code = False
if man:
emit("\n.EE\n")
else:
emit("</code>")
else:
in_code = True
if line == "...\n":
if man:
emit("\\fBExample\\fP\n.br\n")
else:
emit("<b><small>Example</small></b><br><br>")
if man:
emit("\n.EX\n")
else:
emit("<code>")
continue
if line == "\n":
if man:
emit("\n.br\n")
else:
emit("<br>")
if not in_code:
if man:
emit("\n.br\n")
else:
emit("<br>")
continue
if in_code:
if man:
line = line.replace("\n", "\n.br\n")
else:
line = line.replace(" ", "&nbsp;")
line = line.replace("\n", "<br>")
while line.find("[*") != -1 and line.find("*]") != -1:
(b, s, e) = line.partition("[*")
(l, s, e) = e.partition("*]")
if man:
line = "{}\\fB{}\\fP{}".format(b, l, e)
else:
line = "{}<a href=\"#{}\">{}</a>{}".format(b, l, l, e)
if l not in param_refd:
param_refd.append(l)
while line.find("[[") != -1 and line.find("]]") != -1:
(b, s, e) = line.partition("[[")
(l, s, e) = e.partition("]]")
if man:
line = "{}\\fB{}\\fP{}".format(b, l, e)
else:
line = "{}<a href=\"{}\">{}</a>{}".format(b, l, l, e)
if at == TEXT:
if line[0] == '*' and line[-2] == '*':
if man:
emit(".SS {}".format(line[1:-2]))
else:
emit("<h3>{}</h3>".format(line[1:-2]))
elif line[0] == '^' and line[-2] == '^':
if man:
emit(".SS {}".format(line[1:-2]))
else:
emit("<br><b>{}</b><br>".format(line[1:-2]))
else:
emit(line)
elif at == OVERVIEW:
if line == "\n":
if man:
emit("\n.br\n")
else:
emit("<tr><td></td><td></td></tr>")
else:
(func, sep, desc) = line.partition(" ")
if desc != "":
if man:
emit("\n.br\n{}".format(line.strip()))
else:
emit("<tr><td><a href=\"#{}\">{}</a></td><td>{}</td></tr>".
format(func, func, desc))
else:
if man:
emit(".SS {}".format(line.replace("_", " ").strip()))
else:
emit("<tr><td><b>{}</b></td><td></td></tr>".
format(func.replace("_", " ")))
elif at == FUNC:
fdef += line
elif at == DESC:
emit(line)
elif at == PARAMS:
if line.find("::") != -1:
(par, sep, end) = line.partition("::")
par = par.strip()
end = end.strip()
if nostar(par.lower()) < nostar(last_par.lower()):
sys.stderr.write("Out of order {} after {}.\n".
format(par, last_par))
last_par = par
if par in param_defd:
sys.stderr.write("Duplicate definition of {}.\n".format(par))
else:
param_defd.append(par)
if end != "":
end = ": " + end
if man:
emit("\n.IP \"\\fB{}\\fP{}\" 0\n".format(par, end))
else:
emit("<h3><a name=\"{}\">{}</a>{}</h3>\n".format(par, par, end))
else:
emit(line)
elif at == MAN:
if man:
emit(line)
elif at == OPT:
line = line.split("|")
if man:
emit("\n.IP \"\\fB{}\\fP\"\n{}.\n{}.\n{}.".format(
line[0], line[1], line[2], line[3]))
else:
emit("<tr><td><b>{}</b></td><td>{}</td><td>{}</td><td>{}</td></tr>".
format(line[0], line[1], line[2], line[3]))
elif at == DEFS:
emit(line)
if man:
if obj == "pigpio":
emit(pigpio_m2)
elif obj == "pigpiod_if":
emit(pigpiod_if_m2)
elif obj == "pigpiod_if2":
emit(pigpiod_if2_m2)
elif obj == "pigpiod":
emit(pigpiod_m2)
elif obj == "pig2vcd":
emit(pig2vcd_m2)
f.close()

123
DOC/bin/examples.py Executable file
View File

@ -0,0 +1,123 @@
#!/usr/bin/env python3
import sys
from collections import OrderedDict
def emit(s):
sys.stdout.write(s)
def get_line(f):
line = f.readline()
return line
def get_file():
try:
fn = sys.argv[1]
f = open(fn, "r")
except:
exit("aborting, can't open {}".format(fn))
return f
def cancel_row():
global in_row
if in_row:
in_row = False
emit('</td></tr>')
def start_row():
global in_row
if not in_row:
in_row = True
emit('<tr><td style="width: 150px; vertical-align: top; font-size: 0.8em; font-weight: bold;">')
def cancel_table():
global in_table
if in_table:
in_table = False
cancel_row()
emit('</tbody></table>')
def start_table():
global in_table
if not in_table:
in_table = True
emit('<table style="text-align: left; width: 90%;" border="0" cellpadding="4" cellspacing="4"><tbody>')
else:
cancel_row()
start_row()
index = {}
in_code = False
in_samp = False
in_table = False
in_row = False
f = get_file()
while True:
line = get_line(f)
if line == "":
cancel_table()
emit('<table style="text-align: left; width: 90%;" border="0" cellpadding="4" cellspacing="4"><tbody>\n')
last = None
ordered = OrderedDict(sorted(index.items(), key=lambda t: t[1].lower()))
for k,v in ordered.items():
tag=k.split('_')[0]
if last != v.lower():
if last is not None:
emit('</td></tr>')
last = v.lower()
anchor="index_"+last.replace(" ", "_")
emit('<tr><td><span id="'+anchor+'"></span>'+v+'</td><td>')
emit(' <a href="#'+k+'">'+tag+'</a>\n')
emit('</td></tr></tbody></table>')
break
if line.startswith("?0|"):
s = line.split("|")
anchor=s[1].strip()
emit('<a href="#'+anchor+'">'+anchor+'</a><br>')
continue
if line.startswith("?1|"):
cancel_table()
s = line.split("|")
tag = s[1].strip()+"_"
anchor=s[2].strip()
emit('<h3><span id="'+anchor+'">'+anchor+'</span></h3>')
continue
elif line.startswith("?2|") or line.startswith("?3|") or line.startswith("?4|"):
start_table()
s = line.split("|")
anchor=tag+s[1].strip()
if line.startswith("?2|"):
link=s[1].strip()+".html"
elif line.startswith("?3|"):
link="code/"+s[1].strip()+".zip"
elif line.startswith("?4|"):
link=s[1].strip()
else:
link="code/"+s[1].strip()
date=s[2].strip()
title=s[3].strip()
emit('<span id="'+anchor+'"><a href="'+link+'">'+title+'</a><br>'+date+'</span></td><td>')
index.update({anchor:title})
continue
else:
emit(line.replace("\n", "<br>\n"))
f.close()

137
DOC/bin/html.py Executable file
View File

@ -0,0 +1,137 @@
#!/usr/bin/env python3
import sys
import sqlite3
import time
i_file_name = 0
i_menu_title = 1
i_menu_pos = 2
i_menu_level = 3
i_page_title = 4
i_pic1 = 5
i_pic2 = 6
i_pic3 = 7
i_body = 8
print("""
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="description" content="Raspberry Pi Reg. C GPIO library and Python GPIO module and shell command utilities to control the GPIO, including SPI, I2C, and serial links." />
<meta name="keywords" content="raspberry, pi, C, Python, GPIO, library, shell, command, utilities, module, SPI, I2C, serial" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>pigpio library</title>
<link rel="stylesheet" type="text/css" href="scripts/index.css">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
<body>
""")
page = sys.argv[1]
menuH = ""
menuV = ""
sitemap = ""
header = '<a href="index.html"><img src="images/pigpio-logo.gif" border="0" /></a>pigpio library'
footer1 = "<small>&copy; 2012-2020</small>";
footer2 = "e-mail: pigpio @ abyz.me.uk";
footer3 = "<small>Updated: " + time.strftime("%d/%m/%Y") + "</small>";
db=sqlite3.connect("dbase/pigpio.sqlite")
c=db.cursor()
def menu_titles():
global menuV, menuH
c.execute(
"SELECT file_name, menu_title, menu_level FROM pigpio ORDER by menu_pos")
recs = c.fetchall()
menuV = ""
menuH = ""
for r in recs:
if r[2] == 1:
menuV += '<a class="l1" href="' + r[0] + '.html">' + r[1] + '</a>\n'
menuH += '<a class="l2" href="' + r[0] + '.html">[' + r[1] + ']</a>\n'
def sitemap():
c.execute(
"SELECT file_name, menu_title, menu_level FROM pigpio ORDER by menu_pos")
recs = c.fetchall()
stemap = ""
for r in recs:
if r[2] > 0:
s = "----" * (r[2]-1)
stemap += s + '<a href="' + r[0] + '.html">' + r[1] + '</a><br>\n'
return stemap
def check_image(d):
img = "images/" + d
try:
with open("HTML/" + img) as f:
print('<td><img src="' + img + '" width="250"></td>')
except:
pass
titles = menu_titles()
s_sidebar = 'style="background:#EAF2E6 url(\'images/sidebar.gif\') repeat-y; width:35px; height:100%"'
s_header = 'style="background:url(\'images/topbar.gif\') repeat-x; height: 70px; font-size:1.5em; vertical-align: top;"'
s_menuV = 'style="vertical-align: top; background-color: #98bf21;"'
c.execute("SELECT * FROM pigpio WHERE file_name=?", (page,))
rec = c.fetchone()
if page == "sitemap":
body = sitemap()
else:
body = rec[i_body]
c.close()
db.close()
print('<table style="padding:0px; border:0px; margin:0px; width:780px; background-color:#e0e0e0;">')
print('<td ' + s_sidebar + '></td>')
print('<td>')
print('<table>')
print('<div ' + s_header + '>' + header + '</div>')
print('</table>')
print('<table><div>')
check_image(rec[i_pic1])
check_image(rec[i_pic2])
check_image(rec[i_pic3])
print('</div></table>')
print("<table>")
print('<td ' + s_menuV + '>' + menuV + '</td>')
print('<td><center><h2>' + rec[i_page_title] + '</h2></center>' + body + '</td>')
print('</table>')
print('<div style="vertical-align: center; text-align: center; background-color:#98bf21; font-size:0.8em; height:30px">' + menuH + '</div>')
print('<table><tr>')
print('<td style="width: 200px"><div style="text-align: left;">' + footer1 + '</div></td>')
print('<td style="width: 350px"><div style="text-align: center;">' + footer2 + '</div></td>')
print('<td style="width: 200px"><div style="text-align: right;">' + footer3 + '</div></td>')
print('</tr></table>')
print('</td>')
print('</table>')
print('</body>\n</html>')

14
DOC/bin/purge.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
# if backup same as new delete it
if cmp -s dbase/pigpio.sqlite dbase/pigpio.sqlite.bak
then
rm dbase/pigpio.sqlite.bak
else
d=$(date "+%F-%H-%M-%S")
mv -f dbase/pigpio.sqlite.bak dbase/pigpio.sqlite.$d
fi
# delete backups older than a week
find dbase/pigpio.sqlite.2* -mtime +7 -delete &>/dev/null

270
DOC/bin/pymakdoc.py Executable file
View File

@ -0,0 +1,270 @@
#!/usr/bin/env python3
import sys
def emit(s):
sys.stdout.write(s)
def str2hex(s):
return ":".join("{:02x}".format(ord(c)) for c in s)
def funchdr(line):
if len(line) > 1 and (not line.startswith(" ")) and line.find("(") != -1:
return True
else:
return False
def get_line(f):
line = f.readline()
line = line.replace("<", "&lt;")
line = line.replace(">", "&gt;")
return line
def get_file():
try:
fn = sys.argv[1]
f = open(fn, "r")
except:
exit("aborting, can't open {}".format(fn))
return f
NONE = 0
DESCRIPTION = 1
OVERVIEW = 2
CLASSES = 3
CLASS = 4
FUNC = 5
XREF = 6
DATA = 7
f = get_file()
param_used = []
param_defd = []
param_refd = []
at = NONE
in_code = False
in_samp = False
in_table = False
left = 0
while True:
line = get_line(f)
if line == "":
for p in param_used:
if p not in param_defd:
sys.stderr.write("{} is used but not defined.\n".format(p))
for p in param_defd:
if p not in param_used and p not in param_refd:
sys.stderr.write("{} is defined but not used.\n".format(p))
break
if line.startswith("DESCRIPTION"):
left = 4
at = DESCRIPTION
continue
elif line.startswith(" OVERVIEW"):
left = 4
emit("<h2>OVERVIEW</h2>")
emit(
"<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
at = OVERVIEW
continue
elif line.startswith("CLASSES"):
left = 4
emit("</tbody></table>")
at = NONE
continue
elif line.startswith(" class "):
in_func = False
if line.startswith(" class error"):
at = NONE
else:
left = 8
emit("<h2>{}</h2>".format(line))
_class = line[10:-1]
at = CLASS
continue
elif line.startswith("FUNCTIONS"):
left = 4
emit("<h2>FUNCTIONS</h2>")
in_func = False
at = FUNC
continue
elif line.startswith(" xref()"):
left = 8
emit("<h2>PARAMETERS</h2>")
in_func = False
last_par = ""
at = XREF
continue
elif line.startswith("DATA"):
at = DATA
continue
line = line[left:]
at_funchdr = funchdr(line)
if at != NONE and at != OVERVIEW:
if at == CLASS or at == FUNC:
if not at_funchdr:
line = line[4:]
line = line.replace(' \n', '<br>')
if line.find('@') != -1:
if not in_table:
in_table = True
emit("<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
emit("<tr>")
cols = line.split('@')
for col in cols:
emit("<td>{}</td>".format(col.strip()))
emit("</tr>")
continue
else:
if in_table:
in_table = False
emit("</tbody></table>")
if line.find(":=") != -1:
if not in_samp:
emit("<br><b><small>Parameters</small></b><br><br><samp>")
in_samp = True
if line == '...\n' or line == '. .\n':
if in_code:
in_code = False
emit("</code>")
else:
in_code = True
if line == '...\n':
emit("<b><small>Example</small></b><br><br>")
emit("<code>")
continue
if line == '\n' or line == '':
if in_samp:
emit("</samp>")
in_samp = False
emit('<br>')
if not in_code:
emit('<br>')
continue
if in_code or in_samp:
line = line.replace(" ", "&nbsp;")
line = line.replace("\n", "<br>")
while line.find('[*') != -1 and line.find('*]') != -1:
(b, s, e) = line.partition('[*')
(l, s, e) = e.partition('*]')
line = '{}<a href="#{}">{}</a>{}'.format(b, l, l, e)
if l not in param_refd:
param_refd.append(l)
while line.find('[[') != -1 and line.find(']]') != -1:
(b, s, e) = line.partition('[[')
(l, s, e) = e.partition(']]')
line = '{}<a href="{}">{}</a>{}'.format(b, l, l, e)
if at == DESCRIPTION:
if line[0] == '*' and line[-2] == '*':
emit("<h3>{}</h3>".format(line[1:-2]))
elif line[0] == '[' and line[-2] == ']':
pass
else:
emit(line)
elif at == OVERVIEW:
if line == "\n":
emit("<tr><td></td><td></td></tr>")
else:
(func, sep, desc) = line.partition(' ')
if desc != '':
emit("<tr><td><a href=\"#{}\">{}</a></td><td>{}</td></tr>".
format(func, func, desc))
else:
emit("<tr><td><b>{}</b></td><td></td></tr>".
format(func).replace("_", " "))
elif at == CLASS or at == FUNC:
if at_funchdr:
in_func = True
if in_code:
emit("<br>***C***</code>")
in_code = False
if in_samp:
emit("<br>***S***</samp>")
in_samp = False
(func, sep1, end1) = line.partition("(")
(parl, sep2, end2) = end1.partition(")")
pars = parl.split(",")
func = func.strip()
if at == FUNC:
func = "pigpio." + func
else:
if func == "__init__":
func = "pigpio." + _class
emit("<h3><a name=\"{}\">{}".format(func,func))
emit('<small>(')
x = 0
for p in pars:
(p, sep3, end3) = p.partition('=')
p = p.strip()
if (p != 'self') and (p != '...') and (p != ''):
if p not in param_used:
param_used.append(p)
if x > 0:
emit(", ")
x += 1
emit("<a href=\"#{}\">{}</a>".format(p, p))
emit(')</small></h3>\n')
else:
if in_func:
emit(line)
elif at == XREF:
if line.find(':') != -1:
(par, sep, end) = line.partition(':')
par = par.strip()
end = end.strip()
emit("<h3><a name=\"{}\"></a>{}: {}</h3>".format(par, par, end))
if par.lower() < last_par.lower():
sys.stderr.write("Out of order {} after {}.\n".
format(par, last_par))
last_par = par
if par in param_defd:
sys.stderr.write("Duplicate definition of {}.\n".format(par))
else:
param_defd.append(par)
else:
emit(line)
f.close()

376
DOC/bin/smakdoc.py Executable file
View File

@ -0,0 +1,376 @@
#!/usr/bin/env python3
import sys
def get_file():
try:
fn = sys.argv[1]
f = open(fn, "r")
except:
exit("aborting, can't open {}".format(fn))
return f
def emit(s):
sys.stdout.write(s)
def str2hex(s):
return ":".join("{:02x}".format(ord(c)) for c in s)
def get_line(f):
line = f.readline()
if man:
line = line.replace(" \n", "\n.br\n")
else:
line = line.replace("<", "&lt;")
line = line.replace(">", "&gt;")
line = line.replace(" \n", "<br>\n")
return line
if len(sys.argv) > 2: # Are we creating a man page?
man = True
else:
man = False
NONE=0
INTRO=1
OVERVIEW=2
COMMANDS=3
PARAMETERS=4
SCRIPTS=5
param_used = []
param_defd = []
f = get_file()
at = NONE
in_table = False
in_code = False
funcdef ={}
if man:
emit("""
.\" Process this file with
.\" groff -man -Tascii foo.1
.\"
.TH pigs 1 2012-2020 Linux "pigpio archive"
.SH NAME
pigs - command line socket access to the pigpio daemon.\n
/dev/pigpio - command line pipe access to the pigpio daemon.\n
.SH SYNOPSIS\n
.B sudo pigpiod\n
then\n
.B pigs {command}+\n
or\n
.B \"echo {command}+ >/dev/pigpio\"\n
.SH DESCRIPTION\n
.ad l\n
.nh\n
""")
while True:
line = get_line(f)
if line == "":
for p in param_used:
if p not in param_defd:
sys.stderr.write("{} used but not defined.\n".format(p))
for p in param_defd:
if p not in param_used:
sys.stderr.write("{} defined but not used.\n".format(p))
break
if line.startswith("INTRO"):
line = get_line(f)
if man:
pass
else:
emit("<h2><a name=\"Introduction\">Introduction</a></h2>\n")
at = INTRO
elif line.startswith("OVERVIEW"):
line = get_line(f)
if man:
emit("\n.SH OVERVIEW\n")
else:
emit("<h2><a name=\"Overview\">Overview</a></h2>\n")
emit(
"<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
at = OVERVIEW
elif line.startswith("COMMANDS"):
line = get_line(f)
if man:
emit("\n.SH COMMANDS\n")
else:
emit("</tbody></table>")
emit("<h2><a name=\"Commands\">Commands</a></h2>\n")
funcs = sorted(funcdef)
at = COMMANDS
elif line.startswith("PARAMETERS"):
line = get_line(f)
last_par = ""
if man:
emit("\n.SH PARAMETERS\n")
else:
emit("<h2><a name=\"Parameters\">Parameters</a></h2>\n")
at = PARAMETERS
elif line.startswith("SCRIPTS"):
line = get_line(f)
if man:
emit("\n.SH SCRIPTS\n")
else:
emit("<h2><a name=\"Scripts\">Scripts</a></h2>\n")
at = SCRIPTS
if at != NONE:
if line.find("@") != -1:
if not in_table:
in_table = True
if man:
emit("\n.EX\n")
else:
emit("<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
if man:
pass
else:
emit("<tr>")
if man:
line = line.replace("@", " ")
emit(line)
else:
cols = line.split("@")
for col in cols:
emit("<td>{}</td>".format(col.strip()))
if man:
pass
else:
emit("</tr>")
continue
else:
if in_table:
in_table = False
if man:
emit("\n.EE\n")
else:
emit("</tbody></table>")
if line == "...\n" or line == ". .\n":
if in_code:
in_code = False
if man:
emit("\n.EE\n")
else:
emit("</code>")
else:
in_code = True
if at == COMMANDS:
if line == "...\n":
if man:
emit("\n\\fBExample\\fP\n.br\n")
else:
emit("<b><small>Example</small></b><br><br>")
if man:
emit("\n.EX\n")
else:
emit("<code>")
continue
if line == "\n" and at != OVERVIEW:
if man:
# emit("\n.br\n.br\n")
emit("\n.br\n")
else:
emit("<br><br>")
continue
if in_code:
if man:
line = line.replace("\n", "\n.br\n")
else:
line = line.replace(" ", "&nbsp;")
line = line.replace("\n", "<br>")
while line.find("[*") != -1 and line.find("*]") != -1:
(b, s, e) = line.partition("[*")
(l, s, e) = e.partition("*]")
if man:
line = "{}\\fB{}\\fP{}".format(b, l, e)
else:
line = "{}<a href=\"#{}\">{}</a>{}".format(b, l, l, e)
while line.find("[{") != -1 and line.find("}]") != -1:
(b, s, e) = line.partition("[[")
(l, s, e) = e.partition("]]")
if man:
line = "{}\\fB{}\\fP{}".format(b, l, e)
else:
line = "{}<a href=\"{}\">{}</a>{}".format(b, l, l, e)
if at == INTRO or at == SCRIPTS:
if line[0] == "*" and line[-2] == "*":
if man:
emit(".SS {}".format(line[1:-2]))
else:
emit("<h3>{}</h3>".format(line[1:-2]))
else:
emit(line)
elif at == OVERVIEW:
if line == "\n":
if man:
pass
else:
emit("<tr><td></td><td></td><td></td></tr>")
elif line.find("::") == -1:
if man:
emit(".SS {}".format(line))
else:
emit("<tr><td>{}</td><td></td><td></td></tr>".format(line))
else:
(funcpar, sep, desc) = line.partition("::")
funcpar = funcpar.strip()
desc = desc.strip()
if desc != "":
(func, sep, parl) = funcpar.partition(" ")
func = func.strip()
parl = parl.strip()
if func in funcdef:
sys.stderr.write("{} has been redefined.\n".format(func))
funcdef[func]=parl+"::"+desc
if man:
emit(".B {}\n".format(func+" "+parl+" "))
pass
else:
emit("<tr><td><a href=\"#{}\">{}</a>".format(func, func))
pars = parl.split()
for p in pars:
if p not in param_used:
param_used.append(p)
if man:
pass
else:
emit(" <a href=\"#{}\">{}</a>".format(p, p))
(des, sep, c) = desc.partition("::")
c = c.strip()
if man:
emit("{}\n.P\n".format(des))
pass
else:
emit("</td><td>{}</td><td><small><a href=\"cif.html#{}\">{}</a></small></td></tr>".format(des, c, c))
else:
if man:
pass
else:
emit("<tr><td><b>{}</b></td><td></td></tr>".format(funcpar))
if man:
# emit(".IP {} 9\n".format(func))
pass
else:
emit("<tr><td><a href=\"#{}\">{}</a>".format(func, func))
elif at == COMMANDS:
if line.find("::") != -1:
(func, sep, desc) = line.partition("::")
func = func.strip()
if func not in funcdef:
parl="unknown"
desc="unknown"
else:
(parl,sep,desc) = funcdef[func].partition("::")
(des, sep, c) = desc.partition("::")
if man:
t = "\\fB" + func + " " + parl + "\\fP" + " - " + des.strip()
emit("\n.IP \"{}\"\n.IP \"\" 4\n".format(t))
else:
emit("<h3><a name=\"{}\">{}</a>\n".format(func,func))
pars = parl.split()
for p in pars:
if man:
pass
else:
emit(" <a href=\"#{}\">{}</a>".format(p, p))
if man:
pass
else:
emit(" - {}</h3>".format(des.strip()))
else:
emit(line)
elif at == PARAMETERS:
if line.find("::") != -1:
(par, sep, desc) = line.partition("::")
par = par.strip()
desc = desc.strip()
if par.lower() < last_par.lower():
sys.stderr.write("Out of order {} after {}.\n".format(par, last_par))
last_par = par
if par in param_defd:
sys.stderr.write("Duplicate definition of {}.\n".format(par))
else:
param_defd.append(par)
if man:
emit("\n.IP \"\\fB{}\\fP - {}\" 0\n".format(par, desc))
else:
emit("<h3><a name=\"{}\">{}</a> - {}</h3>\n".format(par,par,desc))
else:
emit(line)
if man:
emit("""
.SH SEE ALSO\n
pigpiod(1), pig2vcd(1), pigpio(3), pigpiod_if(3), pigpiod_if2(3)
.SH AUTHOR\n
joan@abyz.me.uk
""")
f.close()

28
DOC/bin/tidy.py Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env python3
import glob
def snafu(t, s, r):
l = t
while l.find(s) != -1:
l = l.replace(s, r)
return l
for n in glob.glob("tmp/body/*.body"):
f = open(n, "r");
t = f.read()
f.close()
t = snafu(t, "<br><h2>", "<h2>")
t = snafu(t, "<br><h3>", "<h3>")
t = snafu(t, "</h2><br>", "</h2>")
t = snafu(t, "</h2>\n<br>", "</h2>\n")
t = snafu(t, "</h3><br>", "</h3>")
t = snafu(t, "</h3>\n<br>", "</h3>\n")
t = snafu(t, "<br><br><br>", "<br><br>")
f = open(n, "w");
f.write(t)
f.close()

21
DOC/bin/updatesql.py Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env python3
import sqlite3
import glob
db=sqlite3.connect("dbase/pigpio.sqlite")
c=db.cursor()
for fn in glob.glob("tmp/body/*.body"):
f = open(fn, encoding='utf-8')
body = f.read()
f.close()
c.execute("UPDATE pigpio SET body=? WHERE file_name=?", (body, fn[9:-5]))
c.close()
db.commit()
db.close()

Some files were not shown because too many files have changed in this diff Show More