diff --git a/drivers/st7735/st7735.cpp b/drivers/st7735/st7735.cpp index ee306bb9..c257020d 100644 --- a/drivers/st7735/st7735.cpp +++ b/drivers/st7735/st7735.cpp @@ -166,7 +166,7 @@ namespace pimoroni { // Native 16-bit framebuffer update void ST7735::update(PicoGraphics *graphics) { if(graphics->pen_type == PicoGraphics::PEN_RGB565) { - command(reg::RAMWR, width * height * sizeof(uint16_t), (const char*)graphics->get_data()); + command(reg::RAMWR, width * height * sizeof(uint16_t), (const char*)graphics->frame_buffer); } else { command(reg::RAMWR); gpio_put(dc, 1); // data mode @@ -174,7 +174,7 @@ namespace pimoroni { uint16_t row_buf[width]; for(auto y = 0u; y < height; y++) { - graphics->get_data(y, &row_buf); + graphics->get_row_rgb565(&row_buf, width * y, width); // TODO: Add DMA->SPI / PIO while we prep the next row spi_write_blocking(spi, (const uint8_t*)row_buf, width * sizeof(uint16_t)); } diff --git a/drivers/st7789/st7789.cpp b/drivers/st7789/st7789.cpp index 4fbee353..be275016 100644 --- a/drivers/st7789/st7789.cpp +++ b/drivers/st7789/st7789.cpp @@ -248,7 +248,7 @@ namespace pimoroni { uint8_t cmd = reg::RAMWR; if(graphics->pen_type == PicoGraphics::PEN_RGB565) { // Display buffer is screen native - command(cmd, width * height * sizeof(uint16_t), (const char*)graphics->get_data()); + command(cmd, width * height * sizeof(uint16_t), (const char*)graphics->frame_buffer); } else if(spi) { // SPI Bus gpio_put(dc, 0); // command mode gpio_put(cs, 0); @@ -257,7 +257,7 @@ namespace pimoroni { uint16_t row_buf[width]; for(auto y = 0u; y < height; y++) { - graphics->get_data(y, &row_buf); + graphics->get_row_rgb565(&row_buf, width * y, width); // TODO: Add DMA->SPI / PIO while we prep the next row spi_write_blocking(spi, (const uint8_t*)row_buf, width * sizeof(uint16_t)); } @@ -271,7 +271,7 @@ namespace pimoroni { uint16_t row_buf[width]; for(auto y = 0u; y < height; y++) { - graphics->get_data(y, &row_buf); + graphics->get_row_rgb565(&row_buf, width * y, width); // TODO: Add DMA->SPI / PIO while we prep the next row write_blocking_parallel((const uint8_t*)row_buf, width * sizeof(uint16_t)); } diff --git a/libraries/pico_graphics/pico_graphics.cpp b/libraries/pico_graphics/pico_graphics.cpp index 263ffed7..a9b9ff30 100644 --- a/libraries/pico_graphics/pico_graphics.cpp +++ b/libraries/pico_graphics/pico_graphics.cpp @@ -8,7 +8,7 @@ namespace pimoroni { int PicoGraphics::reset_pen(uint8_t i) {return -1;}; int PicoGraphics::create_pen(uint8_t r, uint8_t g, uint8_t b) {return -1;}; void PicoGraphics::set_pixel(const Point &p) {}; - void PicoGraphics::palette_lookup(void *frame_buffer, void *result, uint offset, uint length) {}; + void PicoGraphics::get_row_rgb565(void *result, uint offset, uint length) {}; void PicoGraphics::set_dimensions(int width, int height) { bounds = clip = {0, 0, width, height}; @@ -18,14 +18,6 @@ namespace pimoroni { this->frame_buffer = frame_buffer; } - void *PicoGraphics::get_data() { - return frame_buffer; - } - - void PicoGraphics::get_data(uint y, void *row_buf) { - palette_lookup(frame_buffer, row_buf, y * bounds.w, bounds.w); - } - void PicoGraphics::set_font(const bitmap::font_t *font){ this->bitmap_font = font; this->hershey_font = nullptr; diff --git a/libraries/pico_graphics/pico_graphics.hpp b/libraries/pico_graphics/pico_graphics.hpp index b7246aa2..49b11142 100644 --- a/libraries/pico_graphics/pico_graphics.hpp +++ b/libraries/pico_graphics/pico_graphics.hpp @@ -109,7 +109,7 @@ namespace pimoroni { virtual int reset_pen(uint8_t i); virtual int create_pen(uint8_t r, uint8_t g, uint8_t b); virtual void set_pixel(const Point &p); - virtual void palette_lookup(void *frame_buffer, void *result, uint offset, uint length); + virtual void get_row_rgb565(void *result, uint offset, uint length); void set_font(const bitmap::font_t *font); void set_font(const hershey::font_t *font); @@ -119,7 +119,7 @@ namespace pimoroni { void set_framebuffer(void *frame_buffer); void *get_data(); - void get_data(uint y, void *row_buf); + void get_data(PenType type, uint y, void *row_buf); void set_clip(const Rect &r); void remove_clip(); @@ -192,7 +192,7 @@ namespace pimoroni { *f &= m; // clear bits *f |= b; // set value } - void palette_lookup(void *frame_buffer, void *result, uint offset, uint length) override { + void get_row_rgb565(void *result, uint offset, uint length) override { uint8_t *src = (uint8_t *)frame_buffer; uint16_t *dst = (uint16_t *)result; for(auto x = 0u; x < length; x++) { @@ -255,7 +255,7 @@ namespace pimoroni { uint8_t *buf = (uint8_t *)frame_buffer; buf[p.y * bounds.w + p.x] = color; } - void palette_lookup(void *frame_buffer, void *result, uint offset, uint length) override { + void get_row_rgb565(void *result, uint offset, uint length) override { uint8_t *src = (uint8_t *)frame_buffer; uint16_t *dst = (uint16_t *)result; for(auto x = 0u; x < length; x++) { @@ -295,7 +295,7 @@ namespace pimoroni { uint8_t *buf = (uint8_t *)frame_buffer; buf[p.y * bounds.w + p.x] = color; } - void palette_lookup(void *frame_buffer, void *result, uint offset, uint length) override { + void get_row_rgb565(void *result, uint offset, uint length) override { uint8_t *src = (uint8_t *)frame_buffer; uint16_t *dst = (uint16_t *)result; for(auto x = 0u; x < length; x++) {