format code
This commit is contained in:
parent
75989420bd
commit
01ca95d283
9 changed files with 235 additions and 186 deletions
|
|
@ -12,28 +12,20 @@ struct buffer_manager {
|
|||
free_buffers.push(2);
|
||||
}
|
||||
|
||||
int get_free_buffer() {
|
||||
return free_buffers.pop_blocking();
|
||||
}
|
||||
void put_free_buffer(int i) {
|
||||
free_buffers.push(i);
|
||||
}
|
||||
int get_free_buffer() { return free_buffers.pop_blocking(); }
|
||||
void put_free_buffer(int i) { free_buffers.push(i); }
|
||||
|
||||
int get_filled_buffer() {
|
||||
auto r = filled_buffers.pop_nonblocking();
|
||||
return r ? r.value() : no_buffer;
|
||||
}
|
||||
|
||||
void put_filled_buffer(int i) {
|
||||
filled_buffers.push(i);
|
||||
}
|
||||
void put_filled_buffer(int i) { filled_buffers.push(i); }
|
||||
|
||||
void request_exit() {
|
||||
filled_buffers.push(exit_request);
|
||||
}
|
||||
void request_exit() { filled_buffers.push(exit_request); }
|
||||
|
||||
private:
|
||||
thread_queue<int> free_buffers, filled_buffers;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace piomatter
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
namespace piomatter {
|
||||
|
||||
|
|
@ -27,30 +27,22 @@ int orientation_cw(int width, int height, int x, int y) {
|
|||
|
||||
namespace {
|
||||
template <typename Cb>
|
||||
void submap(std::vector<int> &result,
|
||||
int width, int height,
|
||||
int start_x, int dx, int count_x_in,
|
||||
int start_y, int dy, int count_y,
|
||||
int half_panel_height,
|
||||
const Cb &cb) {
|
||||
void submap(std::vector<int> &result, int width, int height, int start_x,
|
||||
int dx, int count_x_in, int start_y, int dy, int count_y,
|
||||
int half_panel_height, const Cb &cb) {
|
||||
|
||||
for (int y = start_y; count_y; count_y -= 2, y += dy) {
|
||||
for(int x = start_x, count_x = count_x_in; count_x--; x += dx )
|
||||
{
|
||||
for (int x = start_x, count_x = count_x_in; count_x--; x += dx) {
|
||||
result.push_back(cb(width, height, x, y));
|
||||
result.push_back(cb(width, height, x, y + dy * half_panel_height));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
template <typename Cb>
|
||||
matrix_map make_matrixmap(
|
||||
int width,
|
||||
int height,
|
||||
int n_addr_lines,
|
||||
bool serpentine,
|
||||
const Cb &cb) {
|
||||
matrix_map make_matrixmap(int width, int height, int n_addr_lines,
|
||||
bool serpentine, const Cb &cb) {
|
||||
|
||||
int panel_height = 2 << n_addr_lines;
|
||||
if (height % panel_height != 0) {
|
||||
|
|
@ -88,13 +80,19 @@ matrix_map make_matrixmap(
|
|||
|
||||
struct matrix_geometry {
|
||||
template <typename Cb>
|
||||
matrix_geometry(int pixels_across, int n_addr_lines, int n_planes, int width, int height, bool serpentine, const Cb &cb) : 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)} {
|
||||
matrix_geometry(int pixels_across, int n_addr_lines, int n_planes,
|
||||
int width, int height, bool serpentine, const Cb &cb)
|
||||
: 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)} {
|
||||
int pixels_down = 2 << n_addr_lines;
|
||||
if (map.size() != pixels_down * pixels_across) {
|
||||
throw std::range_error("map size does not match calculated pixel count");
|
||||
throw std::range_error(
|
||||
"map size does not match calculated pixel count");
|
||||
}
|
||||
}
|
||||
int pixels_across, n_addr_lines, n_planes, width, height;
|
||||
matrix_map map;
|
||||
};
|
||||
}
|
||||
} // namespace piomatter
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ struct adafruit_matrix_bonnet_pinout {
|
|||
static constexpr uint32_t post_addr_delay = 500;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace piomatter
|
||||
|
|
|
|||
|
|
@ -4,22 +4,24 @@
|
|||
|
||||
#include "hardware/pio.h"
|
||||
|
||||
#include "piomatter/pins.h"
|
||||
#include "piomatter/buffer_manager.h"
|
||||
#include "piomatter/render.h"
|
||||
#include "piomatter/matrixmap.h"
|
||||
#include "piomatter/pins.h"
|
||||
#include "piomatter/protomatter.pio.h"
|
||||
#include "piomatter/render.h"
|
||||
|
||||
namespace piomatter {
|
||||
|
||||
constexpr size_t MAX_XFER = 65532;
|
||||
|
||||
void pio_sm_xfer_data_large(PIO pio, int sm, int direction, size_t size, uint32_t *databuf) {
|
||||
void pio_sm_xfer_data_large(PIO pio, int sm, int direction, size_t size,
|
||||
uint32_t *databuf) {
|
||||
while (size) {
|
||||
size_t xfersize = std::min(size_t{MAX_XFER}, size);
|
||||
int r = pio_sm_xfer_data(pio, sm, direction, xfersize, databuf);
|
||||
if (r) {
|
||||
throw std::runtime_error("pio_sm_xfer_data (reboot may be required)");
|
||||
throw std::runtime_error(
|
||||
"pio_sm_xfer_data (reboot may be required)");
|
||||
}
|
||||
size -= xfersize;
|
||||
databuf += xfersize / sizeof(*databuf);
|
||||
|
|
@ -31,10 +33,14 @@ struct piomatter_base {
|
|||
virtual void show() = 0;
|
||||
};
|
||||
|
||||
template<class pinout=adafruit_matrix_bonnet_pinout, class colorspace=colorspace_rgb888>
|
||||
template <class pinout = adafruit_matrix_bonnet_pinout,
|
||||
class colorspace = colorspace_rgb888>
|
||||
struct piomatter : piomatter_base {
|
||||
using buffer_type = std::vector<uint32_t>;
|
||||
piomatter(std::span<typename colorspace::data_type const> framebuffer, const matrix_geometry &geometry) : framebuffer(framebuffer), geometry{geometry}, converter{}, blitter_thread{&piomatter::blit_thread, this} {
|
||||
piomatter(std::span<typename colorspace::data_type const> framebuffer,
|
||||
const matrix_geometry &geometry)
|
||||
: framebuffer(framebuffer), geometry{geometry}, converter{},
|
||||
blitter_thread{&piomatter::blit_thread, this} {
|
||||
if (geometry.n_addr_lines > std::size(pinout::PIN_ADDR)) {
|
||||
throw std::runtime_error("too many address lines requested");
|
||||
}
|
||||
|
|
@ -71,6 +77,7 @@ struct piomatter : piomatter_base {
|
|||
blitter_thread.join();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void program_init() {
|
||||
pio = pio0;
|
||||
|
|
@ -98,8 +105,10 @@ private:
|
|||
pio_sm_set_clkdiv(pio, sm, 1.0);
|
||||
|
||||
pio_sm_config c = pio_get_default_sm_config();
|
||||
sm_config_set_wrap(&c, offset + protomatter_wrap_target, offset + protomatter_wrap);
|
||||
sm_config_set_out_shift(&c, /* shift_right= */ false, /* auto_pull = */ true, 32);
|
||||
sm_config_set_wrap(&c, offset + protomatter_wrap_target,
|
||||
offset + protomatter_wrap);
|
||||
sm_config_set_out_shift(&c, /* shift_right= */ false,
|
||||
/* auto_pull = */ true, 32);
|
||||
sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX);
|
||||
sm_config_set_clkdiv(&c, 1.0);
|
||||
sm_config_set_out_pins(&c, 0, 28);
|
||||
|
|
@ -133,7 +142,8 @@ private:
|
|||
size_t datasize = 0;
|
||||
int old_buffer_idx = buffer_manager::no_buffer;
|
||||
int buffer_idx;
|
||||
while((buffer_idx = manager.get_filled_buffer()) != buffer_manager::exit_request) {
|
||||
while ((buffer_idx = manager.get_filled_buffer()) !=
|
||||
buffer_manager::exit_request) {
|
||||
if (buffer_idx != buffer_manager::no_buffer) {
|
||||
const auto &buffer = buffers[buffer_idx];
|
||||
databuf = &buffer[0];
|
||||
|
|
@ -144,7 +154,8 @@ private:
|
|||
old_buffer_idx = buffer_idx;
|
||||
}
|
||||
if (datasize) {
|
||||
pio_sm_xfer_data_large(pio, sm, PIO_DIR_TO_SM, datasize, (uint32_t*)databuf);
|
||||
pio_sm_xfer_data_large(pio, sm, PIO_DIR_TO_SM, datasize,
|
||||
(uint32_t *)databuf);
|
||||
} else {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
|
|
@ -161,4 +172,4 @@ private:
|
|||
std::thread blitter_thread;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace piomatter
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
const int protomatter_wrap = 4;
|
||||
const int protomatter_wrap_target = 0;
|
||||
const int protomatter_sideset_pin_count = 0;
|
||||
|
|
@ -46,4 +48,3 @@ const uint16_t protomatter[] = {
|
|||
0xa042, // nop
|
||||
0xa042, // nop
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include "matrixmap.h"
|
||||
#include <cassert>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "matrixmap.h"
|
||||
|
||||
namespace piomatter {
|
||||
|
||||
|
||||
constexpr unsigned DATA_OVERHEAD = 3;
|
||||
constexpr unsigned CLOCKS_PER_DATA = 2;
|
||||
constexpr unsigned DELAY_OVERHEAD = 5;
|
||||
|
|
@ -25,11 +24,13 @@ struct gamma_lut {
|
|||
}
|
||||
|
||||
unsigned convert(unsigned v) {
|
||||
if(v >= std::size(lut)) return 1023;
|
||||
if (v >= std::size(lut))
|
||||
return 1023;
|
||||
return lut[v];
|
||||
}
|
||||
|
||||
void convert_rgb888_packed_to_rgb10(std::vector<uint32_t> &result, std::span<const uint8_t> source) {
|
||||
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) {
|
||||
uint32_t r = source[i + 0] & 0xff;
|
||||
|
|
@ -39,8 +40,8 @@ struct gamma_lut {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void convert_rgb888_to_rgb10(std::vector<uint32_t> &result, std::span<const uint32_t> source) {
|
||||
void convert_rgb888_to_rgb10(std::vector<uint32_t> &result,
|
||||
std::span<const uint32_t> source) {
|
||||
result.resize(source.size());
|
||||
for (size_t i = 0; i < source.size(); i++) {
|
||||
uint32_t data = source[i];
|
||||
|
|
@ -51,8 +52,8 @@ struct gamma_lut {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void convert_rgb565_to_rgb10(std::vector<uint32_t> &result, std::span<const uint16_t> source) {
|
||||
void convert_rgb565_to_rgb10(std::vector<uint32_t> &result,
|
||||
std::span<const uint16_t> source) {
|
||||
result.resize(source.size());
|
||||
for (size_t i = 0; i < source.size(); i++) {
|
||||
uint32_t data = source[i];
|
||||
|
|
@ -75,7 +76,8 @@ struct colorspace_rgb565 {
|
|||
|
||||
colorspace_rgb565(float gamma = 2.2) : lut{gamma} {}
|
||||
gamma_lut lut;
|
||||
const std::span<const uint32_t> convert(std::span<const data_type> data_in) {
|
||||
const std::span<const uint32_t>
|
||||
convert(std::span<const data_type> data_in) {
|
||||
lut.convert_rgb565_to_rgb10(rgb10, data_in);
|
||||
return rgb10;
|
||||
}
|
||||
|
|
@ -87,7 +89,8 @@ struct colorspace_rgb888 {
|
|||
|
||||
colorspace_rgb888(float gamma = 2.2) : lut{gamma} {}
|
||||
gamma_lut lut;
|
||||
const std::span<const uint32_t> convert(std::span<const data_type> data_in) {
|
||||
const std::span<const uint32_t>
|
||||
convert(std::span<const data_type> data_in) {
|
||||
lut.convert_rgb888_to_rgb10(rgb10, data_in);
|
||||
return rgb10;
|
||||
}
|
||||
|
|
@ -99,7 +102,8 @@ struct colorspace_rgb888_packed {
|
|||
|
||||
colorspace_rgb888_packed(float gamma = 2.2) : lut{gamma} {}
|
||||
gamma_lut lut;
|
||||
const std::span<const uint32_t> convert(std::span<const data_type> data_in) {
|
||||
const std::span<const uint32_t>
|
||||
convert(std::span<const data_type> data_in) {
|
||||
lut.convert_rgb888_packed_to_rgb10(rgb10, data_in);
|
||||
return rgb10;
|
||||
}
|
||||
|
|
@ -109,21 +113,24 @@ struct colorspace_rgb888_packed {
|
|||
struct colorspace_rgb10 {
|
||||
using data_type = uint32_t;
|
||||
|
||||
const std::span<const uint32_t> convert(std::span<const data_type> data_in) {
|
||||
const std::span<const uint32_t>
|
||||
convert(std::span<const data_type> data_in) {
|
||||
return data_in;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Render a buffer in linear RGB10 format into a piomatter stream
|
||||
template <typename pinout>
|
||||
void protomatter_render_rgb10(std::vector<uint32_t> &result, const matrix_geometry &matrixmap, const uint32_t *pixels) {
|
||||
void protomatter_render_rgb10(std::vector<uint32_t> &result,
|
||||
const matrix_geometry &matrixmap,
|
||||
const uint32_t *pixels) {
|
||||
result.clear();
|
||||
|
||||
int data_count = 0;
|
||||
|
||||
auto do_delay = [&](uint32_t delay) {
|
||||
if (delay == 0) return;
|
||||
if (delay == 0)
|
||||
return;
|
||||
assert(delay < 1000000);
|
||||
assert(!data_count);
|
||||
result.push_back(command_delay | (delay ? delay - 1 : 0));
|
||||
|
|
@ -151,35 +158,49 @@ void protomatter_render_rgb10(std::vector<uint32_t> &result, const matrix_geomet
|
|||
|
||||
auto calc_addr_bits = [](int addr) {
|
||||
uint32_t data = 0;
|
||||
if(addr & 1) data |= (1 << pinout::PIN_ADDR[0]);
|
||||
if(addr & 2) data |= (1 << pinout::PIN_ADDR[1]);
|
||||
if(addr & 4) data |= (1 << pinout::PIN_ADDR[2]);
|
||||
if (addr & 1)
|
||||
data |= (1 << pinout::PIN_ADDR[0]);
|
||||
if (addr & 2)
|
||||
data |= (1 << pinout::PIN_ADDR[1]);
|
||||
if (addr & 4)
|
||||
data |= (1 << pinout::PIN_ADDR[2]);
|
||||
if constexpr (std::size(pinout::PIN_ADDR) >= 4) {
|
||||
if(addr & 8) data |= (1 << pinout::PIN_ADDR[3]);
|
||||
if (addr & 8)
|
||||
data |= (1 << pinout::PIN_ADDR[3]);
|
||||
}
|
||||
if constexpr (std::size(pinout::PIN_ADDR) >= 5) {
|
||||
if(addr & 16) data |= (1 << pinout::PIN_ADDR[4]);
|
||||
if (addr & 16)
|
||||
data |= (1 << pinout::PIN_ADDR[4]);
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
auto add_pixels = [&do_data, &result](uint32_t addr_bits, bool r0, bool g0, bool b0, bool r1, bool g1, bool b1, bool active) {
|
||||
uint32_t data = (active ? pinout::oe_active : pinout::oe_inactive) | addr_bits;
|
||||
if(r0) data |= (1 << pinout::PIN_RGB[0]);
|
||||
if(g0) data |= (1 << pinout::PIN_RGB[1]);
|
||||
if(b0) data |= (1 << pinout::PIN_RGB[2]);
|
||||
if(r1) data |= (1 << pinout::PIN_RGB[3]);
|
||||
if(g1) data |= (1 << pinout::PIN_RGB[4]);
|
||||
if(b1) data |= (1 << pinout::PIN_RGB[5]);
|
||||
auto add_pixels = [&do_data, &result](uint32_t addr_bits, bool r0, bool g0,
|
||||
bool b0, bool r1, bool g1, bool b1,
|
||||
bool active) {
|
||||
uint32_t data =
|
||||
(active ? pinout::oe_active : pinout::oe_inactive) | addr_bits;
|
||||
if (r0)
|
||||
data |= (1 << pinout::PIN_RGB[0]);
|
||||
if (g0)
|
||||
data |= (1 << pinout::PIN_RGB[1]);
|
||||
if (b0)
|
||||
data |= (1 << pinout::PIN_RGB[2]);
|
||||
if (r1)
|
||||
data |= (1 << pinout::PIN_RGB[3]);
|
||||
if (g1)
|
||||
data |= (1 << pinout::PIN_RGB[4]);
|
||||
if (b1)
|
||||
data |= (1 << pinout::PIN_RGB[5]);
|
||||
|
||||
do_data(data);
|
||||
do_data(data | pinout::clk_bit);
|
||||
};
|
||||
|
||||
|
||||
int last_bit = 0;
|
||||
int prev_addr = 7;
|
||||
// illuminate the right row for data in the shift register (the previous address)
|
||||
// illuminate the right row for data in the shift register (the previous
|
||||
// address)
|
||||
uint32_t addr_bits = calc_addr_bits(prev_addr);
|
||||
|
||||
const auto n_addr = 1u << matrixmap.n_addr_lines;
|
||||
|
|
@ -195,11 +216,11 @@ void protomatter_render_rgb10(std::vector<uint32_t> &result, const matrix_geomet
|
|||
uint32_t b = 1 << (0 + offset + bit);
|
||||
|
||||
// the shortest /OE we can do is one DATA_OVERHEAD...
|
||||
// TODO: should make sure desired duration of MSB is at least `pixels_across`
|
||||
// TODO: should make sure desired duration of MSB is at least
|
||||
// `pixels_across`
|
||||
uint32_t desired_duration = 1 << last_bit;
|
||||
last_bit = bit;
|
||||
|
||||
|
||||
prep_data(2 * pixels_across);
|
||||
auto mapiter = matrixmap.map.begin() + 2 * addr * pixels_across;
|
||||
for (int x = 0; x < pixels_across; x++) {
|
||||
|
|
@ -214,26 +235,32 @@ void protomatter_render_rgb10(std::vector<uint32_t> &result, const matrix_geomet
|
|||
auto g1 = pixel1 & g;
|
||||
auto b1 = pixel1 & b;
|
||||
|
||||
add_pixels(addr_bits, r0, g0, b0, r1, g1, b1, x < desired_duration);
|
||||
add_pixels(addr_bits, r0, g0, b0, r1, g1, b1,
|
||||
x < desired_duration);
|
||||
}
|
||||
|
||||
// hold /OE low until desired time has elapsed to illuminate the LAST line
|
||||
// hold /OE low until desired time has elapsed to illuminate the
|
||||
// LAST line
|
||||
int remain = desired_duration - pixels_across;
|
||||
if (remain > 0) {
|
||||
do_data_delay(addr_bits | pinout::oe_active, remain * CLOCKS_PER_DATA - DELAY_OVERHEAD);
|
||||
do_data_delay(addr_bits | pinout::oe_active,
|
||||
remain * CLOCKS_PER_DATA - DELAY_OVERHEAD);
|
||||
}
|
||||
|
||||
do_data_delay(addr_bits | pinout::oe_inactive, pinout::post_oe_delay);
|
||||
do_data_delay(addr_bits | pinout::oe_inactive | pinout::lat_bit, pinout::post_latch_delay);
|
||||
do_data_delay(addr_bits | pinout::oe_inactive,
|
||||
pinout::post_oe_delay);
|
||||
do_data_delay(addr_bits | pinout::oe_inactive | pinout::lat_bit,
|
||||
pinout::post_latch_delay);
|
||||
|
||||
// with oe inactive, set address bits to illuminate THIS line
|
||||
if (addr != prev_addr) {
|
||||
addr_bits = calc_addr_bits(addr);
|
||||
do_data_delay(addr_bits | pinout::oe_inactive, pinout::post_addr_delay);
|
||||
do_data_delay(addr_bits | pinout::oe_inactive,
|
||||
pinout::post_addr_delay);
|
||||
prev_addr = addr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace piomatter
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
#pragma once
|
||||
#include <optional>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <queue>
|
||||
|
||||
namespace piomatter {
|
||||
|
||||
template<class T>
|
||||
struct thread_queue {
|
||||
template <class T> struct thread_queue {
|
||||
thread_queue() : queue{}, mutex{}, cv{} {}
|
||||
|
||||
void push(T t) {
|
||||
|
|
@ -18,7 +17,9 @@ struct thread_queue {
|
|||
|
||||
std::optional<T> pop_nonblocking() {
|
||||
std::unique_lock<std::mutex> lock(mutex);
|
||||
if (queue.empty()) { return {}; }
|
||||
if (queue.empty()) {
|
||||
return {};
|
||||
}
|
||||
T val = queue.front();
|
||||
queue.pop();
|
||||
return val;
|
||||
|
|
@ -26,15 +27,18 @@ struct thread_queue {
|
|||
|
||||
T pop_blocking() {
|
||||
std::unique_lock<std::mutex> lock(mutex);
|
||||
while (queue.empty()) { cv.wait(lock); }
|
||||
while (queue.empty()) {
|
||||
cv.wait(lock);
|
||||
}
|
||||
T val = queue.front();
|
||||
queue.pop();
|
||||
return val;
|
||||
}
|
||||
|
||||
private:
|
||||
std::queue<T> queue;
|
||||
std::mutex mutex;
|
||||
std::condition_variable cv;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace piomatter
|
||||
|
|
|
|||
60
protodemo.c
60
protodemo.c
|
|
@ -1,10 +1,10 @@
|
|||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <vector>
|
||||
|
||||
#include "piomatter/piomatter.h"
|
||||
|
||||
|
|
@ -20,22 +20,38 @@
|
|||
constexpr int width = 64, height = 64;
|
||||
|
||||
uint32_t pixels[height][width] = {
|
||||
{_,w,_,_,r,r,_,_,_,g,_,_,b,b,b,_,c,c,_,_,y,_,y,_,m,m,m,_,w,w,w,_}, // 0
|
||||
{w,_,w,_,r,_,r,_,g,_,g,_,b,_,_,_,c,_,c,_,y,_,y,_,_,m,_,_,_,w,_,_}, // 1
|
||||
{w,w,w,_,r,_,r,_,g,g,g,_,b,b,_,_,c,c,_,_,y,_,y,_,_,m,_,_,_,w,_,_}, // 2
|
||||
{w,_,w,_,r,_,r,_,g,_,g,_,b,_,_,_,c,_,c,_,y,_,y,_,_,m,_,_,_,w,_,_}, // 3
|
||||
{w,_,w,_,r,r,_,_,g,_,g,_,b,_,_,_,c,_,c,_,_,y,_,_,m,m,m,_,_,w,_,_}, // 4
|
||||
{_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_}, // 5
|
||||
{_,c,_,_,y,y,_,_,_,m,_,_,r,r,r,_,g,g,_,_,b,_,b,_,w,w,w,_,c,c,c,_}, // 6
|
||||
{c,_,c,_,y,_,y,_,m,_,m,_,r,_,_,_,g,_,g,_,b,_,b,_,_,w,_,_,_,c,_,_}, // 7
|
||||
{c,c,c,_,y,_,y,_,m,m,m,_,r,r,_,_,g,g,_,_,b,_,b,_,_,w,_,_,_,c,_,_}, // 8
|
||||
{c,_,c,_,y,_,y,_,m,_,m,_,r,_,_,_,g,_,g,_,b,_,b,_,_,w,_,_,_,c,_,_}, // 9
|
||||
{c,_,c,_,y,y,_,_,m,_,m,_,r,_,_,_,g,_,g,_,_,b,_,_,w,w,w,_,_,c,_,_}, // 10
|
||||
{_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_}, // 11
|
||||
{r,y,g,c,b,m,r,y,g,c,b,m,r,y,g,c,b,m,r,y,g,c,b,m,r,y,g,c,b,m,r,g}, // 12
|
||||
{y,g,c,b,m,r,y,g,c,b,m,r,y,g,c,b,m,r,y,g,c,b,m,r,y,g,c,b,m,r,g,y}, // 13
|
||||
{g,c,b,m,r,y,g,c,b,m,r,y,g,c,b,m,r,y,g,c,b,m,r,y,g,c,b,m,r,g,c,b}, // 14
|
||||
{c,b,m,r,y,g,c,b,m,r,y,g,c,b,m,r,y,g,c,b,m,r,y,g,c,b,m,r,g,c,b,m}, // 15
|
||||
{_, w, _, _, r, r, _, _, _, g, _, _, b, b, b, _,
|
||||
c, c, _, _, y, _, y, _, m, m, m, _, w, w, w, _}, // 0
|
||||
{w, _, w, _, r, _, r, _, g, _, g, _, b, _, _, _,
|
||||
c, _, c, _, y, _, y, _, _, m, _, _, _, w, _, _}, // 1
|
||||
{w, w, w, _, r, _, r, _, g, g, g, _, b, b, _, _,
|
||||
c, c, _, _, y, _, y, _, _, m, _, _, _, w, _, _}, // 2
|
||||
{w, _, w, _, r, _, r, _, g, _, g, _, b, _, _, _,
|
||||
c, _, c, _, y, _, y, _, _, m, _, _, _, w, _, _}, // 3
|
||||
{w, _, w, _, r, r, _, _, g, _, g, _, b, _, _, _,
|
||||
c, _, c, _, _, y, _, _, m, m, m, _, _, w, _, _}, // 4
|
||||
{_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
|
||||
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _}, // 5
|
||||
{_, c, _, _, y, y, _, _, _, m, _, _, r, r, r, _,
|
||||
g, g, _, _, b, _, b, _, w, w, w, _, c, c, c, _}, // 6
|
||||
{c, _, c, _, y, _, y, _, m, _, m, _, r, _, _, _,
|
||||
g, _, g, _, b, _, b, _, _, w, _, _, _, c, _, _}, // 7
|
||||
{c, c, c, _, y, _, y, _, m, m, m, _, r, r, _, _,
|
||||
g, g, _, _, b, _, b, _, _, w, _, _, _, c, _, _}, // 8
|
||||
{c, _, c, _, y, _, y, _, m, _, m, _, r, _, _, _,
|
||||
g, _, g, _, b, _, b, _, _, w, _, _, _, c, _, _}, // 9
|
||||
{c, _, c, _, y, y, _, _, m, _, m, _, r, _, _, _,
|
||||
g, _, g, _, _, b, _, _, w, w, w, _, _, c, _, _}, // 10
|
||||
{_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
|
||||
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _}, // 11
|
||||
{r, y, g, c, b, m, r, y, g, c, b, m, r, y, g, c,
|
||||
b, m, r, y, g, c, b, m, r, y, g, c, b, m, r, g}, // 12
|
||||
{y, g, c, b, m, r, y, g, c, b, m, r, y, g, c, b,
|
||||
m, r, y, g, c, b, m, r, y, g, c, b, m, r, g, y}, // 13
|
||||
{g, c, b, m, r, y, g, c, b, m, r, y, g, c, b, m,
|
||||
r, y, g, c, b, m, r, y, g, c, b, m, r, g, c, b}, // 14
|
||||
{c, b, m, r, y, g, c, b, m, r, y, g, c, b, m, r,
|
||||
y, g, c, b, m, r, y, g, c, b, m, r, g, c, b, m}, // 15
|
||||
};
|
||||
#undef r
|
||||
#undef g
|
||||
|
|
@ -78,13 +94,13 @@ static uint64_t monotonicns64() {
|
|||
struct timespec tp;
|
||||
clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||
return tp.tv_sec * UINT64_C(1000000000) + tp.tv_nsec;
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n = argc > 1 ? atoi(argv[1]) : 0;
|
||||
|
||||
piomatter::matrix_geometry geometry(128, 4, 10, 64, 64, true, piomatter::orientation_normal);
|
||||
piomatter::matrix_geometry geometry(128, 4, 10, 64, 64, true,
|
||||
piomatter::orientation_normal);
|
||||
piomatter::piomatter p(std::span(&pixels[0][0], 64 * 64), geometry);
|
||||
|
||||
uint64_t start = monotonicns64();
|
||||
|
|
|
|||
Loading…
Reference in a new issue