it's working!!!1
This commit is contained in:
parent
895a5e5458
commit
e55647d8f7
3 changed files with 16 additions and 10 deletions
|
|
@ -1,9 +1,11 @@
|
|||
import pathlib
|
||||
|
||||
import adafruit_raspberry_pi5_piomatter
|
||||
import numpy as np
|
||||
import PIL.Image as Image
|
||||
|
||||
g = adafruit_raspberry_pi5_piomatter.Geometry(64, 64, 4, rotation=adafruit_raspberry_pi5_piomatter.Orientation.Normal)
|
||||
arr = np.asarray(Image.open("blinka64x64.png"))
|
||||
arr = np.asarray(Image.open(pathlib.Path(__file__).parent / "blinka64x64.png"))
|
||||
m = adafruit_raspberry_pi5_piomatter.AdafruitMatrixBonnetRGB888Packed(arr, g)
|
||||
m.show()
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ matrix_map make_matrixmap(size_t width, size_t height, size_t n_addr_lines,
|
|||
|
||||
struct matrix_geometry {
|
||||
template <typename Cb>
|
||||
matrix_geometry(size_t pixels_across, size_t n_addr_lines, size_t n_planes,
|
||||
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)
|
||||
: pixels_across(pixels_across), n_addr_lines(n_addr_lines),
|
||||
n_planes(n_planes), width(width),
|
||||
|
|
@ -94,7 +94,9 @@ struct matrix_geometry {
|
|||
"map size does not match calculated pixel count");
|
||||
}
|
||||
}
|
||||
size_t pixels_across, n_addr_lines, n_planes, width, height;
|
||||
size_t pixels_across, n_addr_lines;
|
||||
int n_planes;
|
||||
size_t width, height;
|
||||
matrix_map map;
|
||||
};
|
||||
} // namespace piomatter
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ struct gamma_lut {
|
|||
void convert_rgb888_packed_to_rgb10(std::vector<uint32_t> &result,
|
||||
std::span<const uint8_t> source) {
|
||||
result.resize(source.size() / 3);
|
||||
for (size_t i = 0; i < source.size(); i += 3) {
|
||||
for (size_t i = 0, j = 0; i < source.size(); i += 3) {
|
||||
uint32_t r = source[i + 0] & 0xff;
|
||||
uint32_t g = source[i + 1] & 0xff;
|
||||
uint32_t b = source[i + 2] & 0xff;
|
||||
result[i] = (convert(r) << 20) | (convert(g) << 10) | convert(b);
|
||||
result[j++] = (convert(r) << 20) | (convert(g) << 10) | convert(b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -210,17 +210,19 @@ void protomatter_render_rgb10(std::vector<uint32_t> &result,
|
|||
// illuminate the right row for data in the shift register (the previous
|
||||
// address)
|
||||
|
||||
const auto n_addr = 1u << matrixmap.n_addr_lines;
|
||||
const auto n_planes = matrixmap.n_planes;
|
||||
constexpr auto n_bits = 10u;
|
||||
const size_t n_addr = 1u << matrixmap.n_addr_lines;
|
||||
const int n_planes = matrixmap.n_planes;
|
||||
constexpr size_t n_bits = 10u;
|
||||
unsigned offset = n_bits - n_planes;
|
||||
const auto pixels_across = matrixmap.pixels_across;
|
||||
const size_t pixels_across = matrixmap.pixels_across;
|
||||
|
||||
size_t prev_addr = n_addr - 1;
|
||||
uint32_t addr_bits = calc_addr_bits(prev_addr);
|
||||
|
||||
for (size_t addr = 0; addr < n_addr; addr++) {
|
||||
for (size_t bit = n_planes - 1; bit >= 0; bit--) {
|
||||
// printf("addr=%zu/%zu\n", addr, n_addr);
|
||||
for (int bit = n_planes - 1; bit >= 0; bit--) {
|
||||
// printf("bit=%d/%d\n", bit, n_planes);
|
||||
uint32_t r = 1 << (20 + offset + bit);
|
||||
uint32_t g = 1 << (10 + offset + bit);
|
||||
uint32_t b = 1 << (0 + offset + bit);
|
||||
|
|
|
|||
Loading…
Reference in a new issue