From 486217f538f8690ecdf639e8486b45ec5a485375 Mon Sep 17 00:00:00 2001 From: Thomas Sommer Date: Tue, 11 Jan 2022 14:49:27 +0100 Subject: [PATCH] Update src --- src/modm/board/disco_f469ni/board_display.cpp | 6 +++--- src/modm/driver/color/tcs3414.hpp | 2 +- src/modm/driver/display/ili9341_impl.hpp | 20 +++++++++---------- src/modm/driver/display/parallel_tft_impl.hpp | 4 ++-- src/modm/driver/pwm/apa102.hpp | 12 +++++------ src/modm/driver/pwm/sk6812w.hpp | 10 +++++----- src/modm/driver/pwm/ws2812b.hpp | 6 +++--- .../ui/display/virtual_graphic_display.cpp | 4 ++-- src/modm/ui/led/module.md | 2 +- src/modm/ui/led/rgb.hpp | 16 +++++++-------- 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/modm/board/disco_f469ni/board_display.cpp b/src/modm/board/disco_f469ni/board_display.cpp index 664a544484..526bedf927 100644 --- a/src/modm/board/disco_f469ni/board_display.cpp +++ b/src/modm/board/disco_f469ni/board_display.cpp @@ -49,7 +49,7 @@ class DsiDisplay : public modm::ColorGraphicDisplay void clear() final { - std::fill(buffer, buffer + this->getBufferWidth()*this->getBufferHeight(), this->backgroundColor.color); + std::fill(buffer, buffer + this->getBufferWidth()*this->getBufferHeight(), this->backgroundColor.getValue()); } void @@ -62,14 +62,14 @@ class DsiDisplay : public modm::ColorGraphicDisplay setPixel(int16_t x, int16_t y) final { if (x < 0 or 800 <= x or y < 0 or 480 <= y) return; - buffer[y * 800 + x] = this->foregroundColor.color; + buffer[y * 800 + x] = this->foregroundColor.getValue(); } void clearPixel(int16_t x, int16_t y) final { if (x < 0 or 800 <= x or y < 0 or 480 <= y) return; - buffer[y * 800 + x] = this->backgroundColor.color; + buffer[y * 800 + x] = this->backgroundColor.getValue(); } modm::color::Rgb565 diff --git a/src/modm/driver/color/tcs3414.hpp b/src/modm/driver/color/tcs3414.hpp index c2fb3e6f85..7bd2d62e68 100644 --- a/src/modm/driver/color/tcs3414.hpp +++ b/src/modm/driver/color/tcs3414.hpp @@ -123,7 +123,7 @@ struct tcs3414 }; - using Rgb = color::RgbT; + using Rgb = color::Rgb161616; struct modm_packed Data diff --git a/src/modm/driver/display/ili9341_impl.hpp b/src/modm/driver/display/ili9341_impl.hpp index d44ce85c69..8f5a545239 100644 --- a/src/modm/driver/display/ili9341_impl.hpp +++ b/src/modm/driver/display/ili9341_impl.hpp @@ -202,7 +202,7 @@ void Ili9341::drawHorizontalLine( glcd::Point start, uint16_t length) { - uint16_t const pixelValue { modm::toBigEndian(foregroundColor.color) }; + uint16_t const pixelValue { modm::toBigEndian(foregroundColor.getValue()) }; auto minLength { std::min(std::size_t(length), BufferSize) }; uint16_t *buffer16 { reinterpret_cast(buffer) }; std::fill(buffer16, buffer16+minLength, pixelValue); @@ -223,7 +223,7 @@ void Ili9341::drawVerticalLine( glcd::Point start, uint16_t length) { - uint16_t const pixelValue { modm::toBigEndian(foregroundColor.color) }; + uint16_t const pixelValue { modm::toBigEndian(foregroundColor.getValue()) }; auto minLength { std::min(std::size_t(length), BufferSize) }; uint16_t *buffer16 { reinterpret_cast(buffer) }; std::fill(buffer16, buffer16+minLength, pixelValue); @@ -248,7 +248,7 @@ Ili9341::fillRectangle( auto const y { upperLeft.getY() }; std::size_t pixelCount { std::size_t(width) * std::size_t(height) }; - uint16_t const pixelValue { modm::toBigEndian(foregroundColor.color) }; + uint16_t const pixelValue { modm::toBigEndian(foregroundColor.getValue()) }; auto minLength { std::min(std::size_t(pixelCount), BufferSize) }; uint16_t *buffer16 { reinterpret_cast(buffer) }; std::fill(buffer16, buffer16+minLength, pixelValue); @@ -270,8 +270,8 @@ void Ili9341::fillCircle( glcd::Point center, uint16_t radius) { - uint8_t const setColor[] { uint8_t((foregroundColor.color >> 8) & 0xff), - uint8_t(foregroundColor.color & 0xff) }; + uint8_t const setColor[] { uint8_t((foregroundColor.getValue() >> 8) & 0xff), + uint8_t(foregroundColor.getValue() & 0xff) }; int16_t f = 1 - radius; int16_t ddF_x = 0; @@ -317,10 +317,10 @@ void Ili9341::drawImageRaw(glcd::Point upperLeft, uint16_t width, uint16_t height, modm::accessor::Flash data) { - uint8_t const setColor[] { uint8_t((foregroundColor.color >> 8) & 0xff), - uint8_t(foregroundColor.color & 0xff) }; - uint8_t const clearColor[] { uint8_t((backgroundColor.color >> 8) & 0xff), - uint8_t(backgroundColor.color & 0xff) }; + uint8_t const setColor[] { uint8_t((foregroundColor.getValue() >> 8) & 0xff), + uint8_t(foregroundColor.getValue() & 0xff) }; + uint8_t const clearColor[] { uint8_t((backgroundColor.getValue() >> 8) & 0xff), + uint8_t(backgroundColor.getValue() & 0xff) }; BatchHandle h(*this); @@ -392,7 +392,7 @@ Ili9341::setColoredPixel( int16_t x, int16_t y, color::Rgb565 const &color) { auto const pixelColor { color }; - uint8_t const setColor[] { uint8_t((pixelColor.color >> 8) & 0xff), uint8_t(pixelColor.color & 0xff) }; + uint8_t const setColor[] { uint8_t((pixelColor.getValue() >> 8) & 0xff), uint8_t(pixelColor.getValue() & 0xff) }; BatchHandle h(*this); diff --git a/src/modm/driver/display/parallel_tft_impl.hpp b/src/modm/driver/display/parallel_tft_impl.hpp index be3f5c6579..26afae8b56 100644 --- a/src/modm/driver/display/parallel_tft_impl.hpp +++ b/src/modm/driver/display/parallel_tft_impl.hpp @@ -110,7 +110,7 @@ modm::ParallelTft::clear() interface.writeIndex(0x0022); for (uint32_t i = 0; i < MAX_X * MAX_Y; i++) { - interface.writeData(backgroundColor.color); + interface.writeData(backgroundColor.getValue()); } } @@ -123,7 +123,7 @@ modm::ParallelTft::setPixel(int16_t x, int16_t y) } writeCursor(x, y); - interface.writeRegister(0x0022, foregroundColor.color); + interface.writeRegister(0x0022, foregroundColor.getValue()); } template diff --git a/src/modm/driver/pwm/apa102.hpp b/src/modm/driver/pwm/apa102.hpp index b9b5e79d32..31e7e4dea7 100644 --- a/src/modm/driver/pwm/apa102.hpp +++ b/src/modm/driver/pwm/apa102.hpp @@ -43,29 +43,29 @@ class Apa102 } bool - setColorBrightness(size_t index, const color::Rgb &color, uint8_t brightness) + setColorBrightness(size_t index, const color::Rgb888 &color, uint8_t brightness) { if (index >= LEDs) return false; - uint32_t value = (color.red << 24) | (color.green << 16) | - (color.blue << 8) | (brightness | 0xe0); + uint32_t value = (color.getRed() << 24) | (color.getGreen() << 16) | + (color.getBlue() << 8) | (brightness | 0xe0); reinterpret_cast(data)[1+index] = value; return true; } bool - setColor(size_t index, const color::Rgb &color) + setColor(size_t index, const color::Rgb888 &color) { if (index >= LEDs) return false; // read the brightness value and clear all colors uint32_t value = reinterpret_cast(data)[1+index] & 0xfful; // set all colors - value |= (color.red << 24) | (color.green << 16) | (color.blue << 8); + value |= (color.getRed() << 24) | (color.getGreen() << 16) | (color.getBlue() << 8); // write back entire value reinterpret_cast(data)[1+index] = value; return true; } - color::Rgb + color::Rgb888 getColor(size_t index) const { if (index >= LEDs) return {}; diff --git a/src/modm/driver/pwm/sk6812w.hpp b/src/modm/driver/pwm/sk6812w.hpp index 995e409c6f..a89219dafd 100644 --- a/src/modm/driver/pwm/sk6812w.hpp +++ b/src/modm/driver/pwm/sk6812w.hpp @@ -72,11 +72,11 @@ class Sk6812w } void - setColorBrightness(size_t index, const color::Rgb &color, uint8_t brightness) + setColorBrightness(size_t index, const color::Rgb888 &color, uint8_t brightness) { if (index >= LEDs) return; - const uint8_t colors[] = {color.green, color.red, color.blue, brightness}; + const uint8_t colors[] = {color.getGreen(), color.getRed(), color.getBlue(), brightness}; for (size_t ii = 0; ii < 4; ii++) { const uint32_t c = (spread(colors[ii]) << 12) | spread(colors[ii] >> 4); @@ -86,11 +86,11 @@ class Sk6812w } void - setColor(size_t index, const color::Rgb &color) + setColor(size_t index, const color::Rgb888 &color) { if (index >= LEDs) return; - const uint8_t colors[] = {color.green, color.red, color.blue}; + const uint8_t colors[] = {color.getGreen(), color.getRed(), color.getBlue()}; for (size_t ii = 0; ii < 3; ii++) { const uint32_t c = (spread(colors[ii]) << 12) | spread(colors[ii] >> 4); @@ -99,7 +99,7 @@ class Sk6812w } } - color::Rgb + color::Rgb888 getColor(size_t index) const { if (index >= LEDs) return {}; diff --git a/src/modm/driver/pwm/ws2812b.hpp b/src/modm/driver/pwm/ws2812b.hpp index 0f064f712d..59717b543c 100644 --- a/src/modm/driver/pwm/ws2812b.hpp +++ b/src/modm/driver/pwm/ws2812b.hpp @@ -72,11 +72,11 @@ class Ws2812b } void - setColor(size_t index, const color::Rgb &color) + setColor(size_t index, const color::Rgb888 &color) { if (index >= LEDs) return; - const uint8_t colors[3] = {color.green, color.red, color.blue}; + const uint8_t colors[3] = {color.getGreen(), color.getRed(), color.getBlue()}; for (size_t ii = 0; ii < 3; ii++) { const uint32_t c = (spread(colors[ii]) << 12) | spread(colors[ii] >> 4); @@ -85,7 +85,7 @@ class Ws2812b } } - color::Rgb + color::Rgb888 getColor(size_t index) const { if (index >= LEDs) return {}; diff --git a/src/modm/ui/display/virtual_graphic_display.cpp b/src/modm/ui/display/virtual_graphic_display.cpp index 936629c168..05915d14d2 100644 --- a/src/modm/ui/display/virtual_graphic_display.cpp +++ b/src/modm/ui/display/virtual_graphic_display.cpp @@ -31,9 +31,9 @@ void modm::VirtualGraphicDisplay::clear() { //TODO switch black , white - this->display->setColor(color::Rgb(0, 0, 0)); + this->display->setColor(color::Rgb888(0, 0, 0)); this->display->fillRectangle(this->leftUpper, width, height); - this->display->setColor(color::Rgb(255, 255, 255)); + this->display->setColor(color::Rgb888(255, 255, 255)); } void diff --git a/src/modm/ui/led/module.md b/src/modm/ui/led/module.md index 02efb86ade..7e00b9d646 100644 --- a/src/modm/ui/led/module.md +++ b/src/modm/ui/led/module.md @@ -188,7 +188,7 @@ modm::ui::Led leds[3] = // Group them together as one RGB LED modm::ui::RgbLed rgb(leds[1], leds[0], leds[2]); // animate to orange within 2 seconds -rgb.fadeTo(modm::ui::Rgb(95, 177, 147), 2000); +rgb.fadeTo(modm::ui::Rgb888(95, 177, 147), 2000); ``` diff --git a/src/modm/ui/led/rgb.hpp b/src/modm/ui/led/rgb.hpp index 4386e283b2..73d75bab42 100644 --- a/src/modm/ui/led/rgb.hpp +++ b/src/modm/ui/led/rgb.hpp @@ -35,14 +35,14 @@ class RgbLed Led& green; Led& blue; - ::modm::color::Rgb absolute; + ::modm::color::Rgb888 absolute; public: RgbLed(Led& red, Led& green, Led& blue): red(red), green(green), blue(blue) {} inline void - setColor(::modm::color::Rgb color) + setColor(::modm::color::Rgb888 color) { absolute = color; @@ -51,10 +51,10 @@ class RgbLed blue.setBrightness(color.blue); } - inline ::modm::color::Rgb + inline ::modm::color::Rgb888 getColor() { - return ::modm::color::Rgb( + return ::modm::color::Rgb888( red.getBrightness(), green.getBrightness(), blue.getBrightness()); } @@ -65,13 +65,13 @@ class RgbLed } inline void - fadeTo(::modm::color::Rgb color, uint16_t time) + fadeTo(::modm::color::Rgb888 color, uint16_t time) { absolute = color; - red.fadeTo(absolute.red, time); - green.fadeTo(absolute.green, time); - blue.fadeTo(absolute.blue, time); + red.fadeTo(absolute.getRed(), time); + green.fadeTo(absolute.getGreen(), time); + blue.fadeTo(absolute.getBlue(), time); } /// should be called every 1ms or more.