// Draw a filled rectangle. Note: damages text color register
void RA8876_common::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) {
x += _originx;
y += _originy;
int16_t x_end = x + w - 1;
int16_t y_end = y + h - 1;
if ((x >= _displayclipx2) || // Clip right
(y >= _displayclipy2) || // Clip bottom
(x_end < _displayclipx1) || // Clip left
(y_end < _displayclipy1)) // Clip top
{
// outside the clip rectangle
return;
}
if (x < _displayclipx1)
x = _displayclipx1;
if (y < _displayclipy1)
y = _displayclipy1;
if (x_end > _displayclipx2)
x_end = _displayclipx2;
if (y_end > _displayclipy2)
y_end = _displayclipy2;
check2dBusy();
graphicMode(true); <------------------------ Switched to graphics mode ------------------------
foreGroundColor16bpp(color);
switch (_rotation) {
case 1:
swapvals(x, y);
swapvals(x_end, y_end);
break;
case 2:
x = _width - x;
x_end = _width - x_end;
;
break;
case 3:
rotateCCXY(x, y);
rotateCCXY(x_end, y_end);
break;
}
lcdRegDataWrite(RA8876_DLHSR0, x, false); // 68h
lcdRegDataWrite(RA8876_DLHSR1, x >> 8, false); // 69h
lcdRegDataWrite(RA8876_DLVSR0, y, false); // 6ah
lcdRegDataWrite(RA8876_DLVSR1, y >> 8, false); // 6bh
lcdRegDataWrite(RA8876_DLHER0, x_end, false); // 6ch
lcdRegDataWrite(RA8876_DLHER1, x_end >> 8, false); // 6dh
lcdRegDataWrite(RA8876_DLVER0, y_end, false); // 6eh
lcdRegDataWrite(RA8876_DLVER1, y_end >> 8, false); // 6fh
lcdRegDataWrite(RA8876_DCR1, RA8876_DRAW_SQUARE_FILL, true); // 76h,0xE0
}