void RA8876_t3::writeRect(int16_t x, int16_t y, int16_t w, int16_t h, const uint16_t *pcolors)
{
uint16_t start_x = (x != CENTER) ? x : (_width - w) / 2;
uint16_t start_y = (y != CENTER) ? y : (_height - h) / 2;
// BUGBUG:: Should check if > this size and do multiple outputs.
static uint16_t rotated_row[1024]; // max size.
switch (_rotation) {
case 0: // we will just hand off for now to
// unrolled to bte call
//Using the BTE function is faster and will use DMA if available
bteMpuWriteWithROPData8(currentPage, width(), x, y, //Source 1 is ignored for ROP 12
currentPage, width(), x, y, w, h, //destination address, pagewidth, x/y, width/height
RA8876_BTE_ROP_CODE_12,
( const unsigned char *)pcolors);
break;
case 1:
pcolors += (w - 1);
for (uint16_t x = start_x + w - 1; x >= start_x; x--) {
const uint16_t *pimage = pcolors;
for (uint16_t i = 0; i < h; i++) {
rotated_row[i] = *pimage;
pimage += w;
}
//Serial.printf("DP %x, %d, %d %d\n", rotated_row, h, start_x, y);
bteMpuWriteWithROPData8(currentPage, height(), start_y, x, //Source 1 is ignored for ROP 12
currentPage, height(), start_y, x, h, 1, //destination address, pagewidth, x/y, width/height
RA8876_BTE_ROP_CODE_12,
( const unsigned char *)rotated_row);
pcolors--;
}
break;
case 2:
// unrolled to bte call
//Using the BTE function is faster and will use DMA if available
// We reverse the colors in the row...
while (h) {
for (int i = (int)w - 1; i >= 0; i--) {
rotated_row[i] = *pcolors++;
}
bteMpuWriteWithROPData8(currentPage, width(), x, y, //Source 1 is ignored for ROP 12
currentPage, width(), x, y, w, 1, //destination address, pagewidth, x/y, width/height
RA8876_BTE_ROP_CODE_12,
( const unsigned char *)rotated_row);
y++;
h--;
}
break;
case 3:
pcolors += (w - 1);
for (uint16_t x = start_x + w - 1; x >= start_x; x--) {
const uint16_t *pimage = pcolors;
for (uint16_t i = 0; i < h; i++) {
// cleanup..
rotated_row[h-i-1] = *pimage;
pimage += w;
}
//Serial.printf("DP %x, %d, %d %d\n", rotated_row, h, start_x, y);
bteMpuWriteWithROPData8(currentPage, height(), start_y, x, //Source 1 is ignored for ROP 12
currentPage, height(), start_y, x, h, 1, //destination address, pagewidth, x/y, width/height
RA8876_BTE_ROP_CODE_12,
( const unsigned char *)rotated_row);
pcolors--;
}
break;
}
}