Skip to content

Commit

Permalink
Basic support for FillPatterns
Browse files Browse the repository at this point in the history
  • Loading branch information
TomSaw committed Aug 2, 2021
1 parent 60c8450 commit 8d11b57
Show file tree
Hide file tree
Showing 23 changed files with 611 additions and 215 deletions.
127 changes: 78 additions & 49 deletions src/modm/driver/display/ili9341.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
#include <modm/architecture/interface/register.hpp>
#include <modm/platform/gpio/base.hpp>
#include <modm/processing/resumable.hpp>

#include <modm/ui/graphic/display.hpp>
#include <modm/ui/graphic/buffer.hpp>
#include <modm/ui/graphic/buffer_bool.hpp>
#include <modm/ui/graphic/display.hpp>
// #include <modm/ui/graphic/painter_remote.hpp>

#include "ili9341_interface_parallel.hpp"
Expand All @@ -31,14 +30,13 @@ namespace modm
{

/// @ingroup modm_driver_ili9341
template<class Interface, class Reset, class RB = Resolution<32, 32>>
class Ili9341
: public Interface,
// : public RemotePainter<Resolution<320, 240>, Interface>,
public Display<color::Rgb565<true>, Resolution<320, 240>, true>,
public FlashPainter<true>
template<class Interface, class Reset, size_t BC = 1024>
class Ili9341 : public Interface,
// : public RemotePainter<Resolution<320, 240>, Interface>,
public Display<color::Rgb565<true>, Resolution<320, 240>, true>,
public FlashPainter<true>
{
static_assert(RB::H % 8 == 0, "Height of BufferResolution must be multiple of 8");
static_assert(BC >= 128, "Buffer for conversion requires a reasonable minimum size.");

using Toggle = ili9341_register::Toggle;
using ReadWrite = ili9341_register::ReadWrite;
Expand All @@ -49,10 +47,12 @@ class Ili9341
using colorType = color::Rgb565<true>;

template<typename... Args>
Ili9341(Args &&...args) :
Interface(std::forward<Args>(args)...),
Display<colorType, Resolution<320, 240>, true>(color::html::White)
{ Reset::setOutput(modm::Gpio::High); }
Ili9341(Args &&...args)
: Interface(std::forward<Args>(args)...),
Display<colorType, Resolution<320, 240>, true>(color::html::White)
{
Reset::setOutput(modm::Gpio::High);
}

~Ili9341(){};

Expand Down Expand Up @@ -95,53 +95,79 @@ class Ili9341
modm::ResumableResult<void>
scrollTo(uint16_t row);

// Write equal colored buffer via BufferInterface
// Write from Pattern (compiletime poly)
template<typename Pattern>
modm::ResumableResult<void>
drawBuffer(BufferInterface<colorType> *buffer,
Point origin = {0, 0});
writePattern(Section section, Pattern generator);

// Write monochrome buffer via BufferInterface
// Write equal colored Buffer (compiletime poly)
template<typename R_, class Painter_>
modm::ResumableResult<void>
drawBuffer(BufferInterface<bool> *buffer,
Point origin = {0, 0});
writeBuffer(const Buffer<colorType, R_, Painter_> &buffer, Point origin = {0, 0});

// Write equal colored buffer
// Write equal colored BufferInterface (runtime poly)
modm::ResumableResult<void>
writeBuffer(BufferInterface<colorType> *buffer, Point origin = {0, 0});

// Write different colored Buffer (compiletime poly)
template<typename C_, typename R_, class Painter_>
modm::ResumableResult<void>
writeBuffer(const Buffer<C_, R_, Painter_> &buffer, Point origin = {0, 0});

// Write monochrome Buffer (compiletime poly)
template<typename R_, class Painter_>
modm::ResumableResult<void>
drawBuffer(const Buffer<colorType, R_, Painter_> &buffer, Point origin = {0, 0});
writeBuffer(const Buffer<bool, R_, Painter_> &buffer, Point origin = {0, 0});

// Write different colored buffer
template<class C_, typename R_, class Painter_>
// Write monochrome BufferInterface (runtime poly)
modm::ResumableResult<void>
drawBuffer(const Buffer<C_, R_, Painter_> &buffer, Point origin = {0, 0});
writeBuffer(BufferInterface<bool> *buffer, Point origin = {0, 0});

// Write monochrome Flash (runtime poly)
modm::ResumableResult<void>
drawFlash(modm::accessor::Flash<uint8_t> data, uint16_t width, uint16_t height, Point originorigin = {0, 0}) final;
writeFlash(modm::accessor::Flash<uint8_t> data, uint16_t width, uint16_t height,
Point originorigin = {0, 0}) final;

// Clear whole screen with color
modm::ResumableResult<void>
clear(colorType color = html::Black);

// FIXME Fix inheritance on RemotePainter and move all of draw(..) there
modm::ResumableResult<void> draw(Point point);
modm::ResumableResult<void> draw(Line line);
modm::ResumableResult<void> draw(Rectangle rectangle, Style style = Style::Outline);
modm::ResumableResult<void> draw(Rectangle rectangle, uint16_t radius, Style style = Style::Outline);
modm::ResumableResult<void> draw(Circle circle, Style style = Style::Outline);
modm::ResumableResult<void> draw(Ellipse ellipse, Style style = Style::Outline);

modm::ResumableResult<void>
draw(Point point);
modm::ResumableResult<void>
draw(Line line);
modm::ResumableResult<void>
draw(Rectangle rectangle, Style style = Style::Outline);
modm::ResumableResult<void>
draw(Rectangle rectangle, uint16_t radius, Style style = Style::Outline);
modm::ResumableResult<void>
draw(Circle circle, Style style = Style::Outline);
modm::ResumableResult<void>
draw(Ellipse ellipse, Style style = Style::Outline);

protected:
modm::ResumableResult<void> drawQuadPoints(Point center, Point point);

modm::ResumableResult<void> updateClipping();
modm::ResumableResult<void> setClipping(Point point);
modm::ResumableResult<void>
drawQuadPoints(Point center, Point point);

modm::ResumableResult<void>
updateClipping();
modm::ResumableResult<void>
setClipping(Point point);

inline void
initialize_writeBuffer_monochrome(Point origin);

// TODO Add final as soon as RemotePainter is connected
// Hardware accelerated drawing directly on the screen
modm::ResumableResult<void> drawFast(Point point);
modm::ResumableResult<void> drawFast(HLine hline);
modm::ResumableResult<void> drawFast(VLine vline);
modm::ResumableResult<void> drawFast(Section section);
modm::ResumableResult<void>
drawFast(Point point);
modm::ResumableResult<void>
drawFast(HLine hline);
modm::ResumableResult<void>
drawFast(VLine vline);
modm::ResumableResult<void>
drawFast(Section section);

// Static variables for resumable functions
union {
Expand All @@ -151,18 +177,21 @@ class Ili9341
ili9341_register::MemoryAccessCtrl_t madCtrl;

// Parallel use in resumable function: don't overlap!
struct {
struct
{
uint16_t buff_cmd_clipping[2];

// Buffer for conversion
modm::Buffer<colorType, RB> buffer_conversion;
Point buffer_conversion_pos;
// Primary Pixelbuffer
colorType buffer[BC];
size_t buffer_i;

size_t pixels_to_write, pixel_bulk;

// Keep track of current position in
Point scanner;
ScannerBufferBool bool_scanner;

colorType color_temp;
union {
uint16_t write_height;
uint32_t write_pixels;
};
colorType temp_color;
} p; // p for parallel
};

Expand Down
Loading

0 comments on commit 8d11b57

Please sign in to comment.