Allow passing in the matrix map directly to a Geometry object
Some checks failed
Pip / build (ubuntu-24.04-arm, 3.11) (push) Has been cancelled
Pip / build (ubuntu-24.04-arm, 3.12) (push) Has been cancelled
Pip / build (ubuntu-24.04-arm, 3.13) (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Wheels / Build SDist (push) Has been cancelled
Wheels / Wheels on ubuntu-24.04-arm (push) Has been cancelled
Wheels / Upload release (push) Has been cancelled
Some checks failed
Pip / build (ubuntu-24.04-arm, 3.11) (push) Has been cancelled
Pip / build (ubuntu-24.04-arm, 3.12) (push) Has been cancelled
Pip / build (ubuntu-24.04-arm, 3.13) (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Wheels / Build SDist (push) Has been cancelled
Wheels / Wheels on ubuntu-24.04-arm (push) Has been cancelled
Wheels / Upload release (push) Has been cancelled
This commit is contained in:
parent
86cef28c18
commit
d120ecab66
2 changed files with 22 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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