Hub75: Add support for alternate pen types.

pull/1064/head
Phil Howard 2025-02-04 22:11:31 +00:00
rodzic b3d7bd497d
commit a8f6b48fbf
2 zmienionych plików z 92 dodań i 64 usunięć

Wyświetl plik

@ -277,11 +277,11 @@ void Hub75::dma_complete() {
}
}
void Hub75::update(PicoGraphics *graphics) {
if(graphics->pen_type == PicoGraphics::PEN_RGB888) {
uint8_t *p = (uint8_t *)graphics->frame_buffer;
if(graphics->bounds.w == int32_t(width / 2) && graphics->bounds.h == int32_t(height * 2)) {
for(int y = 0; y < graphics->bounds.h; y++) {
void Hub75::copy_to_back_buffer(void *data, size_t len, int start_x, int start_y, int g_width, int g_height) {
uint8_t *p = (uint8_t *)data;
if(g_width == int32_t(width / 2) && g_height == int32_t(height * 2)) {
for(int y = start_y; y < g_height; y++) {
int offsety = 0;
int sy = y;
int basex = 0;
@ -308,7 +308,7 @@ void Hub75::update(PicoGraphics *graphics) {
offsety *= sy;
}
for(int x = 0; x < graphics->bounds.w; x++) {
for(int x = start_x; x < g_width; x++) {
int sx = x;
uint8_t b = *p++;
uint8_t g = *p++;
@ -326,11 +326,17 @@ void Hub75::update(PicoGraphics *graphics) {
// Skip the empty byte in out 32-bit aligned 24-bit colour.
p++;
len -= 4;
if(len == 0) {
return;
}
}
}
} else {
for(uint y = 0; y < height; y++) {
for(uint x = 0; x < width; x++) {
for(uint y = start_y; y < height; y++) {
for(uint x = start_x; x < width; x++) {
int offset = 0;
int sy = y;
int sx = x;
@ -356,9 +362,30 @@ void Hub75::update(PicoGraphics *graphics) {
// Skip the empty byte in out 32-bit aligned 24-bit colour.
p++;
len -= 4;
if(len == 0) {
return;
}
}
}
}
}
void Hub75::update(PicoGraphics *graphics) {
if(graphics->pen_type == PicoGraphics::PEN_RGB888) {
copy_to_back_buffer(graphics->frame_buffer, width * height * sizeof(RGB888), 0, 0, graphics->bounds.w, graphics->bounds.h);
} else {
unsigned int offset = 0;
graphics->frame_convert(PicoGraphics::PEN_RGB888, [this, &offset, &graphics](void *data, size_t length) {
if (length > 0) {
int offset_y = offset / graphics->bounds.w;
int offset_x = offset - (offset_y * graphics->bounds.w);
copy_to_back_buffer(data, length, offset_x, offset_y, graphics->bounds.w, graphics->bounds.h);
offset += length / sizeof(RGB888);
}
});
}
}
}

Wyświetl plik

@ -135,6 +135,7 @@ class Hub75 {
void set_color(uint x, uint y, Pixel c);
void set_pixel(uint x, uint y, uint8_t r, uint8_t g, uint8_t b);
void copy_to_back_buffer(void *data, size_t len, int start_x, int start_y, int g_width, int g_height);
void display_update();
void clear();
void start(irq_handler_t handler);