Galactic Unicorn: Add support for P4 and P8 pen modes.

pull/697/head
Phil Howard 2023-02-27 20:00:17 +00:00
rodzic ad5e4cc10e
commit 5f3f14e5ce
1 zmienionych plików z 35 dodań i 16 usunięć

Wyświetl plik

@ -518,7 +518,7 @@ namespace pimoroni {
value = value < 0.0f ? 0.0f : value;
value = value > 1.0f ? 1.0f : value;
this->volume = floor(value * 255.0f);
this->synth.volume = this->volume * 255.0f;
this->synth.volume = this->volume * 255.0f;
}
float GalacticUnicorn::get_volume() {
@ -558,24 +558,43 @@ namespace pimoroni {
uint8_t b = (col & 0b0000000000011111) << 3;
p++;
set_pixel(x, y, r, g, b);
}
}
else if(graphics->pen_type == PicoGraphics::PEN_RGB332) {
uint8_t *p = (uint8_t *)graphics->frame_buffer;
for(size_t j = 0; j < 53 * 11; j++) {
int x = j % 53;
int y = j / 53;
uint8_t col = *p;
uint8_t r = (col & 0b11100000);
uint8_t g = (col & 0b00011100) << 3;
uint8_t b = (col & 0b00000011) << 6;
p++;
set_pixel(x, y, r, g, b);
}
}
else if(graphics->pen_type == PicoGraphics::PEN_RGB332) {
uint8_t *p = (uint8_t *)graphics->frame_buffer;
for(size_t j = 0; j < 53 * 11; j++) {
int x = j % 53;
int y = j / 53;
uint8_t col = *p;
uint8_t r = (col & 0b11100000);
uint8_t g = (col & 0b00011100) << 3;
uint8_t b = (col & 0b00000011) << 6;
p++;
set_pixel(x, y, r, g, b);
}
}
else if(graphics->pen_type == PicoGraphics::PEN_P8 || graphics->pen_type == PicoGraphics::PEN_P4) {
int offset = 0;
graphics->frame_convert(PicoGraphics::PEN_RGB888, [this, offset](void *data, size_t length) mutable {
uint32_t *p = (uint32_t *)data;
for(auto i = 0u; i < length / 4; i++) {
int x = offset % 53;
int y = offset / 53;
uint32_t col = *p;
uint8_t r = (col & 0xff0000) >> 16;
uint8_t g = (col & 0x00ff00) >> 8;
uint8_t b = (col & 0x0000ff) >> 0;
set_pixel(x, y, r, g, b);
offset++;
p++;
}
});
}
}
}