Skip to content

Commit

Permalink
Update src
Browse files Browse the repository at this point in the history
  • Loading branch information
TomSaw committed Jan 11, 2022
1 parent 39412c6 commit 486217f
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 41 deletions.
6 changes: 3 additions & 3 deletions src/modm/board/disco_f469ni/board_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/modm/driver/color/tcs3414.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ struct tcs3414
};


using Rgb = color::RgbT<uint16_t>;
using Rgb = color::Rgb161616;

struct modm_packed
Data
Expand Down
20 changes: 10 additions & 10 deletions src/modm/driver/display/ili9341_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void
Ili9341<Interface, Reset, Backlight, BufferSize>::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<uint16_t *>(buffer) };
std::fill(buffer16, buffer16+minLength, pixelValue);
Expand All @@ -223,7 +223,7 @@ void
Ili9341<Interface, Reset, Backlight, BufferSize>::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<uint16_t *>(buffer) };
std::fill(buffer16, buffer16+minLength, pixelValue);
Expand All @@ -248,7 +248,7 @@ Ili9341<Interface, Reset, Backlight, BufferSize>::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<uint16_t *>(buffer) };
std::fill(buffer16, buffer16+minLength, pixelValue);
Expand All @@ -270,8 +270,8 @@ void
Ili9341<Interface, Reset, Backlight, BufferSize>::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;
Expand Down Expand Up @@ -317,10 +317,10 @@ void
Ili9341<Interface, Reset, Backlight, BufferSize>::drawImageRaw(glcd::Point upperLeft,
uint16_t width, uint16_t height, modm::accessor::Flash<uint8_t> 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);

Expand Down Expand Up @@ -392,7 +392,7 @@ Ili9341<Interface, Reset, Backlight, BufferSize>::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);

Expand Down
4 changes: 2 additions & 2 deletions src/modm/driver/display/parallel_tft_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ modm::ParallelTft<INTERFACE>::clear()
interface.writeIndex(0x0022);
for (uint32_t i = 0; i < MAX_X * MAX_Y; i++)
{
interface.writeData(backgroundColor.color);
interface.writeData(backgroundColor.getValue());
}
}

Expand All @@ -123,7 +123,7 @@ modm::ParallelTft<INTERFACE>::setPixel(int16_t x, int16_t y)
}

writeCursor(x, y);
interface.writeRegister(0x0022, foregroundColor.color);
interface.writeRegister(0x0022, foregroundColor.getValue());
}

template <typename INTERFACE>
Expand Down
12 changes: 6 additions & 6 deletions src/modm/driver/pwm/apa102.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t*>(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<const uint32_t*>(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<uint32_t*>(data)[1+index] = value;
return true;
}

color::Rgb
color::Rgb888
getColor(size_t index) const
{
if (index >= LEDs) return {};
Expand Down
10 changes: 5 additions & 5 deletions src/modm/driver/pwm/sk6812w.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -99,7 +99,7 @@ class Sk6812w
}
}

color::Rgb
color::Rgb888
getColor(size_t index) const
{
if (index >= LEDs) return {};
Expand Down
6 changes: 3 additions & 3 deletions src/modm/driver/pwm/ws2812b.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -85,7 +85,7 @@ class Ws2812b
}
}

color::Rgb
color::Rgb888
getColor(size_t index) const
{
if (index >= LEDs) return {};
Expand Down
4 changes: 2 additions & 2 deletions src/modm/ui/display/virtual_graphic_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/modm/ui/led/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```


Expand Down
16 changes: 8 additions & 8 deletions src/modm/ui/led/rgb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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());
}

Expand All @@ -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.
Expand Down

0 comments on commit 486217f

Please sign in to comment.