SPI based library for the ST7735 LCD controller.
Dependents: RayCastingEngine RETRO_LCD_PerformanceTest RETRO_loop_test RETRO_RickGame ... more
Revision 14:c94d0a2c2ba0, committed 2015-02-01
- Comitter:
- taylorza
- Date:
- Sun Feb 01 06:49:14 2015 +0000
- Parent:
- 13:a559617cdf94
- Child:
- 15:516f15979b53
- Commit message:
- Added broad font clipping and fixed bug in fillRect
Changed in this revision
LCD_ST7735.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/LCD_ST7735.cpp Sun Feb 01 05:09:49 2015 +0000 +++ b/LCD_ST7735.cpp Sun Feb 01 06:49:14 2015 +0000 @@ -243,9 +243,10 @@ drawRect(x1, y1, x2, y2, borderColor); ++x1; ++y1; --x2; --y2; if (x2 >= x1 && y2 >= y1) - { - clipRect(x1, y1, x2, y2); - int c = ((x2-x1-2) * (y2-y1-2)) << 1; + { + int c = ((x2 + 1 - x1) * (y2 + 1 - y1)) << 1; + + clipRect(x1, y1, x2, y2); uint8_t colorHigh = fillColor >> 8; uint8_t colorLow = fillColor; beginBatchCommand(CMD_RAMWR); @@ -393,15 +394,20 @@ uint8_t topPad = *(pFont + 5); uint8_t bottomPad = *(pFont + 6); + if (y + topPad + h + bottomPad < 0) return; + if (y >= _height) return; + if (x + leftPad + w + rightPad < 0) return; + char *p = (char*)pString; while(*p != 0) - { + { + if (x >= _width) return; drawChar(pFont, x, y, *p++, w, h, offset, leftPad, rightPad, topPad, bottomPad); x += (w + leftPad + rightPad); } } -void measureString(const uint8_t *pFont, const char *pString, uint8_t &width, uint8_t &height) +void LCD_ST7735::measureString(const uint8_t *pFont, const char *pString, uint8_t &width, uint8_t &height) { uint8_t w = *pFont; uint8_t h = *(pFont + 1);