SPI based library for the ST7735 LCD controller.
Dependents: RayCastingEngine RETRO_LCD_PerformanceTest RETRO_loop_test RETRO_RickGame ... more
Diff: LCD_ST7735.cpp
- Revision:
- 12:146a55dccb22
- Parent:
- 9:7ecd74dcb8ef
- Child:
- 13:a559617cdf94
--- a/LCD_ST7735.cpp Thu Jan 22 01:53:06 2015 +0000 +++ b/LCD_ST7735.cpp Sun Jan 25 06:53:17 2015 +0000 @@ -220,6 +220,9 @@ } void LCD_ST7735::fillRect(int x1, int y1, int x2, int y2, uint16_t fillColor) { + if (x1 > x2) swap(x1, x2); + if (y1 > y2) swap(y1, y2); + clipRect(x1, y1, x2, y2); int c = ((x2-x1) * (y2-y1)) << 1; uint8_t colorHigh = fillColor >> 8; @@ -238,16 +241,20 @@ if (y1 > y2) swap(y1, y2); drawRect(x1, y1, x2, y2, borderColor); - clipRect(x1 + 1, y1 + 1, x2 - 1, y2 - 1); - int c = ((x2-x1-2) * (y2-y1-2)) << 1; - uint8_t colorHigh = fillColor >> 8; - uint8_t colorLow = fillColor; - beginBatchCommand(CMD_RAMWR); - while(c--) + ++x1; ++y1; --x2; --y2; + if (x2 >= x1 && y2 >= y1) { - writeBatchData(colorHigh, colorLow); + clipRect(x1, y1, x2, y2); + int c = ((x2-x1-2) * (y2-y1-2)) << 1; + uint8_t colorHigh = fillColor >> 8; + uint8_t colorLow = fillColor; + beginBatchCommand(CMD_RAMWR); + while(c--) + { + writeBatchData(colorHigh, colorLow); + } + endBatchCommand(); } - endBatchCommand(); } void LCD_ST7735::fillCircle(int x, int y, int r, uint16_t borderColor, uint16_t fillColor)