diff --git a/libraries/pico_graphics/pico_graphics.hpp b/libraries/pico_graphics/pico_graphics.hpp index 5ee9ea9e..68a2ddd8 100644 --- a/libraries/pico_graphics/pico_graphics.hpp +++ b/libraries/pico_graphics/pico_graphics.hpp @@ -40,6 +40,10 @@ namespace pimoroni { r((__builtin_bswap16(c) & 0b1111100000000000) >> 8), g((__builtin_bswap16(c) & 0b0000011111100000) >> 3), b((__builtin_bswap16(c) & 0b0000000000011111) << 3) {} + constexpr RGB(uint c) : + r((c >> 16) & 0xff), + g((c >> 8) & 0xff), + b(c & 0xff) {} constexpr RGB(int16_t r, int16_t g, int16_t b) : r(r), g(g), b(b) {} constexpr RGB operator+ (const RGB& c) const {return RGB(r + c.r, g + c.g, b + c.b);} @@ -539,8 +543,7 @@ namespace pimoroni { bool cache_built = false; std::array candidates; - RGB src_color; - RGB565 color; + uint color; IDirectDisplayDriver &driver; PicoGraphics_PenInky7(uint16_t width, uint16_t height, IDirectDisplayDriver &direct_display_driver); diff --git a/libraries/pico_graphics/pico_graphics_pen_inky7.cpp b/libraries/pico_graphics/pico_graphics_pen_inky7.cpp index 37891599..821a4538 100644 --- a/libraries/pico_graphics/pico_graphics_pen_inky7.cpp +++ b/libraries/pico_graphics/pico_graphics_pen_inky7.cpp @@ -7,15 +7,20 @@ namespace pimoroni { this->pen_type = PEN_INKY7; } void PicoGraphics_PenInky7::set_pen(uint c) { - color = c & 0x7; + color = c; } void PicoGraphics_PenInky7::set_pen(uint8_t r, uint8_t g, uint8_t b) { + color = RGB(r, g, b).to_rgb888() | 0x010101; } int PicoGraphics_PenInky7::create_pen(uint8_t r, uint8_t g, uint8_t b) { - return 0; + return RGB(r, g, b).to_rgb888() | 0x010101; } void PicoGraphics_PenInky7::set_pixel(const Point &p) { - driver.write_pixel(p, color); + if ((color & 0x010101) == 0x010101) { + set_pixel_dither(p, RGB(color)); + } else { + driver.write_pixel(p, color & 0x07); + } } void PicoGraphics_PenInky7::set_pixel_span(const Point &p, uint l) { driver.write_pixel_span(p, l, color);