1616#include < modm/architecture/interface/register.hpp>
1717#include < modm/platform/gpio/base.hpp>
1818#include < modm/processing/resumable.hpp>
19-
20- #include < modm/ui/graphic/display.hpp>
2119#include < modm/ui/graphic/buffer.hpp>
2220#include < modm/ui/graphic/buffer_bool.hpp>
21+ #include < modm/ui/graphic/display.hpp>
2322// #include <modm/ui/graphic/painter_remote.hpp>
2423
2524#include " ili9341_interface_parallel.hpp"
@@ -31,14 +30,13 @@ namespace modm
3130{
3231
3332// / @ingroup modm_driver_ili9341
34- template <class Interface , class Reset , class RB = Resolution<32 , 32 >>
35- class Ili9341
36- : public Interface,
37- // : public RemotePainter<Resolution<320, 240>, Interface>,
38- public Display<color::Rgb565<true >, Resolution<320 , 240 >, true >,
39- public FlashPainter<true >
33+ template <class Interface , class Reset , size_t BC = 1024 >
34+ class Ili9341 : public Interface ,
35+ // : public RemotePainter<Resolution<320, 240>, Interface>,
36+ public Display<color::Rgb565<true >, Resolution<320 , 240 >, true >,
37+ public FlashPainter<true >
4038{
41- static_assert (RB::H % 8 == 0 , " Height of BufferResolution must be multiple of 8 " );
39+ static_assert (BC >= 128 , " Buffer for conversion requires a reasonable minimum size. " );
4240
4341 using Toggle = ili9341_register::Toggle;
4442 using ReadWrite = ili9341_register::ReadWrite;
@@ -49,10 +47,12 @@ class Ili9341
4947 using colorType = color::Rgb565<true >;
5048
5149 template <typename ... Args>
52- Ili9341 (Args &&...args) :
53- Interface (std::forward<Args>(args)...),
54- Display<colorType, Resolution<320 , 240 >, true >(color::html::White)
55- { Reset::setOutput (modm::Gpio::High); }
50+ Ili9341 (Args &&...args)
51+ : Interface(std::forward<Args>(args)...),
52+ Display<colorType, Resolution<320 , 240 >, true >(color::html::White)
53+ {
54+ Reset::setOutput (modm::Gpio::High);
55+ }
5656
5757 ~Ili9341 (){};
5858
@@ -95,53 +95,79 @@ class Ili9341
9595 modm::ResumableResult<void >
9696 scrollTo (uint16_t row);
9797
98- // Write equal colored buffer via BufferInterface
98+ // Write from Pattern (compiletime poly)
99+ template <typename Pattern>
99100 modm::ResumableResult<void >
100- drawBuffer (BufferInterface<colorType> *buffer,
101- Point origin = {0 , 0 });
101+ writePattern (Section section, Pattern generator);
102102
103- // Write monochrome buffer via BufferInterface
103+ // Write equal colored Buffer (compiletime poly)
104+ template <typename R_, class Painter_ >
104105 modm::ResumableResult<void >
105- drawBuffer (BufferInterface<bool > *buffer,
106- Point origin = {0 , 0 });
106+ writeBuffer (const Buffer<colorType, R_, Painter_> &buffer, Point origin = {0 , 0 });
107107
108- // Write equal colored buffer
108+ // Write equal colored BufferInterface (runtime poly)
109+ modm::ResumableResult<void >
110+ writeBuffer (BufferInterface<colorType> *buffer, Point origin = {0 , 0 });
111+
112+ // Write different colored Buffer (compiletime poly)
113+ template <typename C_, typename R_, class Painter_ >
114+ modm::ResumableResult<void >
115+ writeBuffer (const Buffer<C_, R_, Painter_> &buffer, Point origin = {0 , 0 });
116+
117+ // Write monochrome Buffer (compiletime poly)
109118 template <typename R_, class Painter_ >
110119 modm::ResumableResult<void >
111- drawBuffer (const Buffer<colorType , R_, Painter_> &buffer, Point origin = {0 , 0 });
120+ writeBuffer (const Buffer<bool , R_, Painter_> &buffer, Point origin = {0 , 0 });
112121
113- // Write different colored buffer
114- template <class C_ , typename R_, class Painter_ >
122+ // Write monochrome BufferInterface (runtime poly)
115123 modm::ResumableResult<void >
116- drawBuffer ( const Buffer<C_, R_, Painter_> & buffer, Point origin = {0 , 0 });
124+ writeBuffer (BufferInterface< bool > * buffer, Point origin = {0 , 0 });
117125
126+ // Write monochrome Flash (runtime poly)
118127 modm::ResumableResult<void >
119- drawFlash (modm::accessor::Flash<uint8_t > data, uint16_t width, uint16_t height, Point originorigin = {0 , 0 }) final ;
128+ writeFlash (modm::accessor::Flash<uint8_t > data, uint16_t width, uint16_t height,
129+ Point originorigin = {0 , 0 }) final ;
120130
121131 // Clear whole screen with color
122132 modm::ResumableResult<void >
123133 clear (colorType color = html::Black);
124134
125135 // FIXME Fix inheritance on RemotePainter and move all of draw(..) there
126- modm::ResumableResult<void > draw (Point point);
127- modm::ResumableResult<void > draw (Line line);
128- modm::ResumableResult<void > draw (Rectangle rectangle, Style style = Style::Outline);
129- modm::ResumableResult<void > draw (Rectangle rectangle, uint16_t radius, Style style = Style::Outline);
130- modm::ResumableResult<void > draw (Circle circle, Style style = Style::Outline);
131- modm::ResumableResult<void > draw (Ellipse ellipse, Style style = Style::Outline);
132-
136+ modm::ResumableResult<void >
137+ draw (Point point);
138+ modm::ResumableResult<void >
139+ draw (Line line);
140+ modm::ResumableResult<void >
141+ draw (Rectangle rectangle, Style style = Style::Outline);
142+ modm::ResumableResult<void >
143+ draw (Rectangle rectangle, uint16_t radius, Style style = Style::Outline);
144+ modm::ResumableResult<void >
145+ draw (Circle circle, Style style = Style::Outline);
146+ modm::ResumableResult<void >
147+ draw (Ellipse ellipse, Style style = Style::Outline);
148+
133149protected:
134- modm::ResumableResult<void > drawQuadPoints (Point center, Point point);
135-
136- modm::ResumableResult<void > updateClipping ();
137- modm::ResumableResult<void > setClipping (Point point);
150+ modm::ResumableResult<void >
151+ drawQuadPoints (Point center, Point point);
152+
153+ modm::ResumableResult<void >
154+ updateClipping ();
155+ modm::ResumableResult<void >
156+ setClipping (Point point);
157+
158+ inline void
159+ initialize_writeBuffer_monochrome (Point origin);
138160
139161 // TODO Add final as soon as RemotePainter is connected
140162 // Hardware accelerated drawing directly on the screen
141- modm::ResumableResult<void > drawFast (Point point);
142- modm::ResumableResult<void > drawFast (HLine hline);
143- modm::ResumableResult<void > drawFast (VLine vline);
144- modm::ResumableResult<void > drawFast (Section section);
163+ modm::ResumableResult<void >
164+ drawFast (Point point);
165+ modm::ResumableResult<void >
166+ drawFast (HLine hline);
167+ modm::ResumableResult<void >
168+ drawFast (VLine vline);
169+ modm::ResumableResult<void >
170+ drawFast (Section section);
145171
146172 // Static variables for resumable functions
147173 union {
@@ -151,18 +177,21 @@ class Ili9341
151177 ili9341_register::MemoryAccessCtrl_t madCtrl;
152178
153179 // Parallel use in resumable function: don't overlap!
154- struct {
180+ struct
181+ {
155182 uint16_t buff_cmd_clipping[2 ];
156183
157- // Buffer for conversion
158- modm::Buffer<colorType, RB> buffer_conversion;
159- Point buffer_conversion_pos;
184+ // Primary Pixelbuffer
185+ colorType buffer[BC];
186+ size_t buffer_i;
187+
188+ size_t pixels_to_write, pixel_bulk;
189+
190+ // Keep track of current position in
191+ Point scanner;
192+ ScannerBufferBool bool_scanner;
160193
161- colorType color_temp;
162- union {
163- uint16_t write_height;
164- uint32_t write_pixels;
165- };
194+ colorType temp_color;
166195 } p; // p for parallel
167196 };
168197
0 commit comments