HW accelerated Ellipses

This commit is contained in:
KTOWN 2013-10-14 14:35:39 +02:00
parent 8533076e15
commit cc22b46b79
2 changed files with 64 additions and 0 deletions

View File

@ -287,6 +287,16 @@ void Adafruit_RA8875::fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y
triangleHelper(x0, y0, x1, y1, x2, y2, color, true);
}
void Adafruit_RA8875::drawEllipse(int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint16_t color)
{
ellipseHelper(xCenter, yCenter, longAxis, shortAxis, color, false);
}
void Adafruit_RA8875::fillEllipse(int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint16_t color)
{
ellipseHelper(xCenter, yCenter, longAxis, shortAxis, color, true);
}
void Adafruit_RA8875::circleHelper(int16_t x0, int16_t y0, int16_t r, uint16_t color, bool filled)
{
/* Set X */
@ -450,6 +460,57 @@ void Adafruit_RA8875::triangleHelper(int16_t x0, int16_t y0, int16_t x1, int16_t
}
}
void Adafruit_RA8875::ellipseHelper(int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint16_t color, bool filled)
{
/* Set Center Point */
writeCommand(0xA5);
writeData(xCenter);
writeCommand(0xA6);
writeData(xCenter >> 8);
writeCommand(0xA7);
writeData(yCenter);
writeCommand(0xA8);
writeData(yCenter >> 8);
/* Set Long and Short Axis */
writeCommand(0xA1);
writeData(longAxis);
writeCommand(0xA2);
writeData(longAxis >> 8);
writeCommand(0xA3);
writeData(shortAxis);
writeCommand(0xA4);
writeData(shortAxis >> 8);
/* Set Color */
writeCommand(0x63);
writeData((color & 0xf800) >> 11);
writeCommand(0x64);
writeData((color & 0x07e0) >> 5);
writeCommand(0x65);
writeData((color & 0x001f));
/* Draw! */
writeCommand(0xA0);
if (filled)
{
writeData(0xC0);
}
else
{
writeData(0x80);
}
/* Wait for the command to finish */
bool finished = false;
while (!finished)
{
uint8_t temp = readReg(0xA0);
if (!(temp & 0x80))
finished = true;
}
}
/************************* Mid Level ***********************************/
void Adafruit_RA8875::GPIOX(boolean on) {

View File

@ -60,6 +60,8 @@ class Adafruit_RA8875 : public Adafruit_GFX {
void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
void drawEllipse(int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint16_t color);
void fillEllipse(int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint16_t color);
/* Backlight */
void GPIOX(boolean on);
@ -92,6 +94,7 @@ class Adafruit_RA8875 : public Adafruit_GFX {
void circleHelper(int16_t x0, int16_t y0, int16_t r, uint16_t color, bool filled);
void rectHelper (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color, bool filled);
void triangleHelper(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color, bool filled);
void ellipseHelper(int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint16_t color, bool filled);
uint8_t _cs, _rst;
uint16_t _width, _height;