first re-commit.

This commit is contained in:
2025-08-05 22:33:23 +02:00
commit e1ff579d1a
295 changed files with 107130 additions and 0 deletions

23
pigpio-master/.gitignore vendored Normal file
View File

@@ -0,0 +1,23 @@
*.o
*.so
*.so.*
*.pyc
pig2vcd
pigpiod
pigs
x_pigpio
x_pigpiod_if
x_pigpiod_if2
__pycache__
build
dist
*.egg-info
tmp/
# DOC files
DOC/dbase/pigpio.sqlite.*
DOC/tmp
DOC/MAN/*
!DOC/MAN/README*
DOC/HTML/*.html

View File

@@ -0,0 +1,127 @@
cmake_minimum_required(VERSION 3.0)
project(pigpio LANGUAGES C VERSION 0.71)
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
find_package(Threads REQUIRED)
find_package(RT REQUIRED)
option(BUILD_SHARED_LIBS "Create shared libraries" ON)
add_compile_options(-Wall)
# libpigpio.(so|a)
add_library(pigpio pigpio.c command.c custom.cext)
# libpigpiod_if.(so|a)
add_library(pigpiod_if pigpiod_if.c command.c)
# libpigpiod_if2.(so|a)
add_library(pigpiod_if2 pigpiod_if2.c command.c)
# x_pigpio
add_executable(x_pigpio x_pigpio.c)
target_link_libraries(x_pigpio pigpio RT::RT Threads::Threads)
# x_pigpiod_if
add_executable(x_pigpiod_if x_pigpiod_if.c)
target_link_libraries(x_pigpiod_if pigpiod_if RT::RT Threads::Threads)
# x_pigpiod_if2
add_executable(x_pigpiod_if2 x_pigpiod_if2.c)
target_link_libraries(x_pigpiod_if2 pigpiod_if2 RT::RT Threads::Threads)
# pigpiod
add_executable(pigpiod pigpiod.c)
target_link_libraries(pigpiod pigpio RT::RT Threads::Threads)
# pigs
add_executable(pigs pigs.c command.c)
target_link_libraries(pigs Threads::Threads)
# pig2vcd
add_executable(pig2vcd pig2vcd.c command.c)
target_link_libraries(pig2vcd Threads::Threads)
# Configure and install project
include (GenerateExportHeader)
include (CMakePackageConfigHelpers)
generate_export_header(${PROJECT_NAME})
install(TARGETS pigpio pigpiod_if pigpiod_if2 pig2vcd pigpiod pigs
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY AnyNewerVersion
)
export(EXPORT ${PROJECT_NAME}Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
NAMESPACE pigpio::
)
set(ConfigPackageLocation lib/cmake/${PROJECT_NAME})
install(EXPORT ${PROJECT_NAME}Targets
FILE
${PROJECT_NAME}Targets.cmake
NAMESPACE
pigpio::
DESTINATION
${ConfigPackageLocation}
)
install(
FILES
${CMAKE_CURRENT_LIST_DIR}/cmake/${PROJECT_NAME}Config.cmake
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION
${ConfigPackageLocation}
)
install(FILES pigpio.h pigpiod_if.h pigpiod_if2.h
DESTINATION include
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ
)
file(GLOB man_1_SRC "*.1")
install(FILES ${man_1_SRC}
DESTINATION man/man1
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ
)
file(GLOB man_3_SRC "*.3")
install(FILES ${man_3_SRC}
DESTINATION man/man3
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ
)
# Install python modules.
find_package(Python COMPONENTS Interpreter QUIET)
if(Python_FOUND)
configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/setup.py.in
${CMAKE_CURRENT_BINARY_DIR}/setup.py
)
install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py install)")
endif()
# package project
include (CPack)

View File

@@ -0,0 +1,58 @@
## Submitting a New Issue
If you are reporting a **bug** or defect, please provide the steps to reproduce the problem you are describing.
Ideally, provide a simple script that will reproduce the issue. Also provide a description of the hardware and
software types and versions used in your application/test environment.
Requests for a feature or **enhancement** to the library software will be treated at a lower priority due to the lack
of resources (contributors with skillset, knowledge of the library or time). Unless your request has wide support
from the community it will be treated at a low priority. If the repo's maintainer judges your request to be of value
then it will be labeled `enhancement`. If additional resources are required, it will be tagged with `help wanted`.
If you simply have a **question**, consult the SUPPORT.md document.
## Creating a Pull Request
Contributions are welcome. To save time it is best to have an open issue relating to what it is you want to contribute
and to discuss the prospects of getting your contribution accepted.
Your changes *must* pass the set of test files `x_*`. Please indicate that you have run the test scripts successfuly or attach
a screen shot of the output from the test scripts.
In addition, you *should* provide updated or additional scripts that at least test the 'happy' paths of your code changes. For
larger changes the additional test cases will be considered mandatory.
Beginning 2020, this repo will follow a dual branch model: `master` is the stable branch that people use in production. A second branch, `develop`, is the first branch to receive merges from bug fixes and new features. Only after we consider `develop` stable we merge it into the `master` branch and release the changes with a tagged version.
Adhering to the following process is the best way to get your work included in the project:
- Fork the project, clone your fork, and configure the remotes:
```
# Clone your fork of the repo into the current directory
git clone https://github.com/<your-username>/pigio.git
# Navigate to the newly cloned directory
cd pigpio
# Assign the original repo to a remote called "upstream"
git remote add upstream https://github.com/joan2937/pigpio.git
```
- If you cloned a while ago, get the latest changes from upstream:
```
git checkout develop
git pull upstream develop
```
- Create a new topic branch (off the develop branch) to contain your feature, change, or fix:
```
git checkout -b <topic-branch-name>
```
- Commit your changes.
- Locally merge (or rebase) the upstream dev branch into your topic branch:
```
git pull [--rebase] upstream develop
```
- Push your topic branch up to your fork:
```
git push origin <topic-branch-name>
```
- Open a Pull Request with a clear title and description. See [creating a pull request from a fork](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork).
Make sure the base branch drop down menu is selecting 'develop'.

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

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

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 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: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

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

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1015 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

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% }

View File

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

16
pigpio-master/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

View File

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

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()

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()

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()

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()

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>')

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

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()

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