From 678be33b538f485b389efd1a1eedd96d3a28e9d9 Mon Sep 17 00:00:00 2001 From: jon Date: Tue, 26 Jul 2022 05:05:23 +0100 Subject: [PATCH] Update to use new RGB888 pen type --- examples/galactic_unicorn/demo.cpp | 2 +- libraries/galactic_unicorn/galactic_unicorn.cpp | 8 ++++---- libraries/galactic_unicorn/galactic_unicorn.hpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/galactic_unicorn/demo.cpp b/examples/galactic_unicorn/demo.cpp index 29ca709d..f65b15e5 100644 --- a/examples/galactic_unicorn/demo.cpp +++ b/examples/galactic_unicorn/demo.cpp @@ -9,7 +9,7 @@ using namespace pimoroni; -PicoGraphics_PenRGB565 graphics(53, 11, nullptr); +PicoGraphics_PenRGB888 graphics(53, 11, nullptr); GalacticUnicorn galactic_unicorn; // HSV Conversion expects float inputs in the range of 0.00-1.00 for each channel diff --git a/libraries/galactic_unicorn/galactic_unicorn.cpp b/libraries/galactic_unicorn/galactic_unicorn.cpp index ba0a456d..9dda38b1 100644 --- a/libraries/galactic_unicorn/galactic_unicorn.cpp +++ b/libraries/galactic_unicorn/galactic_unicorn.cpp @@ -382,16 +382,16 @@ namespace pimoroni { } - void GalacticUnicorn::update(PicoGraphics_PenRGB565 &graphics) { + void GalacticUnicorn::update(PicoGraphics_PenRGB888 &graphics) { uint16_t *p = (uint16_t *)graphics.frame_buffer; for(size_t j = 0; j < 53 * 11; j++) { int x = j % 53; int y = j / 53; uint16_t col = __builtin_bswap16(*p); - uint8_t r = ((col & 0b1111100000000000) >> 11) << 3; - uint8_t g = ((col & 0b0000011111100000) >> 5) << 2; - uint8_t b = ((col & 0b0000000000011111) >> 0) << 3; + uint8_t r = (col & 0xff0000) >> 16; + uint8_t g = (col & 0x00ff00) >> 8; + uint8_t b = (col & 0x0000ff) >> 0; p++; r = (r * this->brightness) >> 8; diff --git a/libraries/galactic_unicorn/galactic_unicorn.hpp b/libraries/galactic_unicorn/galactic_unicorn.hpp index 3714c843..d4499cb0 100644 --- a/libraries/galactic_unicorn/galactic_unicorn.hpp +++ b/libraries/galactic_unicorn/galactic_unicorn.hpp @@ -64,7 +64,7 @@ namespace pimoroni { void clear(); - void update(PicoGraphics_PenRGB565 &graphics); + void update(PicoGraphics_PenRGB888 &graphics); void set_brightness(float value); float get_brightness();