Skip to content

Commit 0999246

Browse files
committed
Fixes RGB rotation..
Thank you to @getznerh for taking the time to track down the issue with this. I have made some many changes to this driver trying to improve the performance of it and I didn't get the calculations quite right. TY for fixing this for us. This is a big help and now that it is fixed I am going to utilize the rotation across all of the bus drivers.
1 parent 36c5ee2 commit 0999246

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

ext_mod/lcd_bus/esp32_src/rgb_bus_rotation.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@
346346
MIN(x_end, dst_width), MIN(y_end, dst_height),
347347
dst_width, dst_height, bytes_per_pixel, rgb565_dither);
348348
} else {
349-
y_end += 1;
349+
y_end += 1; // removes black lines between blocks
350350
if (rotate == RGB_BUS_ROTATION_90 || rotate == RGB_BUS_ROTATION_270) {
351351
x_start = MIN(x_start, dst_height);
352352
x_end = MIN(x_end, dst_height);
@@ -380,7 +380,7 @@
380380
if(x_start == 0 && x_end == (dst_width - 1) && !rgb565_dither) {
381381
memcpy(dst, src, dst_width * (y_end - y_start + 1) * bytes_per_pixel);
382382
} else {
383-
uint32_t src_bytes_per_line = (x_end - x_start) * bytes_per_pixel;
383+
uint32_t src_bytes_per_line = (x_end - x_start + 1) * bytes_per_pixel;
384384
uint32_t dst_bytes_per_line = dst_width * bytes_per_pixel;
385385

386386
if (rgb565_dither) {
@@ -409,7 +409,7 @@
409409
uint32_t i;
410410
uint32_t j;
411411

412-
uint32_t src_bytes_per_line = x_end - x_start;
412+
uint32_t src_bytes_per_line = x_end - x_start + 1;
413413
uint32_t offset = y_start * src_bytes_per_line + x_start;
414414

415415
switch (rotate) {
@@ -436,6 +436,7 @@
436436
src++;
437437
i--;
438438
}
439+
src++;
439440
}
440441
break;
441442

@@ -468,7 +469,7 @@
468469
uint32_t i;
469470
uint32_t j;
470471

471-
uint32_t src_bytes_per_line = x_end - x_start;
472+
uint32_t src_bytes_per_line = x_end - x_start + 1;
472473
uint32_t offset = y_start * src_bytes_per_line + x_start;
473474

474475
if (rgb565_dither) {
@@ -498,6 +499,7 @@
498499
src++;
499500
i--;
500501
}
502+
src++;
501503
}
502504
break;
503505

@@ -545,7 +547,8 @@
545547
src++;
546548
i--;
547549
}
548-
}
550+
src++;
551+
}
549552
break;
550553

551554
// SWAP_XY MIRROR_X
@@ -577,7 +580,7 @@
577580
uint32_t i;
578581
uint32_t j;
579582

580-
uint32_t src_bytes_per_line = (x_end - x_start) * 3;
583+
uint32_t src_bytes_per_line = (x_end - x_start + 1) * 3;
581584
uint32_t offset = y_start * src_bytes_per_line + x_start * 3;
582585

583586
switch (rotate) {
@@ -605,6 +608,7 @@
605608
src += 3;
606609
i -= 3;
607610
}
611+
src++;
608612
}
609613
break;
610614

@@ -636,7 +640,7 @@
636640
uint32_t i;
637641
uint32_t j;
638642

639-
uint32_t src_bytes_per_line = x_end - x_start;
643+
uint32_t src_bytes_per_line = x_end - x_start + 1;
640644
uint32_t offset = y_start * src_bytes_per_line + x_start;
641645

642646
switch (rotate) {
@@ -663,6 +667,7 @@
663667
src++;
664668
i--;
665669
}
670+
src++;
666671
}
667672
break;
668673

0 commit comments

Comments
 (0)