@@ -236,7 +236,7 @@ modm::Ili9341<Interface, Reset, BC>::updateClipping()
236236 RF_END ();
237237}
238238
239- // -- Write from Pattern ------ ---------------------------
239+ // -- Write Pattern from Generator ---------------------------
240240template <class Interface , class Reset , size_t BC>
241241template <ColorPattern P>
242242modm::ResumableResult<void >
@@ -269,113 +269,69 @@ modm::Ili9341<Interface, Reset, BC>::writePattern(Rectangle rectangle, P pattern
269269 RF_END ();
270270}
271271
272- // -- Write equal colored BufferInterface -----------------------------
272+ // -- Write equal colored BufferInterface --------------------
273273template <class Interface , class Reset , size_t BC>
274+ template <template <typename > class Accessor >
274275modm::ResumableResult<void >
275- modm::Ili9341<Interface, Reset, BC>::writeBuffer(
276- const BufferInterface<C> *buffer, Point origin) {
276+ modm::Ili9341<Interface, Reset, BC>::writeImage(
277+ modm::graphic::Image<C, Accessor> image, Point origin)
278+ {
277279 RF_BEGIN ();
278280
279- this ->layout = buffer->getLayout ();
280-
281- this ->clipping = this ->getIntersection (Rectangle (origin, this ->layout .size ));
281+ this ->clipping = this ->getIntersection (Rectangle (origin, image.size ));
282282 RF_CALL (updateClipping ());
283283
284284 // Add left offset
285- if (origin.x < 0 )
286- this ->layout .buffer += -origin.x * this ->layout .size .y * 2 ;
285+ /* if(origin.x < 0)
286+ this->layout.buffer += -origin.x * this->layout.size.y * 2; */
287287
288- // Check if we exceed the display vertically
289- if (origin.y < 0 or origin.y + this ->layout .size .y != this ->clipping .bottomRight .y )
288+ // Check if display is exceeded vertically
289+ /* if (origin.y < 0 or origin.y + this->layout.size.y != this->clipping.bottomRight.y)
290290 {
291+ // Can't transfer continuously, send row by row
292+
291293 // Add top offset
292294 if(origin.y < 0)
293295 this->layout.buffer += -origin.y * 2;
294296
295- // Can't transfer buffer continuously, send row by row
296297 p.pixels_bulk = this->clipping.getHeight();
297298 while(p.pixels) {
298299 RF_CALL(this->writeData((C*)(this->layout.buffer), p.pixels_bulk));
299300 this->layout.buffer += this->layout.size.y * 2;
300301 p.pixels -= p.pixels_bulk;
301302 }
302303 } else
303- {
304- // Transfer buffer continuously in one shot
305- RF_CALL (this ->writeData ((C*)(this ->layout .buffer ), p.pixels ));
306- }
307-
308- RF_END ();
309- }
310-
311- // -- Write different colored BufferInterface -----------------------------
312- template <class Interface , class Reset , size_t BC>
313- template <Color C_>
314- modm::ResumableResult<void >
315- modm::Ili9341<Interface, Reset, BC>::writeBuffer(
316- const BufferInterface<C_> *buffer, Point origin) {
317- RF_BEGIN ();
304+ { */
305+ // Transfer buffer in one shot
306+ RF_CALL (this ->writeData ((C*)(image.getPointer ()), p.pixels ));
307+ /* } */
318308
319- this ->clipping = this ->getIntersection (Rectangle (origin, this ->layout .size ));
320- RF_CALL (updateClipping ());
321-
322309 RF_END ();
323310}
324311
325312// -- Write monochrome BufferInterface -------------------
326313template <class Interface , class Reset , size_t BC>
314+ template <template <typename > class Accessor >
327315modm::ResumableResult<void >
328- modm::Ili9341<Interface, Reset, BC>::writeBuffer(
329- const BufferInterface<bool > *buffer, Point origin) {
330- RF_BEGIN ();
331-
332- this ->layout = buffer->getLayout ();
333- this ->clipping = this ->getIntersection (Rectangle (origin, this ->layout .size ));
334- RF_CALL (updateClipping ());
335-
336- p.mono_reader = MonochromeReader (this ->layout .buffer , this ->layout .size .x , origin);
337- p.scanner = this ->clipping .topLeft ;
338-
339- while (p.pixels )
340- {
341- // Convert next Bulk
342- for (p.i = 0 ; p.i < std::min<uint32_t >(p.pixels , BC); p.i ++) {
343- p.buffer [p.i ] = p.mono_reader () ? color : C (html::Black);
344- if (++p.scanner .y == this ->clipping .bottomRight .y ) {
345- scannerNextRow ();
346- p.mono_reader .nextRow ();
347- }
348- }
349- // Transfer
350- RF_CALL (this ->writeData (p.buffer , p.i ));
351- p.pixels -= p.i ;
352- }
353-
354- RF_END ();
355- }
356-
357- // -- Write monochrome Flash -----------------------------
358- template <class Interface , class Reset , size_t BC>
359- modm::ResumableResult<void >
360- modm::Ili9341<Interface, Reset, BC>::writeFlash(modm::accessor::Flash<uint8_t > data,
361- uint16_t width, uint16_t height, Point origin) {
316+ modm::Ili9341<Interface, Reset, BC>::writeImage(
317+ modm::graphic::Image<bool , Accessor> image, Point origin) {
362318 RF_BEGIN ();
363319
364- this ->clipping = this ->getIntersection (Rectangle (origin, {width, height} ));
320+ this ->clipping = this ->getIntersection (Rectangle (origin, image. size ));
365321 RF_CALL (updateClipping ());
366322
367- // FIXME MonochromeReader must learn to handle modm::accessor::Flash<uint8_t>
368- // p.mono_reader = MonochromeReader(data, width, origin);
323+ // FIXME store image locally
324+ image. initializeReader ( origin);
369325 p.scanner = this ->clipping .topLeft ;
370326
371327 while (p.pixels )
372328 {
373329 // Convert next Bulk
374330 for (p.i = 0 ; p.i < std::min<uint32_t >(p.pixels , BC); p.i ++) {
375- // p.buffer[p.i] = p.mono_reader () ? color : C(html::Black);
331+ p.buffer [p.i ] = image () ? color : C (html::Black);
376332 if (++p.scanner .y == this ->clipping .bottomRight .y ) {
377333 scannerNextRow ();
378- // p.mono_reader .nextRow();
334+ image .nextRow ();
379335 }
380336 }
381337 // Transfer
@@ -393,26 +349,23 @@ modm::Ili9341<Interface, Reset, BC>::drawFast(Point point)
393349{
394350 RF_BEGIN ();
395351 RF_CALL (setClipping (point));
396- RF_CALL (this ->writeData (color));
397- RF_END ();
352+ RF_END_RETURN_CALL (this ->writeData (color));
398353}
399354
400355template <class Interface , class Reset , size_t BC>
401356modm::ResumableResult<void >
402357modm::Ili9341<Interface, Reset, BC>::drawFast(HLine hline)
403358{
404359 RF_BEGIN ();
405- RF_CALL (drawFast (Section (hline.start , {hline.end_x , hline.start .y + 1 })));
406- RF_END ();
360+ RF_END_RETURN_CALL (drawFast (Section (hline.start , {hline.end_x , hline.start .y + 1 })));
407361}
408362
409363template <class Interface , class Reset , size_t BC>
410364modm::ResumableResult<void >
411365modm::Ili9341<Interface, Reset, BC>::drawFast(VLine vline)
412366{
413367 RF_BEGIN ();
414- RF_CALL (drawFast (Section (vline.start , {vline.start .x + 1 , vline.end_y })));
415- RF_END ();
368+ RF_END_RETURN_CALL (drawFast (Section (vline.start , {vline.start .x + 1 , vline.end_y })));
416369}
417370
418371template <class Interface , class Reset , size_t BC>
0 commit comments