@@ -202,10 +202,9 @@ void
202
202
Ili9341<Interface, Reset, Backlight, BufferSize>::drawHorizontalLine(
203
203
glcd::Point start, uint16_t length)
204
204
{
205
- uint16_t const pixelValue { modm::toBigEndian (foregroundColor.color ) };
206
205
auto minLength { std::min (std::size_t (length), BufferSize) };
207
206
uint16_t *buffer16 { reinterpret_cast <uint16_t *>(buffer) };
208
- std::fill (buffer16, buffer16+minLength, pixelValue );
207
+ std::fill (buffer16, buffer16+minLength, foregroundColor. color );
209
208
210
209
BatchHandle h (*this );
211
210
@@ -223,10 +222,9 @@ void
223
222
Ili9341<Interface, Reset, Backlight, BufferSize>::drawVerticalLine(
224
223
glcd::Point start, uint16_t length)
225
224
{
226
- uint16_t const pixelValue { modm::toBigEndian (foregroundColor.color ) };
227
225
auto minLength { std::min (std::size_t (length), BufferSize) };
228
226
uint16_t *buffer16 { reinterpret_cast <uint16_t *>(buffer) };
229
- std::fill (buffer16, buffer16+minLength, pixelValue );
227
+ std::fill (buffer16, buffer16+minLength, foregroundColor. color );
230
228
231
229
BatchHandle h (*this );
232
230
@@ -248,10 +246,9 @@ Ili9341<Interface, Reset, Backlight, BufferSize>::fillRectangle(
248
246
auto const y { upperLeft.getY () };
249
247
std::size_t pixelCount { std::size_t (width) * std::size_t (height) };
250
248
251
- uint16_t const pixelValue { modm::toBigEndian (foregroundColor.color ) };
252
249
auto minLength { std::min (std::size_t (pixelCount), BufferSize) };
253
250
uint16_t *buffer16 { reinterpret_cast <uint16_t *>(buffer) };
254
- std::fill (buffer16, buffer16+minLength, pixelValue );
251
+ std::fill (buffer16, buffer16+minLength, foregroundColor. color );
255
252
256
253
BatchHandle h (*this );
257
254
270
267
Ili9341<Interface, Reset, Backlight, BufferSize>::fillCircle(
271
268
glcd::Point center, uint16_t radius)
272
269
{
273
- uint8_t const setColor[] { uint8_t ((foregroundColor.color >> 8 ) & 0xff ),
274
- uint8_t (foregroundColor.color & 0xff ) };
275
-
276
270
int16_t f = 1 - radius;
277
271
int16_t ddF_x = 0 ;
278
272
int16_t ddF_y = -2 * radius;
@@ -283,7 +277,7 @@ Ili9341<Interface, Reset, Backlight, BufferSize>::fillCircle(
283
277
284
278
setClipping (center.getX () - radius, center.getY (), 2 * radius, 1 );
285
279
for (std::size_t i = 0 ; i < 2 * radius; ++i)
286
- this ->writeData (setColor, 2 );
280
+ this ->writeData (foregroundColor. color );
287
281
288
282
while (x < y)
289
283
{
@@ -299,16 +293,16 @@ Ili9341<Interface, Reset, Backlight, BufferSize>::fillCircle(
299
293
300
294
setClipping (center.getX () - x, center.getY () - y, 2 * x, 1 );
301
295
for (std::size_t i = 0 ; i < 2 * x; ++i)
302
- this ->writeData (setColor, 2 );
296
+ this ->writeData (foregroundColor. color );
303
297
setClipping (center.getX () - y, center.getY () - x, 2 * y, 1 );
304
298
for (std::size_t i = 0 ; i < 2 * y; ++i)
305
- this ->writeData (setColor, 2 );
299
+ this ->writeData (foregroundColor. color );
306
300
setClipping (center.getX () - x, center.getY () + y, 2 * x, 1 );
307
301
for (std::size_t i = 0 ; i < 2 * x; ++i)
308
- this ->writeData (setColor, 2 );
302
+ this ->writeData (foregroundColor. color );
309
303
setClipping (center.getX () - y, center.getY () + x, 2 * y, 1 );
310
304
for (std::size_t i = 0 ; i < 2 * y; ++i)
311
- this ->writeData (setColor, 2 );
305
+ this ->writeData (foregroundColor. color );
312
306
}
313
307
}
314
308
@@ -317,11 +311,6 @@ void
317
311
Ili9341<Interface, Reset, Backlight, BufferSize>::drawImageRaw(glcd::Point upperLeft,
318
312
uint16_t width, uint16_t height, modm::accessor::Flash<uint8_t > data)
319
313
{
320
- uint8_t const setColor[] { uint8_t ((foregroundColor.color >> 8 ) & 0xff ),
321
- uint8_t (foregroundColor.color & 0xff ) };
322
- uint8_t const clearColor[] { uint8_t ((backgroundColor.color >> 8 ) & 0xff ),
323
- uint8_t (backgroundColor.color & 0xff ) };
324
-
325
314
BatchHandle h (*this );
326
315
327
316
setClipping (upperLeft.getX (), upperLeft.getY (), width, height);
@@ -333,9 +322,9 @@ Ili9341<Interface, Reset, Backlight, BufferSize>::drawImageRaw(glcd::Point upper
333
322
{
334
323
uint8_t byte = data[(r / 8 ) * width + w];
335
324
if (byte & bit)
336
- this ->writeData (setColor, 2 );
325
+ this ->writeData (foregroundColor. color );
337
326
else
338
- this ->writeData (clearColor, 2 );
327
+ this ->writeData (backgroundColor. color );
339
328
}
340
329
// TODO: optimize, use ROL (rotate left)
341
330
bit <<= 1 ;
@@ -351,13 +340,8 @@ Ili9341<Interface, Reset, Backlight, BufferSize>::drawRaw(glcd::Point upperLeft,
351
340
{
352
341
BatchHandle h (*this );
353
342
354
- uint16_t * buffer = (uint16_t *)data;
355
- for (size_t i = 0 ; i < size_t (width*height); i++) {
356
- buffer[i] = modm::fromBigEndian (buffer[i]);
357
- }
358
-
359
343
setClipping (upperLeft.getX (), upperLeft.getY (), width, height);
360
- this ->writeData (( uint8_t *)buffer , width * height * 2 );
344
+ this ->writeData (data , width * height);
361
345
}
362
346
363
347
template <class Interface , class Reset , class Backlight , std::size_t BufferSize>
@@ -391,13 +375,10 @@ void
391
375
Ili9341<Interface, Reset, Backlight, BufferSize>::setColoredPixel(
392
376
int16_t x, int16_t y, color::Rgb565 const &color)
393
377
{
394
- auto const pixelColor { color };
395
- uint8_t const setColor[] { uint8_t ((pixelColor.color >> 8 ) & 0xff ), uint8_t (pixelColor.color & 0xff ) };
396
-
397
378
BatchHandle h (*this );
398
379
399
380
this ->setClipping (x, y, 1 , 1 );
400
- this ->writeData (setColor, 2 );
381
+ this ->writeData (foregroundColor. color );
401
382
}
402
383
403
384
template <class Interface , class Reset , class Backlight , std::size_t BufferSize>
0 commit comments