Compare commits
2 commits
419f3f7eb7
...
d120ecab66
| Author | SHA1 | Date | |
|---|---|---|---|
| d120ecab66 | |||
| 86cef28c18 |
5 changed files with 47 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,4 +1,3 @@
|
|||
/*.pio.h
|
||||
protodemo
|
||||
/build
|
||||
*.egg-info
|
||||
|
|
|
|||
4
setup.py
4
setup.py
|
|
@ -11,7 +11,7 @@ __version__ = get_version()
|
|||
# say from a submodule.
|
||||
|
||||
ext_modules = [
|
||||
Pybind11Extension("adafruit_blinka_raspberry_pi5_piomatter",
|
||||
Pybind11Extension("adafruit_blinka_raspberry_pi5_piomatter._piomatter",
|
||||
["src/pymain.cpp", "src/piolib/piolib.c", "src/piolib/pio_rp1.c"],
|
||||
define_macros = [('VERSION_INFO', __version__)],
|
||||
include_dirs = ['./src/include', './src/piolib/include'],
|
||||
|
|
@ -33,6 +33,8 @@ setup(
|
|||
cmdclass={"build_ext": build_ext},
|
||||
zip_safe=False,
|
||||
python_requires=">=3.11",
|
||||
packages=['adafruit_blinka_raspberry_pi5_piomatter'],
|
||||
package_dir={'adafruit_blinka_raspberry_pi5_piomatter': 'src/adafruit_blinka_raspberry_pi5_piomatter'},
|
||||
extras_require={
|
||||
'docs': ["sphinx", "sphinx-rtd-theme", "sphinxcontrib-jquery"],
|
||||
},
|
||||
|
|
|
|||
21
src/adafruit_blinka_raspberry_pi5_piomatter/__init__.py
Normal file
21
src/adafruit_blinka_raspberry_pi5_piomatter/__init__.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
from ._piomatter import (
|
||||
AdafruitMatrixBonnetRGB565,
|
||||
AdafruitMatrixBonnetRGB888,
|
||||
AdafruitMatrixBonnetRGB888Packed,
|
||||
Colorspace,
|
||||
Geometry,
|
||||
Orientation,
|
||||
Pinout,
|
||||
PioMatter,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
'AdafruitMatrixBonnetRGB565',
|
||||
'AdafruitMatrixBonnetRGB888',
|
||||
'AdafruitMatrixBonnetRGB888Packed',
|
||||
'Colorspace',
|
||||
'Geometry',
|
||||
'Orientation',
|
||||
'Pinout',
|
||||
'PioMatter',
|
||||
]
|
||||
|
|
@ -84,16 +84,21 @@ struct matrix_geometry {
|
|||
template <typename Cb>
|
||||
matrix_geometry(size_t pixels_across, size_t n_addr_lines, int n_planes,
|
||||
size_t width, size_t height, bool serpentine, const Cb &cb)
|
||||
: matrix_geometry(
|
||||
pixels_across, n_addr_lines, n_planes, width, height,
|
||||
make_matrixmap(width, height, n_addr_lines, serpentine, cb)) {}
|
||||
|
||||
matrix_geometry(size_t pixels_across, size_t n_addr_lines, int n_planes,
|
||||
size_t width, size_t height, matrix_map map)
|
||||
: pixels_across(pixels_across), n_addr_lines(n_addr_lines),
|
||||
n_planes(n_planes), width(width),
|
||||
height(height), map{make_matrixmap(width, height, n_addr_lines,
|
||||
serpentine, cb)} {
|
||||
n_planes(n_planes), width(width), height(height), map(map) {
|
||||
size_t pixels_down = 2u << n_addr_lines;
|
||||
if (map.size() != pixels_down * pixels_across) {
|
||||
throw std::range_error(
|
||||
"map size does not match calculated pixel count");
|
||||
}
|
||||
}
|
||||
|
||||
size_t pixels_across, n_addr_lines;
|
||||
int n_planes;
|
||||
size_t width, height;
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ make_piomatter(Colorspace c, Pinout p, py::buffer buffer,
|
|||
}
|
||||
} // namespace
|
||||
|
||||
PYBIND11_MODULE(adafruit_blinka_raspberry_pi5_piomatter, m) {
|
||||
PYBIND11_MODULE(_piomatter, m) {
|
||||
py::options options;
|
||||
options.enable_enum_members_docstring();
|
||||
options.enable_function_signatures();
|
||||
|
|
@ -209,6 +209,20 @@ The default, 10, is the maximum value.
|
|||
py::arg("serpentine") = true,
|
||||
py::arg("rotation") = piomatter::orientation::normal,
|
||||
py::arg("n_planes") = 10u)
|
||||
.def(py::init([](size_t width, size_t height, size_t n_addr_lines,
|
||||
piomatter::matrix_map map, size_t n_planes) {
|
||||
size_t n_lines = 2 << n_addr_lines;
|
||||
size_t pixels_across = width * height / n_lines;
|
||||
for (auto el : map) {
|
||||
if ((size_t)el >= width * height) {
|
||||
throw std::out_of_range("Map element out of range");
|
||||
}
|
||||
}
|
||||
return piomatter::matrix_geometry(
|
||||
pixels_across, n_addr_lines, n_planes, width, height, map);
|
||||
}),
|
||||
py::arg("width"), py::arg("height"), py::arg("n_addr_lines"),
|
||||
py::arg("map"), py::arg("n_planes") = 10u)
|
||||
.def_readonly("width", &piomatter::matrix_geometry::width)
|
||||
.def_readonly("height", &piomatter::matrix_geometry::height);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue